From db6c8bc884fa3efc0eb7f7d9dba816f97aac703b Mon Sep 17 00:00:00 2001 From: tbxark Date: Wed, 23 Oct 2024 10:37:11 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9GOOGLE=5FAPI=5FBASE?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E5=8F=98=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agent/gemini.ts | 2 +- src/config/config.ts | 12 +++++------- src/config/env.ts | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/agent/gemini.ts b/src/agent/gemini.ts index 4c01a068..c99240be 100644 --- a/src/agent/gemini.ts +++ b/src/agent/gemini.ts @@ -17,7 +17,7 @@ export class Gemini implements ChatAgent { readonly request = async (params: LLMChatParams, context: AgentUserConfig, onStream: ChatStreamTextHandler | null): Promise => { const provider = createGoogleGenerativeAI({ - baseURL: context.GOOGLE_BASE_URL, + baseURL: context.GOOGLE_API_BASE, apiKey: context.GOOGLE_API_KEY || undefined, }); const languageModelV1 = provider.languageModel(this.model(context), undefined); diff --git a/src/config/config.ts b/src/config/config.ts index b2bd45ad..2a92730f 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -20,7 +20,7 @@ export class EnvironmentConfig { // 图片尺寸偏移 0为第一位,-1为最后一位, 越靠后的图片越大。PS: 图片过大可能导致token消耗过多,或者workers超时或内存不足 // 默认选择次低质量的图片 TELEGRAM_PHOTO_SIZE_OFFSET = 1; - // 向LLM优先传递图片方式:url, base64 + // Deprecated: 向LLM优先传递图片方式:url, base64 TELEGRAM_IMAGE_TRANSFER_MODE = 'url'; // -- 权限相关 -- @@ -33,12 +33,10 @@ export class EnvironmentConfig { LOCK_USER_CONFIG_KEYS = [ // 默认为API BASE 防止被替换导致token 泄露 'OPENAI_API_BASE', - 'GOOGLE_COMPLETIONS_API', + 'GOOGLE_API_BASE', 'MISTRAL_API_BASE', 'COHERE_API_BASE', 'ANTHROPIC_API_BASE', - 'AZURE_COMPLETIONS_API', - 'AZURE_DALLE_API', ]; // -- 群组相关 -- @@ -92,7 +90,7 @@ export class AgentShareConfig { AI_IMAGE_PROVIDER = 'auto'; // 全局默认初始化消息 SYSTEM_INIT_MESSAGE: string | null = null; - // 全局默认初始化消息角色 + // Deprecated: 全局默认初始化消息 SYSTEM_INIT_MESSAGE_ROLE = 'system'; } @@ -104,7 +102,7 @@ export class OpenAIConfig { OPENAI_CHAT_MODEL = 'gpt-4o-mini'; // OpenAI API BASE `` OPENAI_API_BASE = 'https://api.openai.com/v1'; - // OpenAI API Extra Params + // Deprecated: OpenAI API Extra Params OPENAI_API_EXTRA_PARAMS: Record = {}; } @@ -151,7 +149,7 @@ export class GeminiConfig { // Google Gemini API Key GOOGLE_API_KEY: string | null = null; // Google Gemini API Base - GOOGLE_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'; + GOOGLE_API_BASE = 'https://generativelanguage.googleapis.com/v1beta'; // Google Gemini Model GOOGLE_COMPLETIONS_MODEL = 'gemini-pro'; } diff --git a/src/config/env.ts b/src/config/env.ts index 975ca622..50a83ded 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -174,8 +174,8 @@ class Environment extends EnvironmentConfig { } // 兼容旧版 GOOGLE_COMPLETIONS_API - if (source.GOOGLE_COMPLETIONS_API && !this.USER_CONFIG.GOOGLE_BASE_URL) { - this.USER_CONFIG.GOOGLE_BASE_URL = source.GOOGLE_COMPLETIONS_API.replace(/\/models\/?$/, ''); + if (source.GOOGLE_COMPLETIONS_API && !this.USER_CONFIG.GOOGLE_API_BASE) { + this.USER_CONFIG.GOOGLE_API_BASE = source.GOOGLE_COMPLETIONS_API.replace(/\/models\/?$/, ''); } // 兼容旧版 AZURE_COMPLETIONS_API if (source.AZURE_COMPLETIONS_API && !this.USER_CONFIG.AZURE_CHAT_MODEL) {