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 会统一迁移
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from app.services.scenes.gate_rules import GateRule, SceneRoute
|
|
from app.services.scenes.scene_descriptor import SceneDescriptor
|
|
from app.services.scenes.scene_registry import register_scene
|
|
|
|
|
|
def register() -> None:
|
|
register_scene(
|
|
SceneDescriptor(
|
|
scene_id="expense_application",
|
|
label="费用申请",
|
|
assigned_agent="application_assistant",
|
|
signal_keywords=(
|
|
"申请", "出差", "差旅", "费用", "交通", "住宿", "采购", "会务", "会议",
|
|
"客户现场", "项目", "拜访", "调研", "驻场", "上线", "验收",
|
|
),
|
|
ontology_fields=(), # 沿用全局 BUSINESS_CANONICAL_FIELDS,运行时 fallback
|
|
gate=GateRule.MODEL_ONLY,
|
|
route=SceneRoute.MODEL_INTENT,
|
|
handler=None,
|
|
action_steps_builder=None, # 运行时从 StewardActionPlanBuilder 取
|
|
can_resume=True,
|
|
flow_id="travel_application",
|
|
side_effect_actions=("save_application_draft", "submit_application", "run_duplicate_precheck"),
|
|
noop_actions=(
|
|
"fill_application_fields",
|
|
"build_application_preview",
|
|
"validate_required_fields",
|
|
),
|
|
executor=None, # 运行时从 StewardActionExecutor 取
|
|
prompt_fragment=(
|
|
"用户描述未来出差、差旅计划、去某地几天、部署、支撑、拜访或会议安排时,"
|
|
"即使没有出现“申请”两个字,也必须优先识别为 expense_application。"
|
|
),
|
|
priority=100,
|
|
)
|
|
)
|