All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 12m9s
## 核心改动 ### 1. 单图方案重构 - 删除了多图(self.graphs),改为单图(self.graph) - 新增 MainGraphState.current_model 字段用于运行时注入模型 - llm_call 节点改为动态选择模型(create_dynamic_llm_call_node) ### 2. chat_services 优化 - 添加 _cached_services 缓存,避免重复初始化 - 新增 get_cached_chat_services() 函数,用于单图注入 - 新增 _check_http_service_available() 统一HTTP探测逻辑 - 减少重复代码,LocalVLLMChatProvider和LocalSmallModelProvider共用探测方法 ### 3. AIAgentService 重构 - initialize() 只构建一次图,传入 chat_services 字典 - 新增 _resolve_model() 模型回退逻辑 - 新增 _build_invocation() 统一构建调用参数 - process_message() 和 process_message_stream() 改为注入 current_model - 流式处理代码拆分,增加可读性 ### 4. 新增和删除文件 - 新增:backend/app/main_graph/main_graph_builder.py(图构建) - 新增:backend/app/main_graph/subgraph_wrapper.py(子图封装) - 新增:tools/test/test_tavily_search.py(测试) - 删除:backend/app/main_graph/graph.py(旧图) - 删除:backend/app/main_graph/utils/main_graph_builder.py(旧构建器) - 删除:backend/app/main_graph/utils/__init__.py ### 5. 其他更新 - README.md:新增模型服务使用情况详解章节 - backend/app/model_services/__init__.py:新增 get_cached_chat_services 导出 ## 方案优势 - 内存优化:N张图 → 1张图 - 灵活性:运行时动态选择模型,支持同会话不同模型 - 性能:模型服务缓存,初始化仅一次 - 可维护性:减少重复代码,统一HTTP探测逻辑
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
"""
|
|
主图节点模块导出
|
|
"""
|
|
|
|
# React 模式节点
|
|
from .reasoning import react_reason_node
|
|
from .web_search import web_search_node
|
|
from .error_handling import error_handling_node
|
|
from .routing import init_state_node, route_by_reasoning, should_summarize
|
|
from .llm_call import create_dynamic_llm_call_node
|
|
from .rag_nodes import rag_retrieve_node, rag_re_retrieve_node
|
|
|
|
# 记忆节点
|
|
from .retrieve_memory import create_retrieve_memory_node
|
|
from .memory_trigger import memory_trigger_node, set_mem0_client
|
|
from .summarize import create_summarize_node
|
|
from .finalize import finalize_node
|
|
|
|
# 混合路由节点
|
|
from .hybrid_router import (
|
|
hybrid_router_node,
|
|
route_from_hybrid_decision,
|
|
check_fast_path_success,
|
|
)
|
|
from .fast_paths import (
|
|
fast_chitchat_node,
|
|
fast_rag_node,
|
|
fast_tool_node,
|
|
)
|
|
|
|
# 通用工具
|
|
from ._utils import dispatch_custom_event, make_react_event
|
|
|
|
__all__ = [
|
|
# React 模式节点
|
|
"init_state_node",
|
|
"react_reason_node",
|
|
"web_search_node",
|
|
"error_handling_node",
|
|
"route_by_reasoning",
|
|
"should_summarize",
|
|
"create_dynamic_llm_call_node",
|
|
"rag_retrieve_node",
|
|
"rag_re_retrieve_node",
|
|
# 记忆节点
|
|
"create_retrieve_memory_node",
|
|
"memory_trigger_node",
|
|
"set_mem0_client",
|
|
"create_summarize_node",
|
|
"finalize_node",
|
|
# 混合路由节点
|
|
"hybrid_router_node",
|
|
"route_from_hybrid_decision",
|
|
"check_fast_path_success",
|
|
"fast_chitchat_node",
|
|
"fast_rag_node",
|
|
"fast_tool_node",
|
|
# 通用工具
|
|
"dispatch_custom_event",
|
|
"make_react_event",
|
|
]
|