refactor(backend): 后端重构初步设想
This commit is contained in:
1 parent
b69d549b2c
commit
21b8c24815
96 files changed
+1592
No files matched your search
@@ -0,0 +1,6 @@
|
||||
"""
|
||||
backend/app/services/chat/__init__.py
|
||||
|
||||
用途:聊天域业务服务包。
|
||||
逻辑:Wave 3 从 api/chat/_legacy 与 chat.py 意图路由抽取。
|
||||
"""
|
||||
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
backend/app/services/chat/log_service.py
|
||||
|
||||
用途:聊天历史、反馈业务逻辑。
|
||||
"""
|
||||
@@ -0,0 +1,6 @@
|
||||
"""
|
||||
backend/app/services/chat/perf.py
|
||||
|
||||
用途:聊天性能埋点(Wave 3 自 services/chat_perf.py 迁入)。
|
||||
"""
|
||||
from app.services.chat_perf import * # noqa: F403
|
||||
@@ -0,0 +1,6 @@
|
||||
"""
|
||||
backend/app/services/chat/preview_service.py
|
||||
|
||||
用途:PLM/Excel 预览与文件转换(从 api/chat 抽出)。
|
||||
逻辑:Wave 3 将 subprocess/openpyxl 逻辑迁入本模块。
|
||||
"""
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
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')
|
||||
@@ -0,0 +1,6 @@
|
||||
"""
|
||||
backend/app/services/chat/session_service.py
|
||||
|
||||
用途:聊天会话 CRUD 业务逻辑。
|
||||
逻辑:Wave 3 从 api/chat/_legacy 抽取 sessions 相关路由逻辑。
|
||||
"""
|
||||
Reference in new issue
Block a user