refactor: 解耦 Provider Adapter 继承关系
问题:AgnesAdapter extends DeepSeekAdapter 在架构上不合理。 DeepSeek、Agnes AI、Ollama 是三个完全不同的 API,不应有继承关系。 重构: BaseAdapter ├── DeepSeekAdapter (独立) ├── AgnesAdapter (独立) └── OllamaAdapter (独立) 变更: - 新增 shared/openai-format.ts — 提取 OpenAI 兼容消息/工具格式构建 - 新增 shared/sse-stream.ts — 提取 SSE 流式解析逻辑 - DeepSeekAdapter 重写为独立继承 BaseAdapter,使用共享工具 - AgnesAdapter 重写为独立继承 BaseAdapter,使用共享工具 - OllamaAdapter 无需变更(原本就独立继承) - adapters/index.ts 清理导出,移除隐式耦合
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
/**
|
||||
* Provider Adapter 导出
|
||||
*
|
||||
* 三种 Provider 各自独立继承 BaseAdapter,无耦合关系:
|
||||
* - DeepSeekAdapter — OpenAI 兼容 + DeepSeek 特有参数
|
||||
* - AgnesAdapter — OpenAI 兼容 + Agnes 特有参数
|
||||
* - OllamaAdapter — Ollama 原生 API
|
||||
*
|
||||
* 共享工具(仅供 OpenAI 兼容 Adapter 使用):
|
||||
* - shared/openai-format — 消息/工具格式构建
|
||||
* - shared/sse-stream — SSE 流式解析
|
||||
*/
|
||||
|
||||
export { BaseAdapter } from './base-adapter';
|
||||
export { DeepSeekAdapter } from './deepseek.adapter';
|
||||
export { AgnesAdapter } from './agnes-ai.adapter';
|
||||
|
||||
Reference in New Issue
Block a user