Files
ailine/backend/app/agent_subgraphs/common/__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

95 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
公共工具模块
提供可复用的基础组件
导出:
- formatter.py: 格式化输出工具
- intent.py: 意图理解工具
- human_review.py: 人工审核工具
- state_base.py: 状态基类工具
"""
from .formatter import (
MarkdownFormatter,
TemplateManager,
OutputRenderer,
PresetTemplates
)
from .intent import (
# 旧版 API保持向后兼容
IntentType,
Intent,
Entity,
IntentParser,
RuleBasedIntentClassifier,
RuleBasedEntityExtractor,
IntentRegistry,
create_default_intent_parser,
# 新版 React 模式 API
ReasoningAction,
RetrievalConfig,
ReasoningResult,
BaseIntentReasoner,
RuleBasedReactReasoner,
LLMReactReasoner,
create_react_reasoner,
react_reason,
get_route_by_reasoning
)
from .human_review import (
ReviewStatus,
HumanReview,
HumanReviewStore,
InMemoryReviewStore,
HumanReviewNode,
ReviewManager
)
from .state_base import (
BaseState,
Phase,
TokenUsage,
StateUtils
)
__all__ = [
# formatter
"MarkdownFormatter",
"TemplateManager",
"OutputRenderer",
"PresetTemplates",
# intent - 旧版
"IntentType",
"Intent",
"Entity",
"IntentParser",
"RuleBasedIntentClassifier",
"RuleBasedEntityExtractor",
"IntentRegistry",
"create_default_intent_parser",
# intent - 新版 React 模式
"ReasoningAction",
"RetrievalConfig",
"ReasoningResult",
"BaseIntentReasoner",
"RuleBasedReactReasoner",
"LLMReactReasoner",
"create_react_reasoner",
"react_reason",
"get_route_by_reasoning",
# human_review
"ReviewStatus",
"HumanReview",
"HumanReviewStore",
"InMemoryReviewStore",
"HumanReviewNode",
"ReviewManager",
# state_base
"BaseState",
"Phase",
"TokenUsage",
"StateUtils"
]