SiangKai commited on
Commit
2cc60c5
·
verified ·
1 Parent(s): e9cf619

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
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
- 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
 
 
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