Files
ailine/backend/app/graph/__init__.py
root e3adb45454
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m15s
feat: 实现 React 模式循环推理,带超时重试和结构化错误处理
- 更新 intent.py 为 React 模式推理器
- 新增 react_nodes.py: React 模式节点
- 新增 retry_utils.py: 超时和重试工具
- 更新 state.py: 支持循环步数和错误记录
- 重写 subgraph_builder.py: 完整 React 循环流程
- 结构化错误输出,符合 Agent 执行循环最佳实践
- 限制最大推理步数 ≤40,防止无限循环
- RAG 检索带重试和超时保护
- 子图错误可传递给主图处理
2026-04-26 11:14:04 +08:00

64 lines
1.3 KiB
Python

"""
Graph 子模块 - React 模式增强版(带超时重试)
"""
from .graph_builder import GraphBuilder
from .subgraph_builder import build_main_graph, build_react_main_graph
from .react_nodes import (
init_state_node,
react_reason_node,
rag_retrieve_node,
error_handling_node,
final_response_node,
route_by_reasoning
)
from .state import (
MessagesState,
GraphContext,
MainGraphState,
CurrentAction,
ErrorRecord,
ErrorSeverity
)
from .retry_utils import (
RetryConfig,
RetryResult,
RetryStrategy,
with_retry,
with_async_retry,
create_retry_wrapper_for_node,
RAG_RETRY_CONFIG,
SUBGRAPH_RETRY_CONFIG
)
__all__ = [
# 旧版兼容性
"GraphBuilder",
"build_main_graph",
"MessagesState",
"GraphContext",
"MainGraphState",
"CurrentAction",
# 新版 React 模式
"build_react_main_graph",
"init_state_node",
"react_reason_node",
"rag_retrieve_node",
"error_handling_node",
"final_response_node",
"route_by_reasoning",
"ErrorRecord",
"ErrorSeverity",
# 超时和重试工具
"RetryConfig",
"RetryResult",
"RetryStrategy",
"with_retry",
"with_async_retry",
"create_retry_wrapper_for_node",
"RAG_RETRY_CONFIG",
"SUBGRAPH_RETRY_CONFIG"
]