Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: support tencent cloud #6029

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config/aiModels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { default as siliconcloud } from './siliconcloud';
import { default as spark } from './spark';
import { default as stepfun } from './stepfun';
import { default as taichu } from './taichu';
import { default as tencentcloud } from './tencentcloud';
import { default as togetherai } from './togetherai';
import { default as upstage } from './upstage';
import { default as wenxin } from './wenxin';
Expand Down Expand Up @@ -93,6 +94,7 @@ export const LOBE_DEFAULT_MODEL_LIST = buildDefaultModelList({
spark,
stepfun,
taichu,
tencentcloud,
togetherai,
upstage,
wenxin,
Expand Down Expand Up @@ -134,6 +136,7 @@ export { default as siliconcloud } from './siliconcloud';
export { default as spark } from './spark';
export { default as stepfun } from './stepfun';
export { default as taichu } from './taichu';
export { default as tencentcloud } from './tencentcloud';
export { default as togetherai } from './togetherai';
export { default as upstage } from './upstage';
export { default as wenxin } from './wenxin';
Expand Down
43 changes: 43 additions & 0 deletions src/config/aiModels/tencentcloud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { AIChatModelCard } from '@/types/aiModel';

const tencentCloudChatModels: AIChatModelCard[] = [
{
abilities: {
reasoning: true,
},
contextWindowTokens: 65_536,
description:
'DeepSeek-R1 是一款强化学习(RL)驱动的推理模型,解决了模型中的重复性和可读性问题。在 RL 之前,DeepSeek-R1 引入了冷启动数据,进一步优化了推理性能。它在数学、代码和推理任务中与 OpenAI-o1 表现相当,并且通过精心设计的训练方法,提升了整体效果。',
displayName: 'DeepSeek R1',
enabled: true,
id: 'deepseek-r1',
maxOutput: 8192,
pricing: {
currency: 'CNY',
input: 4,
output: 16,
},
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 65_536,
description:
'DeepSeek-V3 是一款拥有 6710 亿参数的混合专家(MoE)语言模型,采用多头潜在注意力(MLA)和 DeepSeekMoE 架构,结合无辅助损失的负载平衡策略,优化推理和训练效率。通过在 14.8 万亿高质量tokens上预训练,并进行监督微调和强化学习,DeepSeek-V3 在性能上超越其他开源模型,接近领先闭源模型。',
displayName: 'DeepSeek V3',
enabled: true,
id: 'deepseek-v3',
pricing: {
currency: 'CNY',
input: 2,
output: 8,
},
type: 'chat',
},
];

export const allModels = [...tencentCloudChatModels];

export default allModels;
3 changes: 3 additions & 0 deletions src/config/modelProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import SiliconCloudProvider from './siliconcloud';
import SparkProvider from './spark';
import StepfunProvider from './stepfun';
import TaichuProvider from './taichu';
import TencentcloudProvider from './tencentcloud';
import TogetherAIProvider from './togetherai';
import UpstageProvider from './upstage';
import WenxinProvider from './wenxin';
Expand Down Expand Up @@ -105,6 +106,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
XAIProvider,
QwenProvider,
WenxinProvider,
TencentcloudProvider,
HunyuanProvider,
ZhiPuProvider,
SiliconCloudProvider,
Expand Down Expand Up @@ -166,6 +168,7 @@ export { default as SiliconCloudProviderCard } from './siliconcloud';
export { default as SparkProviderCard } from './spark';
export { default as StepfunProviderCard } from './stepfun';
export { default as TaichuProviderCard } from './taichu';
export { default as TencentCloudProviderCard } from './tencentcloud';
export { default as TogetherAIProviderCard } from './togetherai';
export { default as UpstageProviderCard } from './upstage';
export { default as WenxinProviderCard } from './wenxin';
Expand Down
19 changes: 19 additions & 0 deletions src/config/modelProviders/tencentcloud.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ModelProviderCard } from '@/types/llm';

const TencentCloud: ModelProviderCard = {
chatModels: [],
checkModel: 'deepseek-v3',
description:
'知识引擎原子能力(LLM Knowledge Engine Atomic Power)基于知识引擎研发的知识问答全链路能力,面向企业及开发者,提供灵活组建及开发模型应用的能力。您可通过多款原子能力组建您专属的模型服务,调用文档解析、拆分、embedding、多轮改写等服务进行组装,定制企业专属 AI 业务。',
id: 'tencentcloud',
modelsUrl: 'https://cloud.tencent.com/document/api/1772/115963',
name: 'TencentCloud',
settings: {
disableBrowserRequest: true,
sdkType: 'openai',
showModelFetcher: true,
},
url: 'https://cloud.tencent.com/document/api/1772/115365',
};

export default TencentCloud;
7 changes: 7 additions & 0 deletions src/libs/agent-runtime/AgentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { LobeSiliconCloudAI } from './siliconcloud';
import { LobeSparkAI } from './spark';
import { LobeStepfunAI } from './stepfun';
import { LobeTaichuAI } from './taichu';
import { LobeTencentCloudAI } from './tencentcloud';
import { LobeTogetherAI } from './togetherai';
import {
ChatCompetitionOptions,
Expand Down Expand Up @@ -166,6 +167,7 @@ class AgentRuntime {
spark: Partial<ClientOptions>;
stepfun: Partial<ClientOptions>;
taichu: Partial<ClientOptions>;
tencentcloud: Partial<ClientOptions>;
togetherai: Partial<ClientOptions>;
upstage: Partial<ClientOptions>;
wenxin: Partial<ClientOptions>;
Expand Down Expand Up @@ -368,6 +370,11 @@ class AgentRuntime {
break;
}

case ModelProvider.TencentCloud: {
runtimeModel = new LobeTencentCloudAI(params[provider]);
break;
}

case ModelProvider.Doubao: {
runtimeModel = new LobeDoubaoAI(params.doubao);
break;
Expand Down
13 changes: 13 additions & 0 deletions src/libs/agent-runtime/tencentcloud/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @vitest-environment node
import { ModelProvider } from '@/libs/agent-runtime';

import { testProvider } from '../providerTestUtils';
import { LobeTencentCloudAI } from './index';

testProvider({
Runtime: LobeTencentCloudAI,
provider: ModelProvider.TencentCloud,
defaultBaseURL: 'https://api.lkeap.cloud.tencent.com/v1',
chatDebugEnv: 'DEBUG_TENCENT_CLOUD_CHAT_COMPLETION',
chatModel: 'DeepSeek-R1',
});
10 changes: 10 additions & 0 deletions src/libs/agent-runtime/tencentcloud/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ModelProvider } from '../types';
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';

export const LobeTencentCloudAI = LobeOpenAICompatibleFactory({
baseURL: 'https://api.lkeap.cloud.tencent.com/v1',
debug: {
chatCompletion: () => process.env.DEBUG_TENCENT_CLOUD_CHAT_COMPLETION === '1',
},
provider: ModelProvider.TencentCloud,
});
1 change: 1 addition & 0 deletions src/libs/agent-runtime/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export enum ModelProvider {
Spark = 'spark',
Stepfun = 'stepfun',
Taichu = 'taichu',
TencentCloud = 'tencentcloud',
TogetherAI = 'togetherai',
Upstage = 'upstage',
Wenxin = 'wenxin',
Expand Down
1 change: 1 addition & 0 deletions src/types/user/settings/keyVaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface UserKeyVaults {
spark?: OpenAICompatibleKeyVault;
stepfun?: OpenAICompatibleKeyVault;
taichu?: OpenAICompatibleKeyVault;
tencentcloud?: OpenAICompatibleKeyVault;
togetherai?: OpenAICompatibleKeyVault;
upstage?: OpenAICompatibleKeyVault;
wenxin?: OpenAICompatibleKeyVault;
Expand Down