Files
X-Financial/server/tests/test_application_fact_resolver.py
caoxiaozhu 5311c99d69 refactor(server): steward 决策链路改用 LangGraph 编排
- 新增 StewardGraphPlannerService,用 LangGraph 状态图编排意图识别→流程判断→模型/规则分支→兜底,替代原 planner 内线性调用
- 新增 StewardGraphRuntimeService 编排运行时决策与槽位决策;StewardActionContracts/Executor 统一动作合约与执行
- steward_intent_agent/application_fact_resolver/runtime_chat 适配图执行器,config 暴露图相关开关
- pyproject/uv.lock 新增 langgraph 依赖
- 新增 graph_planner/graph_runtime/action_executor 测试,更新 intent_agent/planner/fact_resolver/runtime_chat/reimbursement 测试
2026-06-24 21:58:35 +08:00

54 lines
2.0 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.
from __future__ import annotations
from datetime import date
from app.services.application_fact_resolver import (
ApplicationFactResolver,
resolve_application_facts,
)
def test_application_fact_resolver_extracts_travel_application_fields() -> None:
facts = resolve_application_facts(
"明天去上海出差3天辅助国网仿生产环境部署高铁往返",
"expense_application",
date(2026, 6, 23),
)
assert facts["expense_type"] == "travel"
assert facts["time_range"] == "2026-06-24"
assert facts["location"] == "上海"
assert facts["reason"] == "辅助国网仿生产环境部署,高铁往返"
assert facts["transport_mode"] == "train"
def test_application_fact_resolver_drops_transport_prompt_from_application_reason() -> None:
facts = resolve_application_facts(
"2026-02-20 至 2026-02-23去上海出差辅助国网仿生产服务器部署交通火车直接提交",
"expense_application",
date(2026, 6, 24),
)
assert facts["reason"] == "辅助国网仿生产服务器部署"
assert facts["transport_mode"] == "train"
def test_application_fact_resolver_preserves_reimbursement_transport_semantics() -> None:
facts = resolve_application_facts(
"报销昨天去北京客户现场沟通产生的出租车费用",
"reimbursement",
date(2026, 6, 23),
)
assert facts["expense_type"] == "transport"
assert facts["time_range"] == "2026-06-22"
assert facts["location"] == "北京"
assert facts["reason"] == "去北京客户现场沟通产生的出租车费用"
assert facts["transport_mode"] == "taxi"
def test_application_fact_resolver_keeps_static_wrapper_api() -> None:
assert ApplicationFactResolver.infer_expense_type("打车去客户现场", "expense_application") == "travel"
assert ApplicationFactResolver.infer_expense_type("打车去客户现场", "reimbursement") == "transport"
assert ApplicationFactResolver.extract_time_range("2026-07-01 去深圳", date(2026, 6, 23)) == "2026-07-01"