Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -702,26 +702,26 @@ def gradio_interface(user_input):
|
|
| 702 |
table_name = table_map.get(sub_query)
|
| 703 |
params = params_map.get(sub_query)
|
| 704 |
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
|
| 726 |
combined_context = "\n\n".join(context_list)
|
| 727 |
|
|
|
|
| 702 |
table_name = table_map.get(sub_query)
|
| 703 |
params = params_map.get(sub_query)
|
| 704 |
|
| 705 |
+
if not table_name or not params:
|
| 706 |
+
context_list.append(f"【{sub_query}】\n查詢失敗:未能匹配到資料表或解析參數。")
|
| 707 |
+
continue
|
| 708 |
+
|
| 709 |
+
try:
|
| 710 |
+
# 帶著所有精準參數執行查詢
|
| 711 |
+
result_json = semantic_query_logic(
|
| 712 |
+
time_query=params.get("time_query", ""),
|
| 713 |
+
item_query=params.get("item_query", ""),
|
| 714 |
+
district_query=params.get("district_query", ""),
|
| 715 |
+
project_name=table_name
|
| 716 |
+
)
|
| 717 |
+
result_data = json.loads(result_json)
|
| 718 |
+
if result_data:
|
| 719 |
+
formatted_result = json.dumps(result_data, ensure_ascii=False, indent=2)
|
| 720 |
+
context_list.append(f"【{sub_query}】\n查詢結果:\n{formatted_result}")
|
| 721 |
+
else:
|
| 722 |
+
context_list.append(f"【{sub_query}】\n查無資料。")
|
| 723 |
+
except Exception as e:
|
| 724 |
+
context_list.append(f"【{sub_query}】\n查詢失敗:{e}")
|
| 725 |
|
| 726 |
combined_context = "\n\n".join(context_list)
|
| 727 |
|