Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ from nltk.stem import WordNetLemmatizer
|
|
12 |
import tensorflow as tf
|
13 |
from tensorflow import keras
|
14 |
import spacy
|
|
|
15 |
|
16 |
nltk.download('punkt')
|
17 |
nltk.download('wordnet')
|
@@ -34,9 +35,17 @@ app = Flask(__name__)
|
|
34 |
with open('ai_chatbot_data.json', 'r') as file:
|
35 |
json_data = json.load(file)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
template = "Message: {message}\n\nSentiment Analysis: {sentiment}\n\nConversation History: {history}\n\nDate and Time: {date_time}\n\nBitcoin Price: ${bitcoin_price}\n\nBitcoin history from 1-jan-2024 to today: {database_tag}\n\nYour system: {json_data}.\n\nResponse:"
|
@@ -99,7 +108,7 @@ def submit():
|
|
99 |
history_stemmed_tokens = [ps.stem(token) for token in history_tokens]
|
100 |
history_lemmatized_tokens = [lemmatizer.lemmatize(token) for token in history_tokens]
|
101 |
|
102 |
-
model_input = prompt.format(message=user_input, sentiment=sentiment, history="<br>".join(conversation_history), database_tag=
|
103 |
|
104 |
response = llm(model_input, context="<br>".join(conversation_history))
|
105 |
|
|
|
12 |
import tensorflow as tf
|
13 |
from tensorflow import keras
|
14 |
import spacy
|
15 |
+
from bs4 import BeautifulSoup
|
16 |
|
17 |
nltk.download('punkt')
|
18 |
nltk.download('wordnet')
|
|
|
35 |
with open('ai_chatbot_data.json', 'r') as file:
|
36 |
json_data = json.load(file)
|
37 |
|
38 |
+
url = "https://dooratre-info.hf.space/?logs=container&__sign=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2NWIyYzMyNjJiZTk2NjBmMGIxMjg0MDAiLCJ1c2VyIjoiRG9vcmF0cmUifSwiaWF0IjoxNzEyNjgwNTY4LCJzdWIiOiIvc3BhY2VzL0Rvb3JhdHJlL2luZm8iLCJleHAiOjE3MTI3NjY5NjgsImlzcyI6Imh0dHBzOi8vaHVnZ2luZ2ZhY2UuY28ifQ.R_PX6Hw5SMheYTQWPGe1Qla9q8gVBU0mAFF_u8Iad06jSpZ9sPzZqquSowWn7PGVLRYBW21DnvqSwXIoNZ4CAA"
|
39 |
+
|
40 |
+
response = requests.get(url)
|
41 |
+
soup = BeautifulSoup(response.content, 'html.parser')
|
42 |
+
|
43 |
+
div_content = soup.find('div', {'id': '45'})
|
44 |
+
if div_content:
|
45 |
+
print(div_content)
|
46 |
+
else:
|
47 |
+
print("No div with id=45 found on the page.")
|
48 |
+
database_tag=div_content
|
49 |
|
50 |
|
51 |
template = "Message: {message}\n\nSentiment Analysis: {sentiment}\n\nConversation History: {history}\n\nDate and Time: {date_time}\n\nBitcoin Price: ${bitcoin_price}\n\nBitcoin history from 1-jan-2024 to today: {database_tag}\n\nYour system: {json_data}.\n\nResponse:"
|
|
|
108 |
history_stemmed_tokens = [ps.stem(token) for token in history_tokens]
|
109 |
history_lemmatized_tokens = [lemmatizer.lemmatize(token) for token in history_tokens]
|
110 |
|
111 |
+
model_input = prompt.format(message=user_input, sentiment=sentiment, history="<br>".join(conversation_history), database_tag=div_content, date_time=current_time, bitcoin_price=bitcoin_price, json_data=json_data,history_tokens=history_tokens,history_stemmed_tokens=history_stemmed_tokens,history_lemmatized_tokens=history_lemmatized_tokens)
|
112 |
|
113 |
response = llm(model_input, context="<br>".join(conversation_history))
|
114 |
|