refactor(server): scene 注册表骨架 + 统一门控管道设计文档
Phase 1 P1.1-P1.2:为后端门控收口提供声明式场景注册基础设施。 - 新建 scenes/ 目录:gate_rules(GateRule/SceneRoute 枚举)、scene_descriptor(SceneDescriptor dataclass)、scene_registry(SceneRegistry 单例) - 3 个场景迁入 descriptor:expense_application / reimbursement / query_travel_standard - __init__.py 的 bootstrap_scenes 在 import 时注册 + 运行时绑定 handler/builder/executor(解决循环 import) - 查询场景 priority=50 优先于 MODEL_ONLY 场景,确保规则匹配先于 LLM - 落地 UNIFIED_GATE_PIPELINE.md 架构文档:目标架构 / 验收标准(接入 O(1))/ 3 阶段迁移路径 - 76 passed,scene 注册表未破坏现有代码;与 intent_registry 暂时并存,P1.3-P1.8 会统一迁移
This commit is contained in:
38
server/src/app/services/scenes/gate_rules.py
Normal file
38
server/src/app/services/scenes/gate_rules.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class GateRule(str, Enum):
|
||||
"""门控规则:决定场景如何参与 gate_classify 的裁决。"""
|
||||
|
||||
OFF_TOPIC = "off_topic"
|
||||
"""非业务输入,走 off_topic_reply。"""
|
||||
|
||||
CHOICE = "choice"
|
||||
"""明确的业务选择,命中 signal_keywords 即生效。"""
|
||||
|
||||
AMBIGUOUS_FLOW = "ambiguous_flow"
|
||||
"""话术歧义,走候选流程确认。"""
|
||||
|
||||
MODEL_ONLY = "model_only"
|
||||
"""只走 LLM function call,不参与规则匹配(如申请/报销的复杂识别)。"""
|
||||
|
||||
|
||||
class SceneRoute(str, Enum):
|
||||
"""路由策略:gate_classify 裁决后决定走图的哪条边。"""
|
||||
|
||||
HANDLER_ONLY = "handler_only"
|
||||
"""不走 LLM,直接执行 handler(查询/命令类场景)。"""
|
||||
|
||||
MODEL_INTENT = "model_intent"
|
||||
"""走 LLM function call(申请/报销类场景)。"""
|
||||
|
||||
OFF_TOPIC = "off_topic"
|
||||
"""走 off_topic 回复。"""
|
||||
|
||||
RESUME = "resume"
|
||||
"""走确定性上下文恢复。"""
|
||||
|
||||
AMBIGUOUS = "ambiguous"
|
||||
"""走候选流程确认。"""
|
||||
Reference in New Issue
Block a user