丁云鹏 3 هفته پیش
والد
کامیت
242a7ec192
2فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 3 2
      agent.py
  2. 5 0
      agents/clean_agent/agent.py

+ 3 - 2
agent.py

@@ -21,7 +21,7 @@ from fastapi import FastAPI, HTTPException, BackgroundTasks
 from fastapi.responses import JSONResponse
 from pydantic import BaseModel, Field
 import uvicorn
-from agents.clean_agent.agent import execute_agent_with_api
+from agents.clean_agent.agent import execute_agent_with_api, execute
 from agents.expand_agent.agent import execute_expand_agent_with_api, _update_expansion_status
 
 # LangGraph 相关导入
@@ -731,7 +731,8 @@ async def extract(request: ExtractRequest):
         # 创建线程池任务执行Agent
         def _execute_extract_sync():
             try:
-                result = execute_agent_with_api(json.dumps({"query_word": query, "request_id": requestId}))
+                # result = execute_agent_with_api(json.dumps({"query_word": query, "request_id": requestId}))
+                result = execute(query, requestId)
                 # 更新状态为处理完成
                 update_extract_status(requestId, 2)
                 logger.info(f"异步提取任务完成: requestId={requestId}")

+ 5 - 0
agents/clean_agent/agent.py

@@ -5,6 +5,7 @@ from langgraph.graph.message import add_messages
 import os
 from langchain_openai import ChatOpenAI
 from .tools import evaluation_extraction_tool
+import uuid
 
 from langgraph.prebuilt import ToolNode, tools_condition
 from langgraph.checkpoint.memory import InMemorySaver
@@ -121,6 +122,10 @@ def execute_agent_with_api(user_input: str):
     except Exception as e:
         return f"执行Agent时出错: {str(e)}"
 
+def execute(query_word: str, request_id: str):
+    result = evaluation_extraction_tool(request_id, query_word)
+    return result
+
 def main():
     print(f"开始执行Agent")
     # 设置代理