diff --git a/src/agent/cohere.ts b/src/agent/cohere.ts index abac8060..855b5647 100644 --- a/src/agent/cohere.ts +++ b/src/agent/cohere.ts @@ -7,11 +7,6 @@ export class Cohere implements ChatAgent { readonly name = 'cohere'; readonly modelKey = 'COHERE_CHAT_MODEL'; - static COHERE_ROLE_MAP: Record = { - assistant: 'CHATBOT', - user: 'USER', - }; - readonly enable = (context: AgentUserConfig): boolean => { return !!(context.COHERE_API_KEY); }; diff --git a/src/agent/gemini.ts b/src/agent/gemini.ts index c99240be..0762b819 100644 --- a/src/agent/gemini.ts +++ b/src/agent/gemini.ts @@ -12,7 +12,7 @@ export class Gemini implements ChatAgent { }; readonly model = (ctx: AgentUserConfig): string => { - return ctx.GOOGLE_COMPLETIONS_MODEL; + return ctx.GOOGLE_CHAT_MODEL; }; readonly request = async (params: LLMChatParams, context: AgentUserConfig, onStream: ChatStreamTextHandler | null): Promise => { diff --git a/src/agent/types.ts b/src/agent/types.ts index 7bfddc18..caf98203 100644 --- a/src/agent/types.ts +++ b/src/agent/types.ts @@ -22,21 +22,16 @@ export interface LLMChatParams { export type ResponseMessage = CoreAssistantMessage | CoreToolMessage; export type ChatAgentRequest = (params: LLMChatParams, context: AgentUserConfig, onStream: ChatStreamTextHandler | null) => Promise; +export type ImageAgentRequest = (prompt: string, context: AgentUserConfig) => Promise; -export interface ChatAgent { +export interface Agent { name: string; modelKey: string; enable: (context: AgentUserConfig) => boolean; - request: ChatAgentRequest; + request: AgentRequest; model: (ctx: AgentUserConfig) => string; } -export type ImageAgentRequest = (prompt: string, context: AgentUserConfig) => Promise; +export type ChatAgent = Agent; -export interface ImageAgent { - name: string; - modelKey: string; - enable: (context: AgentUserConfig) => boolean; - request: ImageAgentRequest; - model: (ctx: AgentUserConfig) => string; -} +export type ImageAgent = Agent; diff --git a/src/config/config.ts b/src/config/config.ts index 2a92730f..fdb47bed 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -151,7 +151,7 @@ export class GeminiConfig { // Google Gemini API Base GOOGLE_API_BASE = 'https://generativelanguage.googleapis.com/v1beta'; // Google Gemini Model - GOOGLE_COMPLETIONS_MODEL = 'gemini-pro'; + GOOGLE_CHAT_MODEL = 'gemini-pro'; } // -- Mistral 配置 -- diff --git a/src/config/env.ts b/src/config/env.ts index 50a83ded..b6dd8ff1 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -177,6 +177,11 @@ class Environment extends EnvironmentConfig { if (source.GOOGLE_COMPLETIONS_API && !this.USER_CONFIG.GOOGLE_API_BASE) { this.USER_CONFIG.GOOGLE_API_BASE = source.GOOGLE_COMPLETIONS_API.replace(/\/models\/?$/, ''); } + + if (source.GOOGLE_COMPLETIONS_MODEL && !this.USER_CONFIG.GOOGLE_CHAT_MODEL) { + this.USER_CONFIG.GOOGLE_CHAT_MODEL = source.GOOGLE_COMPLETIONS_MODEL; + } + // 兼容旧版 AZURE_COMPLETIONS_API if (source.AZURE_COMPLETIONS_API && !this.USER_CONFIG.AZURE_CHAT_MODEL) { const url = new URL(source.AZURE_COMPLETIONS_API);