From 4630dab88cb245f3eabdb626dca981f1630a2bc8 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 09:52:04 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20Gitee=20model=20p?= =?UTF-8?q?rovider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/llm/ProviderList/providers.tsx | 2 + src/config/llm.ts | 6 + src/config/modelProviders/gitee.ts | 63 +++++ src/config/modelProviders/index.ts | 4 + src/libs/agent-runtime/AgentRuntime.ts | 7 + src/libs/agent-runtime/gitee/index.test.ts | 255 ++++++++++++++++++ src/libs/agent-runtime/gitee/index.ts | 10 + .../__snapshots__/index.test.ts.snap | 2 +- src/libs/agent-runtime/types/type.ts | 1 + src/server/modules/AgentRuntime/index.ts | 7 + src/types/user/settings/keyVaults.ts | 1 + 11 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 src/config/modelProviders/gitee.ts create mode 100644 src/libs/agent-runtime/gitee/index.test.ts create mode 100644 src/libs/agent-runtime/gitee/index.ts diff --git a/src/app/(main)/settings/llm/ProviderList/providers.tsx b/src/app/(main)/settings/llm/ProviderList/providers.tsx index d67e56fa1242..51a8f6acb229 100644 --- a/src/app/(main)/settings/llm/ProviderList/providers.tsx +++ b/src/app/(main)/settings/llm/ProviderList/providers.tsx @@ -7,6 +7,7 @@ import { BaichuanProviderCard, DeepSeekProviderCard, FireworksAIProviderCard, + GiteeProviderCard, GoogleProviderCard, GroqProviderCard, HunyuanProviderCard, @@ -86,6 +87,7 @@ export const useProviderList = (): ProviderItem[] => { Ai360ProviderCard, TaichuProviderCard, SiliconCloudProviderCard, + GiteeProviderCard, ], [ AzureProvider, diff --git a/src/config/llm.ts b/src/config/llm.ts index 0d34d4f8da1d..8713caef478a 100644 --- a/src/config/llm.ts +++ b/src/config/llm.ts @@ -102,6 +102,9 @@ export const getLLMConfig = () => { SILICONCLOUD_API_KEY: z.string().optional(), SILICONCLOUD_PROXY_URL: z.string().optional(), + ENABLED_GITEE: z.boolean(), + GITEE_API_KEY: z.string().optional(), + ENABLED_UPSTAGE: z.boolean(), UPSTAGE_API_KEY: z.string().optional(), @@ -224,6 +227,9 @@ export const getLLMConfig = () => { SILICONCLOUD_API_KEY: process.env.SILICONCLOUD_API_KEY, SILICONCLOUD_PROXY_URL: process.env.SILICONCLOUD_PROXY_URL, + ENABLED_GITEE: !!process.env.GITEE_API_KEY, + GITEE_API_KEY: process.env.GITEE_API_KEY, + ENABLED_UPSTAGE: !!process.env.UPSTAGE_API_KEY, UPSTAGE_API_KEY: process.env.UPSTAGE_API_KEY, diff --git a/src/config/modelProviders/gitee.ts b/src/config/modelProviders/gitee.ts new file mode 100644 index 000000000000..02b35ffc8e33 --- /dev/null +++ b/src/config/modelProviders/gitee.ts @@ -0,0 +1,63 @@ +import { ModelProviderCard } from '@/types/llm'; + +const Gitee: ModelProviderCard = { + chatModels: [ + { + description: 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', + displayName: 'Qwen2.5 72B Instruct', + enabled: true, + id: 'Qwen2.5-72B-Instruct' + }, + { + description: 'Qwen2 是 Qwen 模型的最新系列,支持 128k 上下文,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', + displayName: 'Qwen2 72B Instruct', + id: 'Qwen2-72B-Instruct' + }, + { + description: 'Qwen2 是 Qwen 模型的最新系列,能够超越同等规模的最优开源模型甚至更大规模的模型,Qwen2 7B 在多个评测上取得显著的优势,尤其是代码及中文理解上。', + displayName: 'Qwen2 7B Instruct', + id: 'Qwen2-7B-Instruct' + }, + { + description: 'GLM-4-9B-Chat 在语义、数学、推理、代码和知识等多方面均表现出较高性能。还具备网页浏览、代码执行、自定义工具调用和长文本推理。 支持包括日语,韩语,德语在内的 26 种语言。', + displayName: 'GLM4 9B Chat', + enabled: true, + id: 'glm-4-9b-chat' + }, + { + description: 'Yi-1.5-34B 在保持原系列模型优秀的通用语言能力的前提下,通过增量训练 5 千亿高质量 token,大幅提高了数学逻辑、代码能力。', + displayName: 'Yi 34B Chat', + enabled: true, + id: 'Yi-34B-Chat' + }, + { + description: 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', + displayName: 'DeepSeek Coder 33B Instruct', + enabled: true, + id: 'deepseek-coder-33B-instruct' + }, + { + description: 'CodeGeeX4-ALL-9B 是一个多语言代码生成模型,支持包括代码补全和生成、代码解释器、网络搜索、函数调用、仓库级代码问答在内的全面功能,覆盖软件开发的各种场景。是参数少于 10B 的顶尖代码生成模型。', + displayName: 'CodeGeeX4 All 9B', + enabled: true, + id: 'codegeex4-all-9b' + }, + { + description: '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', + displayName: 'Code Raccoon v1', + enabled: true, + id: 'code-raccoon-v1' + }, + ], + checkModel: 'Qwen2-7B-Instruct', + description: + 'Gitee AI 的 Serverless API 为 AI 开发者提供开箱即用的大模型推理 API 服务。', + disableBrowserRequest: true, + id: 'gitee', + modelList: { showModelFetcher: true }, + modelsUrl: 'https://ai.gitee.com/docs/openapi/v1#tag/serverless/POST/chat/completions', + name: 'Gitee', + url: 'https://ai.gitee.com', +}; + +export default Gitee; diff --git a/src/config/modelProviders/index.ts b/src/config/modelProviders/index.ts index 3fa1e590c1e5..cd91f0398fd1 100644 --- a/src/config/modelProviders/index.ts +++ b/src/config/modelProviders/index.ts @@ -9,6 +9,7 @@ import BedrockProvider from './bedrock'; import CloudflareProvider from './cloudflare'; import DeepSeekProvider from './deepseek'; import FireworksAIProvider from './fireworksai'; +import GiteeProvider from './gitee'; import GithubProvider from './github'; import GoogleProvider from './google'; import GroqProvider from './groq'; @@ -63,6 +64,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [ CloudflareProvider.chatModels, Ai360Provider.chatModels, SiliconCloudProvider.chatModels, + GiteeProvider.chatModels, UpstageProvider.chatModels, SparkProvider.chatModels, Ai21Provider.chatModels, @@ -106,6 +108,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [ Ai360Provider, TaichuProvider, SiliconCloudProvider, + GiteeProvider, ]; export const filterEnabledModels = (provider: ModelProviderCard) => { @@ -126,6 +129,7 @@ export { default as BedrockProviderCard } from './bedrock'; export { default as CloudflareProviderCard } from './cloudflare'; export { default as DeepSeekProviderCard } from './deepseek'; export { default as FireworksAIProviderCard } from './fireworksai'; +export { default as GiteeProviderCard } from './gitee'; export { default as GithubProviderCard } from './github'; export { default as GoogleProviderCard } from './google'; export { default as GroqProviderCard } from './groq'; diff --git a/src/libs/agent-runtime/AgentRuntime.ts b/src/libs/agent-runtime/AgentRuntime.ts index 7f54ec1abd8e..55a0dbc8e7c5 100644 --- a/src/libs/agent-runtime/AgentRuntime.ts +++ b/src/libs/agent-runtime/AgentRuntime.ts @@ -12,6 +12,7 @@ import { LobeBedrockAI, LobeBedrockAIParams } from './bedrock'; import { LobeCloudflareAI, LobeCloudflareParams } from './cloudflare'; import { LobeDeepSeekAI } from './deepseek'; import { LobeFireworksAI } from './fireworksai'; +import { LobeGiteeAI } from './gitee'; import { LobeGithubAI } from './github'; import { LobeGoogleAI } from './google'; import { LobeGroq } from './groq'; @@ -136,6 +137,7 @@ class AgentRuntime { cloudflare: Partial; deepseek: Partial; fireworksai: Partial; + gitee: Partial; github: Partial; google: { apiKey?: string; baseURL?: string }; groq: Partial; @@ -301,6 +303,11 @@ class AgentRuntime { break; } + case ModelProvider.Gitee: { + runtimeModel = new LobeGiteeAI(params.gitee); + break; + } + case ModelProvider.Upstage: { runtimeModel = new LobeUpstageAI(params.upstage); break; diff --git a/src/libs/agent-runtime/gitee/index.test.ts b/src/libs/agent-runtime/gitee/index.test.ts new file mode 100644 index 000000000000..c8771d5d262b --- /dev/null +++ b/src/libs/agent-runtime/gitee/index.test.ts @@ -0,0 +1,255 @@ +// @vitest-environment node +import OpenAI from 'openai'; +import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; + +import { + ChatStreamCallbacks, + LobeOpenAICompatibleRuntime, + ModelProvider, +} from '@/libs/agent-runtime'; + +import * as debugStreamModule from '../utils/debugStream'; +import { LobeGiteeAI } from './index'; + +const provider = ModelProvider.Gitee; +const defaultBaseURL = 'https://ai.gitee.com/v1'; + +const bizErrorType = 'ProviderBizError'; +const invalidErrorType = 'InvalidProviderAPIKey'; + +// Mock the console.error to avoid polluting test output +vi.spyOn(console, 'error').mockImplementation(() => {}); + +let instance: LobeOpenAICompatibleRuntime; + +beforeEach(() => { + instance = new LobeGiteeAI({ apiKey: 'test' }); + + // 使用 vi.spyOn 来模拟 chat.completions.create 方法 + vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue( + new ReadableStream() as any, + ); +}); + +afterEach(() => { + vi.clearAllMocks(); +}); + +describe('LobeGiteeAI', () => { + describe('init', () => { + it('should correctly initialize with an API key', async () => { + const instance = new LobeGiteeAI({ apiKey: 'test_api_key' }); + expect(instance).toBeInstanceOf(LobeGiteeAI); + expect(instance.baseURL).toEqual(defaultBaseURL); + }); + }); + + describe('chat', () => { + describe('Error', () => { + it('should return OpenAIBizError with an openai error response when OpenAI.APIError is thrown', async () => { + // Arrange + const apiError = new OpenAI.APIError( + 400, + { + status: 400, + error: { + message: 'Bad Request', + }, + }, + 'Error message', + {}, + ); + + vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError); + + // Act + try { + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + temperature: 0, + }); + } catch (e) { + expect(e).toEqual({ + endpoint: defaultBaseURL, + error: { + error: { message: 'Bad Request' }, + status: 400, + }, + errorType: bizErrorType, + provider, + }); + } + }); + + it('should throw AgentRuntimeError with NoOpenAIAPIKey if no apiKey is provided', async () => { + try { + new LobeGiteeAI({}); + } catch (e) { + expect(e).toEqual({ errorType: invalidErrorType }); + } + }); + + it('should return OpenAIBizError with the cause when OpenAI.APIError is thrown with cause', async () => { + // Arrange + const errorInfo = { + stack: 'abc', + cause: { + message: 'api is undefined', + }, + }; + const apiError = new OpenAI.APIError(400, errorInfo, 'module error', {}); + + vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError); + + // Act + try { + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + temperature: 0, + }); + } catch (e) { + expect(e).toEqual({ + endpoint: defaultBaseURL, + error: { + cause: { message: 'api is undefined' }, + stack: 'abc', + }, + errorType: bizErrorType, + provider, + }); + } + }); + + it('should return OpenAIBizError with an cause response with desensitize Url', async () => { + // Arrange + const errorInfo = { + stack: 'abc', + cause: { message: 'api is undefined' }, + }; + const apiError = new OpenAI.APIError(400, errorInfo, 'module error', {}); + + instance = new LobeGiteeAI({ + apiKey: 'test', + + baseURL: 'https://api.abc.com/v1', + }); + + vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(apiError); + + // Act + try { + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + temperature: 0, + }); + } catch (e) { + expect(e).toEqual({ + endpoint: 'https://api.***.com/v1', + error: { + cause: { message: 'api is undefined' }, + stack: 'abc', + }, + errorType: bizErrorType, + provider, + }); + } + }); + + it('should throw an InvalidGiteeAIAPIKey error type on 401 status code', async () => { + // Mock the API call to simulate a 401 error + const error = new Error('Unauthorized') as any; + error.status = 401; + vi.mocked(instance['client'].chat.completions.create).mockRejectedValue(error); + + try { + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + temperature: 0, + }); + } catch (e) { + // Expect the chat method to throw an error with InvalidGiteeAIAPIKey + expect(e).toEqual({ + endpoint: defaultBaseURL, + error: new Error('Unauthorized'), + errorType: invalidErrorType, + provider, + }); + } + }); + + it('should return AgentRuntimeError for non-OpenAI errors', async () => { + // Arrange + const genericError = new Error('Generic Error'); + + vi.spyOn(instance['client'].chat.completions, 'create').mockRejectedValue(genericError); + + // Act + try { + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + temperature: 0, + }); + } catch (e) { + expect(e).toEqual({ + endpoint: defaultBaseURL, + errorType: 'AgentRuntimeError', + provider, + error: { + name: genericError.name, + cause: genericError.cause, + message: genericError.message, + stack: genericError.stack, + }, + }); + } + }); + }); + + describe('DEBUG', () => { + it('should call debugStream and return StreamingTextResponse when DEBUG_GITEE_CHAT_COMPLETION is 1', async () => { + // Arrange + const mockProdStream = new ReadableStream() as any; // 模拟的 prod 流 + const mockDebugStream = new ReadableStream({ + start(controller) { + controller.enqueue('Debug stream content'); + controller.close(); + }, + }) as any; + mockDebugStream.toReadableStream = () => mockDebugStream; // 添加 toReadableStream 方法 + + // 模拟 chat.completions.create 返回值,包括模拟的 tee 方法 + (instance['client'].chat.completions.create as Mock).mockResolvedValue({ + tee: () => [mockProdStream, { toReadableStream: () => mockDebugStream }], + }); + + // 保存原始环境变量值 + const originalDebugValue = process.env.DEBUG_GITEE_CHAT_COMPLETION; + + // 模拟环境变量 + process.env.DEBUG_GITEE_CHAT_COMPLETION = '1'; + vi.spyOn(debugStreamModule, 'debugStream').mockImplementation(() => Promise.resolve()); + + // 执行测试 + // 运行你的测试函数,确保它会在条件满足时调用 debugStream + // 假设的测试函数调用,你可能需要根据实际情况调整 + await instance.chat({ + messages: [{ content: 'Hello', role: 'user' }], + model: 'Qwen2-7B-Instruct', + stream: true, + temperature: 0, + }); + + // 验证 debugStream 被调用 + expect(debugStreamModule.debugStream).toHaveBeenCalled(); + + // 恢复原始环境变量值 + process.env.DEBUG_GITEE_CHAT_COMPLETION = originalDebugValue; + }); + }); + }); +}); diff --git a/src/libs/agent-runtime/gitee/index.ts b/src/libs/agent-runtime/gitee/index.ts new file mode 100644 index 000000000000..926cb400c5ef --- /dev/null +++ b/src/libs/agent-runtime/gitee/index.ts @@ -0,0 +1,10 @@ +import { ModelProvider } from '../types'; +import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; + +export const LobeGiteeAI = LobeOpenAICompatibleFactory({ + baseURL: 'https://ai.gitee.com/v1', + debug: { + chatCompletion: () => process.env.DEBUG_GITEE_CHAT_COMPLETION === '1', + }, + provider: ModelProvider.Gitee, +}); diff --git a/src/libs/agent-runtime/togetherai/__snapshots__/index.test.ts.snap b/src/libs/agent-runtime/togetherai/__snapshots__/index.test.ts.snap index 4a969451ce8d..7e7a2edf7cd3 100644 --- a/src/libs/agent-runtime/togetherai/__snapshots__/index.test.ts.snap +++ b/src/libs/agent-runtime/togetherai/__snapshots__/index.test.ts.snap @@ -565,7 +565,7 @@ exports[`LobeTogetherAI > models > should get models 1`] = ` { "description": "The Yi series models are large language models trained from scratch by developers at 01.AI", "displayName": "01-ai Yi Chat (34B)", - "enabled": false, + "enabled": true, "functionCall": false, "id": "zero-one-ai/Yi-34B-Chat", "maxOutput": 4096, diff --git a/src/libs/agent-runtime/types/type.ts b/src/libs/agent-runtime/types/type.ts index 5a00cbc3dd9c..3ade57095cae 100644 --- a/src/libs/agent-runtime/types/type.ts +++ b/src/libs/agent-runtime/types/type.ts @@ -31,6 +31,7 @@ export enum ModelProvider { Cloudflare = 'cloudflare', DeepSeek = 'deepseek', FireworksAI = 'fireworksai', + Gitee = 'gitee', Github = 'github', Google = 'google', Groq = 'groq', diff --git a/src/server/modules/AgentRuntime/index.ts b/src/server/modules/AgentRuntime/index.ts index 6d2ead94a01a..1f5fa73a884e 100644 --- a/src/server/modules/AgentRuntime/index.ts +++ b/src/server/modules/AgentRuntime/index.ts @@ -236,6 +236,13 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => { return { apiKey, baseURL }; } + case ModelProvider.Gitee: { + const { GITEE_API_KEY } = getLLMConfig(); + + const apiKey = apiKeyManager.pick(payload?.apiKey || GITEE_API_KEY); + + return { apiKey }; + } case ModelProvider.HuggingFace: { const { HUGGINGFACE_PROXY_URL, HUGGINGFACE_API_KEY } = getLLMConfig(); diff --git a/src/types/user/settings/keyVaults.ts b/src/types/user/settings/keyVaults.ts index dec9a9c1ab7c..c048be8ee8f5 100644 --- a/src/types/user/settings/keyVaults.ts +++ b/src/types/user/settings/keyVaults.ts @@ -41,6 +41,7 @@ export interface UserKeyVaults { cloudflare?: CloudflareKeyVault; deepseek?: OpenAICompatibleKeyVault; fireworksai?: OpenAICompatibleKeyVault; + gitee?: OpenAICompatibleKeyVault; github?: OpenAICompatibleKeyVault; google?: OpenAICompatibleKeyVault; groq?: OpenAICompatibleKeyVault; From b43fb5449c5edd19f1ae2f1288b380e1aa087426 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 10:18:02 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20`code-raccoon-v?= =?UTF-8?q?1`=20topP=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/agent-runtime/gitee/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libs/agent-runtime/gitee/index.ts b/src/libs/agent-runtime/gitee/index.ts index 926cb400c5ef..28ddd7fc87db 100644 --- a/src/libs/agent-runtime/gitee/index.ts +++ b/src/libs/agent-runtime/gitee/index.ts @@ -1,8 +1,22 @@ -import { ModelProvider } from '../types'; +import OpenAI from 'openai'; + +import { ChatStreamPayload, ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; export const LobeGiteeAI = LobeOpenAICompatibleFactory({ baseURL: 'https://ai.gitee.com/v1', + chatCompletion: { + handlePayload: ({ model, top_p, ...payload }: ChatStreamPayload) => + ({ + ...payload, + model, + ...(model === "code-raccoon-v1" ? { + top_p: (top_p !== undefined && top_p > 0 && top_p < 1) ? top_p : undefined, + } : { + top_p, + }), + }) as OpenAI.ChatCompletionCreateParamsStreaming, + }, debug: { chatCompletion: () => process.env.DEBUG_GITEE_CHAT_COMPLETION === '1', }, From 30e2a95ef38f7bdb9834582587ed5b52e2b47f52 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 10:43:07 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=92=84=20style:=20update=20model=20li?= =?UTF-8?q?st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/gitee.ts | 29 +++++++++++++++------------ src/libs/agent-runtime/gitee/index.ts | 16 +-------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/config/modelProviders/gitee.ts b/src/config/modelProviders/gitee.ts index 02b35ffc8e33..96fa7b2e621f 100644 --- a/src/config/modelProviders/gitee.ts +++ b/src/config/modelProviders/gitee.ts @@ -1,52 +1,55 @@ import { ModelProviderCard } from '@/types/llm'; +// ref: https://ai.gitee.com/serverless-api/packages/1493 const Gitee: ModelProviderCard = { chatModels: [ { description: 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', displayName: 'Qwen2.5 72B Instruct', enabled: true, - id: 'Qwen2.5-72B-Instruct' + functionCall: true, + id: 'Qwen2.5-72B-Instruct', + tokens: 16_000, }, { description: 'Qwen2 是 Qwen 模型的最新系列,支持 128k 上下文,对比当前最优的开源模型,Qwen2-72B 在自然语言理解、知识、代码、数学及多语言等多项能力上均显著超越当前领先的模型。', displayName: 'Qwen2 72B Instruct', - id: 'Qwen2-72B-Instruct' + id: 'Qwen2-72B-Instruct', + tokens: 6000, }, { description: 'Qwen2 是 Qwen 模型的最新系列,能够超越同等规模的最优开源模型甚至更大规模的模型,Qwen2 7B 在多个评测上取得显著的优势,尤其是代码及中文理解上。', displayName: 'Qwen2 7B Instruct', - id: 'Qwen2-7B-Instruct' + id: 'Qwen2-7B-Instruct', + tokens: 32_000, }, { description: 'GLM-4-9B-Chat 在语义、数学、推理、代码和知识等多方面均表现出较高性能。还具备网页浏览、代码执行、自定义工具调用和长文本推理。 支持包括日语,韩语,德语在内的 26 种语言。', displayName: 'GLM4 9B Chat', enabled: true, - id: 'glm-4-9b-chat' + id: 'glm-4-9b-chat', + tokens: 32_000, }, { description: 'Yi-1.5-34B 在保持原系列模型优秀的通用语言能力的前提下,通过增量训练 5 千亿高质量 token,大幅提高了数学逻辑、代码能力。', displayName: 'Yi 34B Chat', enabled: true, - id: 'Yi-34B-Chat' + id: 'Yi-34B-Chat', + tokens: 4_000, }, { description: 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', displayName: 'DeepSeek Coder 33B Instruct', enabled: true, - id: 'deepseek-coder-33B-instruct' + id: 'deepseek-coder-33B-instruct', + tokens: 8_000, }, { description: 'CodeGeeX4-ALL-9B 是一个多语言代码生成模型,支持包括代码补全和生成、代码解释器、网络搜索、函数调用、仓库级代码问答在内的全面功能,覆盖软件开发的各种场景。是参数少于 10B 的顶尖代码生成模型。', displayName: 'CodeGeeX4 All 9B', enabled: true, - id: 'codegeex4-all-9b' - }, - { - description: '代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节,满足用户代码编写、编程学习等各类需求。代码小浣熊支持 Python、Java、JavaScript、C++、Go、SQL 等 90+主流编程语言和 VS Code、IntelliJ IDEA 等主流 IDE。在实际应用中,代码小浣熊可帮助开发者提升编程效率超 50%。', - displayName: 'Code Raccoon v1', - enabled: true, - id: 'code-raccoon-v1' + id: 'codegeex4-all-9b', + tokens: 40_000, }, ], checkModel: 'Qwen2-7B-Instruct', diff --git a/src/libs/agent-runtime/gitee/index.ts b/src/libs/agent-runtime/gitee/index.ts index 28ddd7fc87db..926cb400c5ef 100644 --- a/src/libs/agent-runtime/gitee/index.ts +++ b/src/libs/agent-runtime/gitee/index.ts @@ -1,22 +1,8 @@ -import OpenAI from 'openai'; - -import { ChatStreamPayload, ModelProvider } from '../types'; +import { ModelProvider } from '../types'; import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; export const LobeGiteeAI = LobeOpenAICompatibleFactory({ baseURL: 'https://ai.gitee.com/v1', - chatCompletion: { - handlePayload: ({ model, top_p, ...payload }: ChatStreamPayload) => - ({ - ...payload, - model, - ...(model === "code-raccoon-v1" ? { - top_p: (top_p !== undefined && top_p > 0 && top_p < 1) ? top_p : undefined, - } : { - top_p, - }), - }) as OpenAI.ChatCompletionCreateParamsStreaming, - }, debug: { chatCompletion: () => process.env.DEBUG_GITEE_CHAT_COMPLETION === '1', }, From 08e8f31cd0e3a92ff53a364db75bcaf3a3fa9e55 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 10:47:41 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=91=B7=20build:=20add=20docker=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 ++ Dockerfile.database | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index d3528c81e582..3e94a70faf5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -158,6 +158,8 @@ ENV \ DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \ # Fireworks AI FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \ + # Gitee + GITEE_API_KEY="" GITEE_MODEL_LIST="" \ # GitHub GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \ # Google diff --git a/Dockerfile.database b/Dockerfile.database index cca4cc35ee78..3f59eab7f9c6 100644 --- a/Dockerfile.database +++ b/Dockerfile.database @@ -193,6 +193,8 @@ ENV \ DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \ # Fireworks AI FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \ + # Gitee + GITEE_API_KEY="" GITEE_MODEL_LIST="" \ # GitHub GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \ # Google From 61f4bd3e47967a38af862a12f52ef1aee94d2713 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 10:51:59 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20CI=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/gitee.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/modelProviders/gitee.ts b/src/config/modelProviders/gitee.ts index 96fa7b2e621f..042f3ab3e9d8 100644 --- a/src/config/modelProviders/gitee.ts +++ b/src/config/modelProviders/gitee.ts @@ -35,14 +35,14 @@ const Gitee: ModelProviderCard = { displayName: 'Yi 34B Chat', enabled: true, id: 'Yi-34B-Chat', - tokens: 4_000, + tokens: 4000, }, { description: 'DeepSeek Coder 33B 是一个代码语言模型, 基于 2 万亿数据训练而成,其中 87% 为代码, 13% 为中英文语言。模型引入 16K 窗口大小和填空任务,提供项目级别的代码补全和片段填充功能。', displayName: 'DeepSeek Coder 33B Instruct', enabled: true, id: 'deepseek-coder-33B-instruct', - tokens: 8_000, + tokens: 8000, }, { description: 'CodeGeeX4-ALL-9B 是一个多语言代码生成模型,支持包括代码补全和生成、代码解释器、网络搜索、函数调用、仓库级代码问答在内的全面功能,覆盖软件开发的各种场景。是参数少于 10B 的顶尖代码生成模型。', From 5245e7a6f032b48f21cb9a1c3fba370f4506ceee Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 10:56:46 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=94=A8=20chore:=20cleanup=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/llm.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/llm.ts b/src/config/llm.ts index 8713caef478a..342327a1c4c5 100644 --- a/src/config/llm.ts +++ b/src/config/llm.ts @@ -229,7 +229,7 @@ export const getLLMConfig = () => { ENABLED_GITEE: !!process.env.GITEE_API_KEY, GITEE_API_KEY: process.env.GITEE_API_KEY, - + ENABLED_UPSTAGE: !!process.env.UPSTAGE_API_KEY, UPSTAGE_API_KEY: process.env.UPSTAGE_API_KEY, From dc00bac5d9be3d3c5f5c3fa3b6d7e48a45bedf96 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Sun, 17 Nov 2024 11:45:43 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=92=84=20style:=20update=20modelProvi?= =?UTF-8?q?der=20display=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/modelProviders/gitee.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/modelProviders/gitee.ts b/src/config/modelProviders/gitee.ts index 042f3ab3e9d8..45619d913777 100644 --- a/src/config/modelProviders/gitee.ts +++ b/src/config/modelProviders/gitee.ts @@ -59,7 +59,7 @@ const Gitee: ModelProviderCard = { id: 'gitee', modelList: { showModelFetcher: true }, modelsUrl: 'https://ai.gitee.com/docs/openapi/v1#tag/serverless/POST/chat/completions', - name: 'Gitee', + name: 'Gitee AI', url: 'https://ai.gitee.com', }; From d5cb60deee4c4eedf8e4f0c261167f51b4886524 Mon Sep 17 00:00:00 2001 From: Zhijie He Date: Tue, 19 Nov 2024 11:51:07 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=92=84=20style:=20update=20Gitee=20AI?= =?UTF-8?q?=20branding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- Dockerfile.database | 4 ++-- src/app/(main)/settings/llm/ProviderList/providers.tsx | 4 ++-- src/config/llm.ts | 8 ++++---- src/config/modelProviders/{gitee.ts => giteeai.ts} | 6 +++--- src/config/modelProviders/index.ts | 8 ++++---- src/libs/agent-runtime/AgentRuntime.ts | 8 ++++---- .../agent-runtime/{gitee => giteeai}/index.test.ts | 10 +++++----- src/libs/agent-runtime/{gitee => giteeai}/index.ts | 4 ++-- src/libs/agent-runtime/types/type.ts | 2 +- src/server/globalConfig/index.ts | 4 ++++ src/server/modules/AgentRuntime/index.ts | 6 +++--- src/types/user/settings/keyVaults.ts | 2 +- 13 files changed, 37 insertions(+), 33 deletions(-) rename src/config/modelProviders/{gitee.ts => giteeai.ts} (97%) rename src/libs/agent-runtime/{gitee => giteeai}/index.test.ts (96%) rename src/libs/agent-runtime/{gitee => giteeai}/index.ts (67%) diff --git a/Dockerfile b/Dockerfile index aaf87fa22680..c1432a9ccb73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -158,8 +158,8 @@ ENV \ DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \ # Fireworks AI FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \ - # Gitee - GITEE_API_KEY="" GITEE_MODEL_LIST="" \ + # Gitee AI + GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \ # GitHub GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \ # Google diff --git a/Dockerfile.database b/Dockerfile.database index 19b8b8bbad99..ce21543e706f 100644 --- a/Dockerfile.database +++ b/Dockerfile.database @@ -193,8 +193,8 @@ ENV \ DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \ # Fireworks AI FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \ - # Gitee - GITEE_API_KEY="" GITEE_MODEL_LIST="" \ + # Gitee AI + GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \ # GitHub GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \ # Google diff --git a/src/app/(main)/settings/llm/ProviderList/providers.tsx b/src/app/(main)/settings/llm/ProviderList/providers.tsx index 09b514a97f4d..1e90871fce22 100644 --- a/src/app/(main)/settings/llm/ProviderList/providers.tsx +++ b/src/app/(main)/settings/llm/ProviderList/providers.tsx @@ -7,7 +7,7 @@ import { BaichuanProviderCard, DeepSeekProviderCard, FireworksAIProviderCard, - GiteeProviderCard, + GiteeAIProviderCard, GoogleProviderCard, GroqProviderCard, HunyuanProviderCard, @@ -89,7 +89,7 @@ export const useProviderList = (): ProviderItem[] => { TaichuProviderCard, InternLMProviderCard, SiliconCloudProviderCard, - GiteeProviderCard, + GiteeAIProviderCard, ], [ AzureProvider, diff --git a/src/config/llm.ts b/src/config/llm.ts index 89f57610c191..46c433fc3cc7 100644 --- a/src/config/llm.ts +++ b/src/config/llm.ts @@ -102,8 +102,8 @@ export const getLLMConfig = () => { SILICONCLOUD_API_KEY: z.string().optional(), SILICONCLOUD_PROXY_URL: z.string().optional(), - ENABLED_GITEE: z.boolean(), - GITEE_API_KEY: z.string().optional(), + ENABLED_GITEE_AI: z.boolean(), + GITEE_AI_API_KEY: z.string().optional(), ENABLED_UPSTAGE: z.boolean(), UPSTAGE_API_KEY: z.string().optional(), @@ -230,8 +230,8 @@ export const getLLMConfig = () => { SILICONCLOUD_API_KEY: process.env.SILICONCLOUD_API_KEY, SILICONCLOUD_PROXY_URL: process.env.SILICONCLOUD_PROXY_URL, - ENABLED_GITEE: !!process.env.GITEE_API_KEY, - GITEE_API_KEY: process.env.GITEE_API_KEY, + ENABLED_GITEE_AI: !!process.env.GITEE_AI_API_KEY, + GITEE_AI_API_KEY: process.env.GITEE_AI_API_KEY, ENABLED_UPSTAGE: !!process.env.UPSTAGE_API_KEY, UPSTAGE_API_KEY: process.env.UPSTAGE_API_KEY, diff --git a/src/config/modelProviders/gitee.ts b/src/config/modelProviders/giteeai.ts similarity index 97% rename from src/config/modelProviders/gitee.ts rename to src/config/modelProviders/giteeai.ts index 45619d913777..49f997b2f2a4 100644 --- a/src/config/modelProviders/gitee.ts +++ b/src/config/modelProviders/giteeai.ts @@ -1,7 +1,7 @@ import { ModelProviderCard } from '@/types/llm'; // ref: https://ai.gitee.com/serverless-api/packages/1493 -const Gitee: ModelProviderCard = { +const GiteeAI: ModelProviderCard = { chatModels: [ { description: 'Qwen2.5-72B-Instruct 支持 16k 上下文, 生成长文本超过 8K 。支持 function call 与外部系统无缝交互,极大提升了灵活性和扩展性。模型知识明显增加,并且大大提高了编码和数学能力, 多语言支持超过 29 种', @@ -56,11 +56,11 @@ const Gitee: ModelProviderCard = { description: 'Gitee AI 的 Serverless API 为 AI 开发者提供开箱即用的大模型推理 API 服务。', disableBrowserRequest: true, - id: 'gitee', + id: 'giteeai', modelList: { showModelFetcher: true }, modelsUrl: 'https://ai.gitee.com/docs/openapi/v1#tag/serverless/POST/chat/completions', name: 'Gitee AI', url: 'https://ai.gitee.com', }; -export default Gitee; +export default GiteeAI; diff --git a/src/config/modelProviders/index.ts b/src/config/modelProviders/index.ts index eb22a5af2703..961736a34fff 100644 --- a/src/config/modelProviders/index.ts +++ b/src/config/modelProviders/index.ts @@ -9,7 +9,7 @@ import BedrockProvider from './bedrock'; import CloudflareProvider from './cloudflare'; import DeepSeekProvider from './deepseek'; import FireworksAIProvider from './fireworksai'; -import GiteeProvider from './gitee'; +import GiteeAIProvider from './giteeai'; import GithubProvider from './github'; import GoogleProvider from './google'; import GroqProvider from './groq'; @@ -65,7 +65,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [ CloudflareProvider.chatModels, Ai360Provider.chatModels, SiliconCloudProvider.chatModels, - GiteeProvider.chatModels, + GiteeAIProvider.chatModels, UpstageProvider.chatModels, SparkProvider.chatModels, Ai21Provider.chatModels, @@ -111,7 +111,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [ TaichuProvider, InternLMProvider, SiliconCloudProvider, - GiteeProvider, + GiteeAIProvider, ]; export const filterEnabledModels = (provider: ModelProviderCard) => { @@ -132,7 +132,7 @@ export { default as BedrockProviderCard } from './bedrock'; export { default as CloudflareProviderCard } from './cloudflare'; export { default as DeepSeekProviderCard } from './deepseek'; export { default as FireworksAIProviderCard } from './fireworksai'; -export { default as GiteeProviderCard } from './gitee'; +export { default as GiteeAIProviderCard } from './giteeai'; export { default as GithubProviderCard } from './github'; export { default as GoogleProviderCard } from './google'; export { default as GroqProviderCard } from './groq'; diff --git a/src/libs/agent-runtime/AgentRuntime.ts b/src/libs/agent-runtime/AgentRuntime.ts index fb0dff7c4185..6cc1d0332943 100644 --- a/src/libs/agent-runtime/AgentRuntime.ts +++ b/src/libs/agent-runtime/AgentRuntime.ts @@ -12,7 +12,7 @@ import { LobeBedrockAI, LobeBedrockAIParams } from './bedrock'; import { LobeCloudflareAI, LobeCloudflareParams } from './cloudflare'; import { LobeDeepSeekAI } from './deepseek'; import { LobeFireworksAI } from './fireworksai'; -import { LobeGiteeAI } from './gitee'; +import { LobeGiteeAI } from './giteeai'; import { LobeGithubAI } from './github'; import { LobeGoogleAI } from './google'; import { LobeGroq } from './groq'; @@ -138,7 +138,7 @@ class AgentRuntime { cloudflare: Partial; deepseek: Partial; fireworksai: Partial; - gitee: Partial; + giteeai: Partial; github: Partial; google: { apiKey?: string; baseURL?: string }; groq: Partial; @@ -305,8 +305,8 @@ class AgentRuntime { break; } - case ModelProvider.Gitee: { - runtimeModel = new LobeGiteeAI(params.gitee); + case ModelProvider.GiteeAI: { + runtimeModel = new LobeGiteeAI(params.giteeai); break; } diff --git a/src/libs/agent-runtime/gitee/index.test.ts b/src/libs/agent-runtime/giteeai/index.test.ts similarity index 96% rename from src/libs/agent-runtime/gitee/index.test.ts rename to src/libs/agent-runtime/giteeai/index.test.ts index c8771d5d262b..f9c2866afe59 100644 --- a/src/libs/agent-runtime/gitee/index.test.ts +++ b/src/libs/agent-runtime/giteeai/index.test.ts @@ -11,7 +11,7 @@ import { import * as debugStreamModule from '../utils/debugStream'; import { LobeGiteeAI } from './index'; -const provider = ModelProvider.Gitee; +const provider = ModelProvider.GiteeAI; const defaultBaseURL = 'https://ai.gitee.com/v1'; const bizErrorType = 'ProviderBizError'; @@ -211,7 +211,7 @@ describe('LobeGiteeAI', () => { }); describe('DEBUG', () => { - it('should call debugStream and return StreamingTextResponse when DEBUG_GITEE_CHAT_COMPLETION is 1', async () => { + it('should call debugStream and return StreamingTextResponse when DEBUG_GITEE_AI_CHAT_COMPLETION is 1', async () => { // Arrange const mockProdStream = new ReadableStream() as any; // 模拟的 prod 流 const mockDebugStream = new ReadableStream({ @@ -228,10 +228,10 @@ describe('LobeGiteeAI', () => { }); // 保存原始环境变量值 - const originalDebugValue = process.env.DEBUG_GITEE_CHAT_COMPLETION; + const originalDebugValue = process.env.DEBUG_GITEE_AI_CHAT_COMPLETION; // 模拟环境变量 - process.env.DEBUG_GITEE_CHAT_COMPLETION = '1'; + process.env.DEBUG_GITEE_AI_CHAT_COMPLETION = '1'; vi.spyOn(debugStreamModule, 'debugStream').mockImplementation(() => Promise.resolve()); // 执行测试 @@ -248,7 +248,7 @@ describe('LobeGiteeAI', () => { expect(debugStreamModule.debugStream).toHaveBeenCalled(); // 恢复原始环境变量值 - process.env.DEBUG_GITEE_CHAT_COMPLETION = originalDebugValue; + process.env.DEBUG_GITEE_AI_CHAT_COMPLETION = originalDebugValue; }); }); }); diff --git a/src/libs/agent-runtime/gitee/index.ts b/src/libs/agent-runtime/giteeai/index.ts similarity index 67% rename from src/libs/agent-runtime/gitee/index.ts rename to src/libs/agent-runtime/giteeai/index.ts index 926cb400c5ef..a84af7571a5f 100644 --- a/src/libs/agent-runtime/gitee/index.ts +++ b/src/libs/agent-runtime/giteeai/index.ts @@ -4,7 +4,7 @@ import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory'; export const LobeGiteeAI = LobeOpenAICompatibleFactory({ baseURL: 'https://ai.gitee.com/v1', debug: { - chatCompletion: () => process.env.DEBUG_GITEE_CHAT_COMPLETION === '1', + chatCompletion: () => process.env.DEBUG_GITEE_AI_CHAT_COMPLETION === '1', }, - provider: ModelProvider.Gitee, + provider: ModelProvider.GiteeAI, }); diff --git a/src/libs/agent-runtime/types/type.ts b/src/libs/agent-runtime/types/type.ts index 8f02639a9804..16f0b4f72948 100644 --- a/src/libs/agent-runtime/types/type.ts +++ b/src/libs/agent-runtime/types/type.ts @@ -31,7 +31,7 @@ export enum ModelProvider { Cloudflare = 'cloudflare', DeepSeek = 'deepseek', FireworksAI = 'fireworksai', - Gitee = 'gitee', + GiteeAI = 'giteeai', Github = 'github', Google = 'google', Groq = 'groq', diff --git a/src/server/globalConfig/index.ts b/src/server/globalConfig/index.ts index 65822bd171b1..6f7e369ccd2d 100644 --- a/src/server/globalConfig/index.ts +++ b/src/server/globalConfig/index.ts @@ -30,6 +30,10 @@ export const getServerGlobalConfig = () => { enabledKey: 'ENABLED_AWS_BEDROCK', modelListKey: 'AWS_BEDROCK_MODEL_LIST', }, + giteeai: { + enabledKey: 'ENABLED_GITEE_AI', + modelListKey: 'GITEE_AI_MODEL_LIST', + }, ollama: { fetchOnClient: !getLLMConfig().OLLAMA_PROXY_URL, }, diff --git a/src/server/modules/AgentRuntime/index.ts b/src/server/modules/AgentRuntime/index.ts index 0e5e4993a73e..fb4522b635ca 100644 --- a/src/server/modules/AgentRuntime/index.ts +++ b/src/server/modules/AgentRuntime/index.ts @@ -236,10 +236,10 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => { return { apiKey, baseURL }; } - case ModelProvider.Gitee: { - const { GITEE_API_KEY } = getLLMConfig(); + case ModelProvider.GiteeAI: { + const { GITEE_AI_API_KEY } = getLLMConfig(); - const apiKey = apiKeyManager.pick(payload?.apiKey || GITEE_API_KEY); + const apiKey = apiKeyManager.pick(payload?.apiKey || GITEE_AI_API_KEY); return { apiKey }; } diff --git a/src/types/user/settings/keyVaults.ts b/src/types/user/settings/keyVaults.ts index f0f0ebb1b468..f6156c22363a 100644 --- a/src/types/user/settings/keyVaults.ts +++ b/src/types/user/settings/keyVaults.ts @@ -41,7 +41,7 @@ export interface UserKeyVaults { cloudflare?: CloudflareKeyVault; deepseek?: OpenAICompatibleKeyVault; fireworksai?: OpenAICompatibleKeyVault; - gitee?: OpenAICompatibleKeyVault; + giteeai?: OpenAICompatibleKeyVault; github?: OpenAICompatibleKeyVault; google?: OpenAICompatibleKeyVault; groq?: OpenAICompatibleKeyVault;