feat(equipment-mainetance): 设备维保助手优化
This commit is contained in:
1 parent
9ea49d7060
commit
fa965dd45b
25 files changed
+1609
-304
No files matched your search
@@ -10,6 +10,8 @@ from app import db
|
||||
from app.models import Agent, ChatLog, MaintenanceDevice, User
|
||||
from app.services.maintenance_chat_service import (
|
||||
MAINTENANCE_MESSAGE_TYPE,
|
||||
MAINTENANCE_MANAGEMENT_REDIRECT_MESSAGE,
|
||||
detect_management_write_intent,
|
||||
resolve_device_query_keyword,
|
||||
try_stream_chat,
|
||||
)
|
||||
@@ -95,3 +97,28 @@ def test_try_stream_chat_bypasses_dify_only_when_local_query_matches(app):
|
||||
# 关键断言:本地真实命中才接管;本地查不到时返回 None,交由 chat.py 后续 Dify 分支处理。
|
||||
assert local_stream is not None
|
||||
assert dify_fallback is None
|
||||
|
||||
|
||||
def test_detect_management_write_intent(app):
|
||||
"""断言新增、导入等写入意图会被识别,纯查询语句不会误判。"""
|
||||
assert detect_management_write_intent('新增设备 A070700001') is True
|
||||
assert detect_management_write_intent('导入设备台账 Excel') is True
|
||||
assert detect_management_write_intent('A070700001 的维修记录') is False
|
||||
assert detect_management_write_intent('查询 A070700001 最近维修记录') is False
|
||||
|
||||
|
||||
def test_try_stream_chat_redirects_management_write_intent(app):
|
||||
"""断言管理写入类问题由本地返回引导文案,不再交给 Dify。"""
|
||||
user, agent = _create_user_and_agent()
|
||||
|
||||
redirect_stream = try_stream_chat(
|
||||
'新增一条维修记录,设备 A070700001,线断了',
|
||||
user,
|
||||
agent,
|
||||
session_id='session-maintenance-3',
|
||||
request_id='req-redirect',
|
||||
)
|
||||
|
||||
assert redirect_stream is not None
|
||||
frames = list(redirect_stream)
|
||||
assert any(MAINTENANCE_MANAGEMENT_REDIRECT_MESSAGE in frame for frame in frames)
|
||||
Reference in new issue
Block a user