2026-07-28 02:12:46 +08:00
|
|
|
|
# ============================================================
|
|
|
|
|
|
# 多轮上下文:短确认 / 文件夹解析
|
|
|
|
|
|
# ============================================================
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
|
|
from server.agent_core.assistant import reply as assistant_reply
|
|
|
|
|
|
from server.agent_core.context import resolve_followup
|
|
|
|
|
|
from server.agent_core.intent import parse_fast
|
|
|
|
|
|
from server.state.seed import seed_world
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_affirm_yes_maps_to_schedule_hint():
|
|
|
|
|
|
hist = [
|
|
|
|
|
|
{"role": "user", "text": "帮我分析项目"},
|
|
|
|
|
|
{"role": "agent", "text": "看起来齐了。直接跟我说「直接排一版」。"},
|
|
|
|
|
|
]
|
|
|
|
|
|
r = resolve_followup("是的", hist)
|
|
|
|
|
|
assert r["kind"] == "affirm"
|
|
|
|
|
|
assert "排一版" in r["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_folder_intent_fast():
|
|
|
|
|
|
world = seed_world()
|
|
|
|
|
|
r = parse_fast("你给我解析文件夹里面的数据给我展现出来", world)
|
|
|
|
|
|
assert r is not None and r.intent == "folder.analyze"
|
|
|
|
|
|
r2 = parse_fast("以上数据根据排产你要怎么数据", world)
|
|
|
|
|
|
assert r2 is not None and r2.intent == "folder.schedule"
|
|
|
|
|
|
r3 = parse_fast("根据这些数据排产", world)
|
|
|
|
|
|
assert r3 is not None and r3.intent == "folder.schedule"
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-20 11:39:21 +08:00
|
|
|
|
def test_explicit_data_path_beats_knowledge_query():
|
|
|
|
|
|
world = seed_world()
|
|
|
|
|
|
text = (
|
|
|
|
|
|
'分析 "D:\\ItemSpace\\14.工业智核\\锐扬\\湖南锐扬MOM主数据收集表.xlsx",'
|
|
|
|
|
|
"解析后写入当前项目主数据和知识库"
|
|
|
|
|
|
)
|
|
|
|
|
|
result = parse_fast(text, world)
|
|
|
|
|
|
assert result is not None
|
|
|
|
|
|
assert result.intent == "data.analyze"
|
|
|
|
|
|
assert result.params["query"] == text
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-28 02:12:46 +08:00
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
|
async def test_folder_listing_reply_not_kimi_excuse():
|
|
|
|
|
|
world = seed_world()
|
|
|
|
|
|
reply = await assistant_reply(
|
|
|
|
|
|
world,
|
|
|
|
|
|
"你给我解析文件夹里面的数据给我展现出来",
|
|
|
|
|
|
history=[
|
|
|
|
|
|
{"role": "user", "text": "帮我分析一下当前项目里面的数据"},
|
|
|
|
|
|
{"role": "agent", "text": "手头有啥……"},
|
|
|
|
|
|
],
|
|
|
|
|
|
session_id="s1",
|
|
|
|
|
|
)
|
|
|
|
|
|
assert "Kimi" not in reply.text
|
|
|
|
|
|
assert "没配大模型" not in reply.text
|
|
|
|
|
|
assert "项目" in reply.text or "文件夹" in reply.text or "文件" in reply.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
|
async def test_yes_after_offer_not_echo_yes():
|
|
|
|
|
|
world = seed_world()
|
|
|
|
|
|
hist = [
|
|
|
|
|
|
{"role": "user", "text": "看看能不能排"},
|
|
|
|
|
|
{"role": "agent", "text": "齐了的话可以说「直接排一版」。"},
|
|
|
|
|
|
]
|
|
|
|
|
|
reply = await assistant_reply(world, "是的", history=hist, session_id="s1")
|
|
|
|
|
|
assert "你问的是「是的」" not in reply.text
|
|
|
|
|
|
assert "是的" not in reply.text[:20] or "明白" in reply.text or "排" in reply.text
|