Update app.py
Browse files
app.py
CHANGED
@@ -36,11 +36,21 @@ with open('ai_chatbot_data.json', 'r') as file:
|
|
36 |
json_data = json.load(file)
|
37 |
|
38 |
# Updated prompt template for Bitcoin trading
|
39 |
-
template = "User Message: {message}\n\nUser Sentiment: {sentiment}\n\nConversation now: {history}\n\nDate and Time: {date_time}\n\nBitcoin Price: ${bitcoin_price}\n\nBTC price from 1 jan (DATE,OPEN,HIGH,LOW,CLOSE,ADJ CLOSE,VOLUME<br/>): {
|
40 |
-
prompt = PromptTemplate(template=template, input_variables=["message", "sentiment", "history", "date_time", "bitcoin_price", "
|
41 |
conversation_history = []
|
42 |
|
43 |
MAX_HISTORY_LENGTH = 55
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
def update_conversation_history(message):
|
46 |
if len(conversation_history) >= MAX_HISTORY_LENGTH:
|
@@ -93,7 +103,7 @@ def submit():
|
|
93 |
history_lemmatized_tokens = [lemmatizer.lemmatize(token) for token in history_tokens]
|
94 |
|
95 |
model_input = prompt.format(message=user_input, sentiment=sentiment, history="\n".join(conversation_history),
|
96 |
-
|
97 |
|
98 |
response = llm(model_input, context="<br>".join(conversation_history))
|
99 |
|
|
|
36 |
json_data = json.load(file)
|
37 |
|
38 |
# Updated prompt template for Bitcoin trading
|
39 |
+
template = "User Message: {message}\n\nUser Sentiment: {sentiment}\n\nConversation now: {history}\n\nDate and Time: {date_time}\n\nBitcoin Price: ${bitcoin_price}\n\nBTC price from 1 jan (DATE,OPEN,HIGH,LOW,CLOSE,ADJ CLOSE,VOLUME<br/>): {div_content}\n\nAI System Data: {json_data}\n\nResponse:"
|
40 |
+
prompt = PromptTemplate(template=template, input_variables=["message", "sentiment", "history", "date_time", "bitcoin_price", "div_content", "json_data"])
|
41 |
conversation_history = []
|
42 |
|
43 |
MAX_HISTORY_LENGTH = 55
|
44 |
+
url = "https://dooratre-info.hf.space/?logs=container&__sign=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2NWIyYzMyNjJiZTk2NjBmMGIxMjg0MDAiLCJ1c2VyIjoiRG9vcmF0cmUifSwiaWF0IjoxNzEyNjgwNTY4LCJzdWIiOiIvc3BhY2VzL0Rvb3JhdHJlL2luZm8iLCJleHAiOjE3MTI3NjY5NjgsImlzcyI6Imh0dHBzOi8vaHVnZ2luZ2ZhY2UuY28ifQ.R_PX6Hw5SMheYTQWPGe1Qla9q8gVBU0mAFF_u8Iad06jSpZ9sPzZqquSowWn7PGVLRYBW21DnvqSwXIoNZ4CAA"
|
45 |
+
|
46 |
+
response = requests.get(url)
|
47 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
48 |
+
|
49 |
+
div_content = soup.find('div', {'id': '45'})
|
50 |
+
if div_content:
|
51 |
+
print(div_content)
|
52 |
+
else:
|
53 |
+
print("No div with id=45 found on the page.")
|
54 |
|
55 |
def update_conversation_history(message):
|
56 |
if len(conversation_history) >= MAX_HISTORY_LENGTH:
|
|
|
103 |
history_lemmatized_tokens = [lemmatizer.lemmatize(token) for token in history_tokens]
|
104 |
|
105 |
model_input = prompt.format(message=user_input, sentiment=sentiment, history="\n".join(conversation_history),
|
106 |
+
div_content="Bitcoin Data Placeholder", date_time=current_time, bitcoin_price=bitcoin_price, json_data=json_data)
|
107 |
|
108 |
response = llm(model_input, context="<br>".join(conversation_history))
|
109 |
|