28 lines
949 B
Python
28 lines
949 B
Python
"""
|
|
backend/app/services/chat/router.py
|
|
|
|
用途:Chat Intent Router,按意图分流至 PLM/HR/Text2SQL/Dify。
|
|
依赖:integrations/* stream_chat 实现。
|
|
逻辑:api/chat/completions 调用本模块 select_stream_generator。
|
|
设计参考:docs/tec.md §4.1 Chat Intent Router。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Iterator
|
|
|
|
|
|
def select_stream_generator(*, user: Any, agent: Any, query: str, **kwargs: Any) -> Iterator[str]:
|
|
"""
|
|
根据 agent 配置与用户问题选择流式 generator。
|
|
核心逻辑:Wave 3 从 api/chat.py /completions 分支迁入。
|
|
Args:
|
|
user: 当前 User 模型实例。
|
|
agent: 当前 Agent 模型实例。
|
|
query: 用户问题文本。
|
|
Returns:
|
|
SSE 事件字符串迭代器。
|
|
Raises:
|
|
NotImplementedError: Wave 0 占位。
|
|
"""
|
|
raise NotImplementedError('ChatIntentRouter pending Wave 3 migration from api/chat.py')
|