Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -468,12 +468,12 @@ def reflect_post(api_key, api_key2, user_input):
|
|
| 468 |
sub_query_texts = [q["sub_query"] for q in direct_queries]
|
| 469 |
|
| 470 |
# Step 2:批次匹配表名 (API Call #2)
|
| 471 |
-
table_map = batch_find_relevant_tables(
|
| 472 |
if not table_map:
|
| 473 |
return all_querys_summary, "⚠️ 系統無法為您的查詢匹配到合適的資料表。"
|
| 474 |
|
| 475 |
# Step 3: 批次解析所有子問題的參數 (API Call #3)
|
| 476 |
-
params_map = batch_parse_sub_queries_with_gemini(
|
| 477 |
if not params_map:
|
| 478 |
return all_querys_summary, "⚠️ 系統無法解析您問題中的查詢參數。"
|
| 479 |
|
|
@@ -509,7 +509,7 @@ def reflect_post(api_key, api_key2, user_input):
|
|
| 509 |
|
| 510 |
# Step 5:整合分析 (API Call #4)
|
| 511 |
integration_prompt = f"使用者問題:{user_input}\n\n查詢資料如下:\n{combined_context}"
|
| 512 |
-
integration_result = reply(
|
| 513 |
return all_querys_summary, integration_result
|
| 514 |
|
| 515 |
# =======================================================================
|
|
@@ -520,6 +520,9 @@ def gradio_interface(user_input):
|
|
| 520 |
"""Gradio 主要處理函式"""
|
| 521 |
api_key = os.getenv('Gemini')
|
| 522 |
api_key2 = os.getenv('Gemini2')
|
|
|
|
|
|
|
|
|
|
| 523 |
if not api_key:
|
| 524 |
return "❌ 查詢失敗", "錯誤:未在伺服器環境中設定 'Gemini' API 金鑰。"
|
| 525 |
|
|
|
|
| 468 |
sub_query_texts = [q["sub_query"] for q in direct_queries]
|
| 469 |
|
| 470 |
# Step 2:批次匹配表名 (API Call #2)
|
| 471 |
+
table_map = batch_find_relevant_tables(api_key2, sub_query_texts)
|
| 472 |
if not table_map:
|
| 473 |
return all_querys_summary, "⚠️ 系統無法為您的查詢匹配到合適的資料表。"
|
| 474 |
|
| 475 |
# Step 3: 批次解析所有子問題的參數 (API Call #3)
|
| 476 |
+
params_map = batch_parse_sub_queries_with_gemini(api_key3, sub_query_texts)
|
| 477 |
if not params_map:
|
| 478 |
return all_querys_summary, "⚠️ 系統無法解析您問題中的查詢參數。"
|
| 479 |
|
|
|
|
| 509 |
|
| 510 |
# Step 5:整合分析 (API Call #4)
|
| 511 |
integration_prompt = f"使用者問題:{user_input}\n\n查詢資料如下:\n{combined_context}"
|
| 512 |
+
integration_result = reply(api_key4, system_integration, integration_prompt)
|
| 513 |
return all_querys_summary, integration_result
|
| 514 |
|
| 515 |
# =======================================================================
|
|
|
|
| 520 |
"""Gradio 主要處理函式"""
|
| 521 |
api_key = os.getenv('Gemini')
|
| 522 |
api_key2 = os.getenv('Gemini2')
|
| 523 |
+
api_key3 = os.getenv('Gemini3')
|
| 524 |
+
api_key4 = os.getenv('Gemini4')
|
| 525 |
+
|
| 526 |
if not api_key:
|
| 527 |
return "❌ 查詢失敗", "錯誤:未在伺服器環境中設定 'Gemini' API 金鑰。"
|
| 528 |
|