feat: 报销预审会话状态管理与工作台交互增强

- 新增差旅报销会话状态管理与对话模型重构
- 增强风险观测服务与运行时聊天上下文作用域
- 优化工作台图标资源、助理意图识别与摘要工具
- 完善报销创建视图样式与差旅详情页标准调整交互
- 补充风险观测、运行时聊天与报销端点测试覆盖
This commit is contained in:
caoxiaozhu
2026-06-04 11:03:29 +08:00
parent 87da5df91b
commit 1cbf3fee44
60 changed files with 4156 additions and 393 deletions

View File

@@ -150,6 +150,62 @@ def test_runtime_chat_disables_glm_thinking_for_direct_user_answers(monkeypatch)
assert captured["timeout_seconds"] == 17
def test_runtime_chat_openai_compatible_tool_call_payload(monkeypatch) -> None:
_clear_runtime_chat_cooldown()
session_factory = build_session_factory()
with session_factory() as db:
service = RuntimeChatService(db)
captured: dict[str, object] = {}
def fake_send_json_request(method, url, *, headers, payload, timeout_seconds):
captured["method"] = method
captured["url"] = url
captured["headers"] = headers
captured["payload"] = payload
captured["timeout_seconds"] = timeout_seconds
return 200, {
"choices": [
{
"message": {
"tool_calls": [
{
"id": "call_001",
"type": "function",
"function": {
"name": "submit_steward_intent_plan",
"arguments": "{\"tasks\": []}",
},
}
]
}
}
]
}
monkeypatch.setattr("app.services.runtime_chat._send_json_request", fake_send_json_request)
tool_call = service._request_openai_compatible_tool_call(
provider="OpenAI Compatible",
endpoint="https://api.example.com/v1",
model="gpt-test",
api_key="secret",
messages=[{"role": "user", "content": "hello"}],
tools=[{"type": "function", "function": {"name": "submit_steward_intent_plan"}}],
tool_choice={"type": "function", "function": {"name": "submit_steward_intent_plan"}},
max_tokens=128,
temperature=0.1,
timeout_seconds=19,
)
assert tool_call is not None
assert tool_call.name == "submit_steward_intent_plan"
assert tool_call.arguments == {"tasks": []}
assert captured["url"] == "https://api.example.com/v1/chat/completions"
assert captured["payload"]["tools"][0]["function"]["name"] == "submit_steward_intent_plan"
assert captured["payload"]["tool_choice"]["function"]["name"] == "submit_steward_intent_plan"
assert captured["headers"]["Authorization"] == "Bearer secret"
def test_runtime_chat_supports_single_pass_fast_failover(monkeypatch) -> None:
_clear_runtime_chat_cooldown()
session_factory = build_session_factory()