Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -293,23 +293,25 @@ async def process_query(query: str,
|
|
| 293 |
if match:
|
| 294 |
waybill_number = match.group(0)
|
| 295 |
print(waybill_number)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
else:
|
| 297 |
print("Waybill number not correct.")
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
-
# Fetch order ID and order details
|
| 301 |
-
try:
|
| 302 |
-
order_id = get_order_id(waybill_number)
|
| 303 |
-
full_data = await get_all_order_data(order_id)
|
| 304 |
-
except Exception as e:
|
| 305 |
-
return {"error": str(e)}
|
| 306 |
-
|
| 307 |
-
# Generate final response based on collected data
|
| 308 |
-
response_message = [
|
| 309 |
-
{"role": "system", "content": "You are a helpful assistant for Curfox delivery system."},
|
| 310 |
-
{"role": "user", "content": f"Answer based on the provided data only. Data: {full_data}. User query: {query}"}
|
| 311 |
-
]
|
| 312 |
-
result = ask_openai(response_message)
|
| 313 |
|
| 314 |
if thread_id==None:
|
| 315 |
return {"meta_data":insert_newchat(user_name,query,result),"answer": result}
|
|
|
|
| 293 |
if match:
|
| 294 |
waybill_number = match.group(0)
|
| 295 |
print(waybill_number)
|
| 296 |
+
# Fetch order ID and order details
|
| 297 |
+
try:
|
| 298 |
+
order_id = get_order_id(waybill_number)
|
| 299 |
+
full_data = await get_all_order_data(order_id)
|
| 300 |
+
# Generate final response based on collected data
|
| 301 |
+
response_message = [
|
| 302 |
+
{"role": "system", "content": "You are a helpful assistant for Curfox delivery system."},
|
| 303 |
+
{"role": "user", "content": f"Answer based on the provided data only. Data: {full_data}. User query: {query}"}
|
| 304 |
+
]
|
| 305 |
+
result = ask_openai(response_message)
|
| 306 |
+
except Exception as e:
|
| 307 |
+
result = str(e)
|
| 308 |
else:
|
| 309 |
print("Waybill number not correct.")
|
| 310 |
+
result = "Waybill number not correct."
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
if thread_id==None:
|
| 317 |
return {"meta_data":insert_newchat(user_name,query,result),"answer": result}
|