Merge branch 'dev' into hugo-shipping-notice
# Conflicts: # backend/app/services/maintenance_chat_service.py # backend/tests/test_maintenance_chat_service.py # frontend/src/features/chat/components/ChatViewContent.vue
This commit is contained in:
commit
2ce1aca023
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,
|
||||
)
|
||||
@@ -132,3 +134,28 @@ def test_resolve_context_device_works_for_custom_agent_name_with_intent_route(ap
|
||||
|
||||
assert keyword == 'A070700002'
|
||||
assert source == 'context'
|
||||
|
||||
|
||||
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