feat: add Nailong Fund advisor capabilities
This commit is contained in:
@@ -31,15 +31,21 @@ class IntentClassifier:
|
||||
self.threshold = threshold
|
||||
|
||||
async def classify(
|
||||
self, *, message: str, supported_intents: tuple[str, ...], endpoints: list[Any]
|
||||
self, *, message: str, supported_intents: tuple[str, ...], endpoints: list[Any],
|
||||
intent_descriptions: dict[str, str] | None = None,
|
||||
) -> IntentResult:
|
||||
if not message.strip():
|
||||
raise ValidationAgentError("待分类消息不能为空")
|
||||
if not supported_intents:
|
||||
raise ValidationAgentError("Agent 未声明支持的意图")
|
||||
descriptions = intent_descriptions or {}
|
||||
intent_options = "\n".join(
|
||||
f"- {intent}: {descriptions.get(intent, intent)}" for intent in supported_intents
|
||||
)
|
||||
prompt = (
|
||||
"请仅输出 JSON,不要 Markdown。字段必须为 intent 和 confidence。"
|
||||
f"intent 只能从 {list(supported_intents)!r} 中选择,confidence 为 0 到 1 的数字。"
|
||||
"intent 只能从以下候选项中选择,confidence 为 0 到 1 的数字:\n"
|
||||
f"{intent_options}\n"
|
||||
f"用户消息:{message}"
|
||||
)
|
||||
execution = await self.model_service.generate(endpoints, prompt)
|
||||
|
||||
Reference in New Issue
Block a user