feat(provider): 添加独立的 Provider 模块管理模型提供商
实现可扩展的 Provider 系统,支持动态注册自定义提供商: Core 模块 (packages/core/src/provider/): - types.ts: Provider 相关类型定义 - builtin/: 内置提供商 (Anthropic, OpenAI, DeepSeek) - registry.ts: ProviderRegistry 单例类 - config.ts: 配置持久化 (~/.ai-terminal-assistant/providers.json) - utils.ts: 连接测试等工具函数 Server API (packages/server/src/routes/providers.ts): - GET/POST/PUT/DELETE /providers 提供商管理 - POST /providers/:id/test 连接测试 - 自定义模型管理接口 Frontend (packages/ui/): - ProvidersPanel 组件用于管理提供商 - API client 函数和类型定义 主要功能: - 支持动态注册 OpenAI 兼容服务 (Ollama, vLLM 等) - 每个提供商独立的 API Key 配置 - 预设模型列表 + 自定义模型输入 - 连接测试验证
This commit is contained in:
@@ -16,7 +16,7 @@ import type {
|
||||
ImageData,
|
||||
} from './types.js';
|
||||
import { checkBashPermission } from './permission-merger.js';
|
||||
import { getModelFactory } from '../core/providers.js';
|
||||
import { getProviderRegistry } from '../provider/index.js';
|
||||
|
||||
/**
|
||||
* Agent 执行器
|
||||
@@ -37,9 +37,10 @@ export class AgentExecutor {
|
||||
this.baseConfig = baseConfig;
|
||||
this.toolRegistry = toolRegistry;
|
||||
|
||||
// 获取模型工厂
|
||||
// 使用 ProviderRegistry 获取模型工厂
|
||||
const provider = agentInfo.model?.provider ?? baseConfig.provider;
|
||||
this.getModel = getModelFactory(provider, {
|
||||
const registry = getProviderRegistry();
|
||||
this.getModel = registry.getModelFactory(provider, {
|
||||
apiKey: baseConfig.apiKey,
|
||||
baseUrl: baseConfig.baseUrl,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user