Spaces:
Paused
Paused
baobuiquang
commited on
Commit
•
c587cbe
1
Parent(s):
f36b4bf
update
Browse files- app.py +28 -16
- requirements.txt +2 -0
app.py
CHANGED
@@ -14,6 +14,7 @@ import torch
|
|
14 |
import time
|
15 |
from transformers import AutoTokenizer, AutoModel
|
16 |
from datetime import datetime, timedelta
|
|
|
17 |
# pd.options.mode.chained_assignment = None # default='warn'
|
18 |
|
19 |
# ===========================
|
@@ -234,16 +235,21 @@ def chatbot_mechanism(message, history, additional_input_1):
|
|
234 |
x_text = str(df.loc[x_index, 'Tên chỉ số'])
|
235 |
y_text = str(df.columns[y_index])
|
236 |
|
|
|
|
|
|
|
237 |
# Small adjustment for better print
|
238 |
if y_text.count('/') == 4:
|
239 |
y_text = y_text[-10:] # If y_text is preprocessed datetime format, trim it
|
240 |
|
241 |
# Just add some text to warn users
|
242 |
-
|
|
|
243 |
eval_text_sub_title = ""
|
244 |
-
if x_score <= 0.
|
245 |
eval_text_sub_title = "Cảnh báo:"
|
246 |
-
|
|
|
247 |
|
248 |
# Score display
|
249 |
x_score_display = str(round((x_score - 0.8) / (1.0 - 0.8) * 100, 1))
|
@@ -254,28 +260,34 @@ def chatbot_mechanism(message, history, additional_input_1):
|
|
254 |
|
255 |
# Final print
|
256 |
final_output_message = f"\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
<div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
258 |
-
|
|
|
|
|
|
|
259 |
</div>\
|
260 |
-
• {x_text}<br>\
|
261 |
-
• {y_text if extra_information_for_special_cases_flag == False else extra_information_for_special_cases}<br>\
|
262 |
"
|
263 |
-
# <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
264 |
-
# Đánh giá:\
|
265 |
-
# </div>\
|
266 |
-
# Độ tương quan: [x={x_score_display}%, y={y_score_display}%]<br>\
|
267 |
# <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
268 |
# Kết quả:\
|
269 |
# </div>\
|
270 |
# <div style='font-weight: bold;'>\
|
271 |
# {cell_value}\
|
272 |
# </div>\
|
273 |
-
# <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
274 |
-
# {eval_text_sub_title}\
|
275 |
-
# </div>\
|
276 |
-
# <div style='color: red; font-weight: bold;'>\
|
277 |
-
# {eval_text}\
|
278 |
-
# </div>\
|
279 |
return final_output_message
|
280 |
# for i in range(len(final_output_message)):
|
281 |
# time.sleep(0.1)
|
|
|
14 |
import time
|
15 |
from transformers import AutoTokenizer, AutoModel
|
16 |
from datetime import datetime, timedelta
|
17 |
+
from dateparser.search import search_dates
|
18 |
# pd.options.mode.chained_assignment = None # default='warn'
|
19 |
|
20 |
# ===========================
|
|
|
235 |
x_text = str(df.loc[x_index, 'Tên chỉ số'])
|
236 |
y_text = str(df.columns[y_index])
|
237 |
|
238 |
+
# Not related but extract datetime in the question if any
|
239 |
+
extracted_date = search_dates(question)[0][1].strftime('%d/%m/%Y')
|
240 |
+
|
241 |
# Small adjustment for better print
|
242 |
if y_text.count('/') == 4:
|
243 |
y_text = y_text[-10:] # If y_text is preprocessed datetime format, trim it
|
244 |
|
245 |
# Just add some text to warn users
|
246 |
+
eval_text_1 = ""
|
247 |
+
eval_text_2 = ""
|
248 |
eval_text_sub_title = ""
|
249 |
+
if x_score <= 0.865 or y_score <= 0.865:
|
250 |
eval_text_sub_title = "Cảnh báo:"
|
251 |
+
eval_text_1 = "⚠️ Độ tương quan thấp ⚠️"
|
252 |
+
eval_text_2 = "opacity: 0.5;"
|
253 |
|
254 |
# Score display
|
255 |
x_score_display = str(round((x_score - 0.8) / (1.0 - 0.8) * 100, 1))
|
|
|
260 |
|
261 |
# Final print
|
262 |
final_output_message = f"\
|
263 |
+
<div style='{eval_text_2}'>\
|
264 |
+
<div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
265 |
+
Đặc trưng trích xuất được (có vector trong dữ liệu):\
|
266 |
+
</div>\
|
267 |
+
• {x_text}<br>\
|
268 |
+
• {y_text if extra_information_for_special_cases_flag == False else extra_information_for_special_cases}<br>\
|
269 |
+
<div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
270 |
+
Đặc trưng trích xuất được (nội suy):\
|
271 |
+
</div>\
|
272 |
+
• {extracted_date}<br>\
|
273 |
+
<div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
274 |
+
Đánh giá:\
|
275 |
+
</div>\
|
276 |
+
Độ tương quan: [x={x_score_display}%, y={y_score_display}%]<br>\
|
277 |
+
</div>\
|
278 |
<div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
279 |
+
{eval_text_sub_title}\
|
280 |
+
</div>\
|
281 |
+
<div style='color: red; font-weight: bold;'>\
|
282 |
+
{eval_text_1}\
|
283 |
</div>\
|
|
|
|
|
284 |
"
|
|
|
|
|
|
|
|
|
285 |
# <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
|
286 |
# Kết quả:\
|
287 |
# </div>\
|
288 |
# <div style='font-weight: bold;'>\
|
289 |
# {cell_value}\
|
290 |
# </div>\
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
return final_output_message
|
292 |
# for i in range(len(final_output_message)):
|
293 |
# time.sleep(0.1)
|
requirements.txt
CHANGED
@@ -9,6 +9,7 @@ click==8.1.7
|
|
9 |
colorama==0.4.6
|
10 |
contourpy==1.2.0
|
11 |
cycler==0.12.1
|
|
|
12 |
et-xmlfile==1.1.0
|
13 |
fastapi==0.110.0
|
14 |
ffmpy==0.3.2
|
@@ -70,6 +71,7 @@ transformers==4.39.1
|
|
70 |
typer==0.10.0
|
71 |
typing_extensions==4.10.0
|
72 |
tzdata==2024.1
|
|
|
73 |
urllib3==2.2.1
|
74 |
uvicorn==0.29.0
|
75 |
websockets==11.0.3
|
|
|
9 |
colorama==0.4.6
|
10 |
contourpy==1.2.0
|
11 |
cycler==0.12.1
|
12 |
+
dateparser==1.2.0
|
13 |
et-xmlfile==1.1.0
|
14 |
fastapi==0.110.0
|
15 |
ffmpy==0.3.2
|
|
|
71 |
typer==0.10.0
|
72 |
typing_extensions==4.10.0
|
73 |
tzdata==2024.1
|
74 |
+
tzlocal==5.2
|
75 |
urllib3==2.2.1
|
76 |
uvicorn==0.29.0
|
77 |
websockets==11.0.3
|