docs: 品牌全量口径统一为「南方基金」+ 作废文档清理
1) 客服 Agent 四份交付文档 + 构建脚手架:品牌由包装占位 XX科技 / 旧名 南方财富 统一为南方基金(热线 400-889-8899 / 官网 nffund.com),系统名改为「智能服务系统」; 同步追加 §0.4 修订记录行,工程记录行保留原占位字面以支撑硬编码扫描验收。 2) 开发文档:清理 28 份已作废/残留文档(14 份移出归档 + 14 份仓库副本), 新增《文档规整方案与开发前待决事项-2026-09-17》。 3) 客服agent 四份交付文档首次纳入本分支。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import pytest
|
||||
|
||||
from app.core.errors import RecoverableAgentError, ValidationAgentError
|
||||
from app.service.intent_classifier import IntentClassifier
|
||||
from app.service.model_gateway import ModelExecution
|
||||
|
||||
|
||||
class StubModel:
|
||||
def __init__(self, text: str) -> None:
|
||||
self.text = text
|
||||
|
||||
async def generate(self, _endpoints: list[object], _prompt: str) -> ModelExecution:
|
||||
return ModelExecution("intent", self.text, 1)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_classifies_and_marks_low_confidence() -> None:
|
||||
classifier = IntentClassifier(StubModel('{"intent":"profile","confidence":0.4}'), threshold=0.6)
|
||||
result = await classifier.classify(
|
||||
message="我的资料", supported_intents=("profile", "general"), endpoints=[object()]
|
||||
)
|
||||
assert result.intent == "profile"
|
||||
assert result.needs_clarification is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_fenced_json_is_supported() -> None:
|
||||
classifier = IntentClassifier(StubModel(
|
||||
"```json\n{\"intent\":\"general\",\"confidence\":1}\n```"
|
||||
))
|
||||
result = await classifier.classify(
|
||||
message="你好", supported_intents=("general",), endpoints=[object()]
|
||||
)
|
||||
assert result.needs_clarification is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_unknown_intent_and_invalid_json_fail_closed() -> None:
|
||||
with pytest.raises(ValidationAgentError):
|
||||
await IntentClassifier(StubModel('{"intent":"trade","confidence":1}')).classify(
|
||||
message="下单", supported_intents=("general",), endpoints=[object()]
|
||||
)
|
||||
with pytest.raises(RecoverableAgentError):
|
||||
await IntentClassifier(StubModel("not-json")).classify(
|
||||
message="你好", supported_intents=("general",), endpoints=[object()]
|
||||
)
|
||||
Reference in New Issue
Block a user