Skip to content

Commit

Permalink
chore: 修改GOOGLE_API_BASE 配置变量名
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Oct 23, 2024
1 parent 146d416 commit db6c8bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/agent/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Gemini implements ChatAgent {

readonly request = async (params: LLMChatParams, context: AgentUserConfig, onStream: ChatStreamTextHandler | null): Promise<ResponseMessage[]> => {
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);
Expand Down
12 changes: 5 additions & 7 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

// -- 权限相关 --
Expand All @@ -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',
];

// -- 群组相关 --
Expand Down Expand Up @@ -92,7 +90,7 @@ export class AgentShareConfig {
AI_IMAGE_PROVIDER = 'auto';
// 全局默认初始化消息
SYSTEM_INIT_MESSAGE: string | null = null;
// 全局默认初始化消息角色
// Deprecated: 全局默认初始化消息
SYSTEM_INIT_MESSAGE_ROLE = 'system';
}

Expand All @@ -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<string, any> = {};
}

Expand Down Expand Up @@ -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';
}
Expand Down
4 changes: 2 additions & 2 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit db6c8bc

Please sign in to comment.