Prechádzať zdrojové kódy

修改ask_agent()的返回结果的json,用records代替query_result.

wangxq 1 týždeň pred
rodič
commit
51cf1f2808
2 zmenil súbory, kde vykonal 5 pridanie a 5 odobranie
  1. 3 3
      agent/citu_agent.py
  2. 2 2
      citu_app.py

+ 3 - 3
agent/citu_agent.py

@@ -656,7 +656,7 @@ class CituLangGraphAgent:
                         "response": state["chat_response"],
                         "type": "DATABASE",
                         "sql": state.get("sql"),
-                        "query_result": state.get("query_result"),  # 获取query_result字段
+                        "query_result": state.get("query_result"),  # 保持内部字段名不变
                         "execution_path": state["execution_path"],
                         "classification_info": {
                             "confidence": state["classification_confidence"],
@@ -672,7 +672,7 @@ class CituLangGraphAgent:
                         "type": "DATABASE",
                         "response": state["summary"],  # 新增:将summary的值赋给response
                         "sql": state.get("sql"),
-                        "query_result": state.get("query_result"),  # 获取query_result字段
+                        "query_result": state.get("query_result"),  # 保持内部字段名不变
                         "summary": state["summary"],  # 暂时保留summary字段
                         "execution_path": state["execution_path"],
                         "classification_info": {
@@ -692,7 +692,7 @@ class CituLangGraphAgent:
                         "success": True,
                         "type": "DATABASE",
                         "sql": state.get("sql"),
-                        "query_result": query_result,  # 获取query_result字段
+                        "query_result": query_result,  # 保持内部字段名不变
                         "execution_path": state["execution_path"],
                         "classification_info": {
                             "confidence": state["classification_confidence"],

+ 2 - 2
citu_app.py

@@ -546,7 +546,7 @@ def ask_agent():
                 response_type=cached_answer.get("type", "UNKNOWN"),
                 response=cached_answer.get("response", ""),  # 修正:使用response而不是response_text
                 sql=cached_answer.get("sql"),
-                query_result=cached_answer.get("query_result"),
+                records=cached_answer.get("query_result"),  # 修改:query_result改为records
                 summary=cached_answer.get("summary"),
                 session_id=browser_session_id,
                 execution_path=cached_answer.get("execution_path", []),
@@ -656,7 +656,7 @@ def ask_agent():
                 response_type=response_type,
                 response=response_text,  # 修正:使用response而不是response_text
                 sql=sql,
-                query_result=query_result,
+                records=query_result,  # 修改:query_result改为records
                 summary=summary,
                 session_id=browser_session_id,
                 execution_path=execution_path,