From 432f4b709543a4a33eeb69bc2f78c211d4edde32 Mon Sep 17 00:00:00 2001 From: martsforever Date: Wed, 24 Sep 2025 16:59:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=89=E4=B8=AA=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=88=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/add_api_route.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/controller/add_api_route.py b/app/controller/add_api_route.py index 044af50..1de7969 100644 --- a/app/controller/add_api_route.py +++ b/app/controller/add_api_route.py @@ -22,8 +22,14 @@ def add_api_route(app: FastAPI): @app.get('/api/project/analysis') async def project_analysis(project_name=Query(..., description="项目名称")): tool_result_string = await tool_project_analysis.ainvoke({"project_name": project_name}) - tool_result_data = json.loads(tool_result_string) - return tool_result_data[0] + try: + tool_result_data = json.loads(tool_result_string) + result = tool_result_data[0] + except: + result = tool_result_string + return { + "result": result + } # 项目日报总结 @app.get('/api/project/report') @@ -37,9 +43,18 @@ def add_api_route(app: FastAPI): "start_time": start_time, "end_time": end_time, }) - return json.loads(tool_result_string) + try: + tool_result_data = json.loads(tool_result_string) + result = tool_result_data[0] + except: + result = tool_result_string + return { + "result": result + } # 检索企业内部文档工具 @app.get('/api/document/retrieve') async def document_retrieve(question=Query(..., description="用户的问题")): - return await tool_retrieve_documents.ainvoke({"question": question}) + return { + "result": await tool_retrieve_documents.ainvoke({"question": question}) + }