refactor: 重命名文件更清晰,调整最大推理步数为10
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m49s
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m49s
- subgraph_builder.py → main_graph_builder.py - service.py → agent_service.py - 调整 max_steps 从 40 → 10 - 更新所有相关导入
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
AI Agent 应用模块
|
AI Agent 应用模块
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .agent.service import AIAgentService
|
from .agent.agent_service import AIAgentService
|
||||||
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS, TOOLS_BY_NAME
|
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS, TOOLS_BY_NAME
|
||||||
|
|
||||||
__all__ = ["AIAgentService", "AVAILABLE_TOOLS", "TOOLS_BY_NAME"]
|
__all__ = ["AIAgentService", "AVAILABLE_TOOLS", "TOOLS_BY_NAME"]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import json
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
# 本地模块
|
# 本地模块
|
||||||
from app.main_graph.utils.subgraph_builder import build_react_main_graph
|
from app.main_graph.utils.main_graph_builder import build_react_main_graph
|
||||||
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS, TOOLS_BY_NAME
|
from app.main_graph.tools.graph_tools import AVAILABLE_TOOLS, TOOLS_BY_NAME
|
||||||
from app.main_graph.config import set_stream_writer
|
from app.main_graph.config import set_stream_writer
|
||||||
from ..model_services.chat_services import get_all_chat_services, LocalVLLMChatProvider
|
from ..model_services.chat_services import get_all_chat_services, LocalVLLMChatProvider
|
||||||
@@ -15,7 +15,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
|
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
|
||||||
from .agent.service import AIAgentService
|
from .agent.agent_service import AIAgentService
|
||||||
from .agent.history import ThreadHistoryService
|
from .agent.history import ThreadHistoryService
|
||||||
from app.core.human_review import (
|
from app.core.human_review import (
|
||||||
ReviewManager,
|
ReviewManager,
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ def route_by_reasoning(state: MainGraphState) -> str:
|
|||||||
route = get_route_by_reasoning(reasoning_result)
|
route = get_route_by_reasoning(reasoning_result)
|
||||||
|
|
||||||
# 映射到我们的节点名称
|
# 映射到我们的节点名称
|
||||||
# 注意:这些名称必须与 subgraph_builder.py 中定义的节点名称一致
|
# 注意:这些名称必须与 main_graph_builder.py 中定义的节点名称一致
|
||||||
route_mapping = {
|
route_mapping = {
|
||||||
"direct_response": "final_response",
|
"direct_response": "final_response",
|
||||||
"retrieve_rag": "rag_retrieve",
|
"retrieve_rag": "rag_retrieve",
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class MainGraphState:
|
|||||||
|
|
||||||
# ========== React 推理专用字段 ==========
|
# ========== React 推理专用字段 ==========
|
||||||
reasoning_step: int = 0 # 当前推理步数
|
reasoning_step: int = 0 # 当前推理步数
|
||||||
max_steps: int = 40 # 最大推理步数(≤40)
|
max_steps: int = 10 # 最大推理步数(≤10)
|
||||||
last_action: str = "" # 上一步动作
|
last_action: str = "" # 上一步动作
|
||||||
reasoning_history: List[Dict[str, Any]] = field(default_factory=list) # 推理历史
|
reasoning_history: List[Dict[str, Any]] = field(default_factory=list) # 推理历史
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if str(PROJECT_ROOT) not in sys.path:
|
|||||||
|
|
||||||
load_dotenv(PROJECT_ROOT / ".env")
|
load_dotenv(PROJECT_ROOT / ".env")
|
||||||
|
|
||||||
from app.agent.service import AIAgentService
|
from app.agent.agent_service import AIAgentService
|
||||||
from app.config import DB_URI
|
from app.config import DB_URI
|
||||||
from app.main_graph.checkpoint.postgres.aio import AsyncPostgresSaver
|
from app.main_graph.checkpoint.postgres.aio import AsyncPostgresSaver
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ load_dotenv()
|
|||||||
|
|
||||||
from backend.app.config import DB_URI
|
from backend.app.config import DB_URI
|
||||||
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
|
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
|
||||||
from backend.app.agent.service import AIAgentService
|
from backend.app.agent.agent_service import AIAgentService
|
||||||
from backend.app.agent.history import ThreadHistoryService
|
from backend.app.agent.history import ThreadHistoryService
|
||||||
from backend.app.logger import info, warning, error
|
from backend.app.logger import info, warning, error
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user