Skip to content

Commit 8ddb41b

Browse files
authored
✨ feat: add Hunyuan(Tencent) model provider (#4147)
* ✨ feat: add Hunyuan(Tencent) model provider * 💄 style: add `HUNYUAN_MODEL_LIST` support * 💄 style: update model price & provider description * 💄 style: enable `hunyuan-standard-256K` as default, sort model provider list * 💄 style: update model tokens info * 💄 style: update pricing * 💄 style: update `hunyuan-turbo` model info
1 parent ac8de6b commit 8ddb41b

File tree

14 files changed

+453
-0
lines changed

14 files changed

+453
-0
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ ENV \
135135
GOOGLE_API_KEY="" GOOGLE_PROXY_URL="" \
136136
# Groq
137137
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
138+
# Hunyuan
139+
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
138140
# Minimax
139141
MINIMAX_API_KEY="" \
140142
# Mistral

Dockerfile.database

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ ENV \
167167
GOOGLE_API_KEY="" GOOGLE_PROXY_URL="" \
168168
# Groq
169169
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
170+
# Hunyuan
171+
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
170172
# Minimax
171173
MINIMAX_API_KEY="" \
172174
# Mistral

src/app/(main)/settings/llm/ProviderList/providers.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
FireworksAIProviderCard,
1010
GoogleProviderCard,
1111
GroqProviderCard,
12+
HunyuanProviderCard,
1213
MinimaxProviderCard,
1314
MistralProviderCard,
1415
MoonshotProviderCard,
@@ -60,6 +61,7 @@ export const useProviderList = (): ProviderItem[] => {
6061
Ai21ProviderCard,
6162
UpstageProviderCard,
6263
QwenProviderCard,
64+
HunyuanProviderCard,
6365
SparkProviderCard,
6466
ZhiPuProviderCard,
6567
ZeroOneProviderCard,

src/app/api/chat/agentRuntime.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ const getLlmOptionsFromPayload = (provider: string, payload: JWTPayload) => {
244244

245245
const apiKey = apiKeyManager.pick(payload?.apiKey || AI21_API_KEY);
246246

247+
return { apiKey };
248+
}
249+
case ModelProvider.Hunyuan: {
250+
const { HUNYUAN_API_KEY } = getLLMConfig();
251+
252+
const apiKey = apiKeyManager.pick(payload?.apiKey || HUNYUAN_API_KEY);
253+
247254
return { apiKey };
248255
}
249256
}

src/config/llm.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ export const getLLMConfig = () => {
117117

118118
ENABLED_AI21: z.boolean(),
119119
AI21_API_KEY: z.string().optional(),
120+
121+
ENABLED_HUNYUAN: z.boolean(),
122+
HUNYUAN_API_KEY: z.string().optional(),
123+
HUNYUAN_MODEL_LIST: z.string().optional(),
120124
},
121125
runtimeEnv: {
122126
API_KEY_SELECT_MODE: process.env.API_KEY_SELECT_MODE,
@@ -231,6 +235,10 @@ export const getLLMConfig = () => {
231235

232236
ENABLED_AI21: !!process.env.AI21_API_KEY,
233237
AI21_API_KEY: process.env.AI21_API_KEY,
238+
239+
ENABLED_HUNYUAN: !!process.env.HUNYUAN_API_KEY,
240+
HUNYUAN_API_KEY: process.env.HUNYUAN_API_KEY,
241+
HUNYUAN_MODEL_LIST: process.env.HUNYUAN_MODEL_LIST,
234242
},
235243
});
236244
};

src/config/modelProviders/hunyuan.ts

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import { ModelProviderCard } from '@/types/llm';
2+
3+
// ref https://cloud.tencent.com/document/product/1729/104753
4+
const Hunyuan: ModelProviderCard = {
5+
chatModels: [
6+
{
7+
description: '升级为 MOE 结构,上下文窗口为 256k ,在 NLP,代码,数学,行业等多项评测集上领先众多开源模型。',
8+
displayName: 'Hunyuan Lite',
9+
enabled: true,
10+
id: 'hunyuan-lite',
11+
maxOutput: 6000,
12+
pricing: {
13+
currency: 'CNY',
14+
input: 0,
15+
output: 0,
16+
},
17+
tokens: 256_000,
18+
},
19+
{
20+
description: '采用更优的路由策略,同时缓解了负载均衡和专家趋同的问题。长文方面,大海捞针指标达到99.9%。MOE-32K 性价比相对更高,在平衡效果、价格的同时,可对实现对长文本输入的处理。',
21+
displayName: 'Hunyuan Standard',
22+
enabled: true,
23+
id: 'hunyuan-standard',
24+
maxOutput: 2000,
25+
pricing: {
26+
currency: 'CNY',
27+
input: 4.5,
28+
output: 5,
29+
},
30+
tokens: 32_000,
31+
},
32+
{
33+
description: '采用更优的路由策略,同时缓解了负载均衡和专家趋同的问题。长文方面,大海捞针指标达到99.9%。MOE-256K 在长度和效果上进一步突破,极大的扩展了可输入长度。',
34+
displayName: 'Hunyuan Standard 256K',
35+
enabled: true,
36+
id: 'hunyuan-standard-256K',
37+
maxOutput: 6000,
38+
pricing: {
39+
currency: 'CNY',
40+
input: 15,
41+
output: 60,
42+
},
43+
tokens: 256_000,
44+
},
45+
{
46+
description: '混元全新一代大语言模型的预览版,采用全新的混合专家模型(MoE)结构,相比hunyuan-pro推理效率更快,效果表现更强。',
47+
displayName: 'Hunyuan Turbo',
48+
enabled: true,
49+
functionCall: true,
50+
id: 'hunyuan-turbo',
51+
maxOutput: 4000,
52+
pricing: {
53+
currency: 'CNY',
54+
input: 15,
55+
output: 50,
56+
},
57+
tokens: 32_000,
58+
},
59+
{
60+
description: '万亿级参数规模 MOE-32K 长文模型。在各种 benchmark 上达到绝对领先的水平,复杂指令和推理,具备复杂数学能力,支持 functioncall,在多语言翻译、金融法律医疗等领域应用重点优化。',
61+
displayName: 'Hunyuan Pro',
62+
enabled: true,
63+
functionCall: true,
64+
id: 'hunyuan-pro',
65+
maxOutput: 4000,
66+
pricing: {
67+
currency: 'CNY',
68+
input: 30,
69+
output: 100,
70+
},
71+
tokens: 32_000,
72+
},
73+
{
74+
description: '混元最新代码生成模型,经过 200B 高质量代码数据增训基座模型,迭代半年高质量 SFT 数据训练,上下文长窗口长度增大到 8K,五大语言代码生成自动评测指标上位居前列;五大语言10项考量各方面综合代码任务人工高质量评测上,性能处于第一梯队',
75+
displayName: 'Hunyuan Code',
76+
enabled: true,
77+
id: 'hunyuan-code',
78+
maxOutput: 4000,
79+
pricing: {
80+
currency: 'CNY',
81+
input: 4,
82+
output: 8,
83+
},
84+
tokens: 8000,
85+
},
86+
{
87+
description: '混元最新多模态模型,支持图片+文本输入生成文本内容。',
88+
displayName: 'Hunyuan Vision',
89+
enabled: true,
90+
id: 'hunyuan-vision',
91+
maxOutput: 4000,
92+
pricing: {
93+
currency: 'CNY',
94+
input: 18,
95+
output: 18,
96+
},
97+
tokens: 8000,
98+
vision: true,
99+
},
100+
{
101+
description: '混元最新 MOE 架构 FunctionCall 模型,经过高质量的 FunctionCall 数据训练,上下文窗口达 32K,在多个维度的评测指标上处于领先。',
102+
displayName: 'Hunyuan FunctionCall',
103+
functionCall: true,
104+
id: 'hunyuan-functioncall',
105+
maxOutput: 4000,
106+
pricing: {
107+
currency: 'CNY',
108+
input: 4,
109+
output: 8,
110+
},
111+
tokens: 32_000,
112+
},
113+
{
114+
description: '混元最新版角色扮演模型,混元官方精调训练推出的角色扮演模型,基于混元模型结合角色扮演场景数据集进行增训,在角色扮演场景具有更好的基础效果。',
115+
displayName: 'Hunyuan Role',
116+
id: 'hunyuan-role',
117+
maxOutput: 4000,
118+
pricing: {
119+
currency: 'CNY',
120+
input: 4,
121+
output: 8,
122+
},
123+
tokens: 8000,
124+
},
125+
],
126+
checkModel: 'hunyuan-lite',
127+
description:
128+
'由腾讯研发的大语言模型,具备强大的中文创作能力,复杂语境下的逻辑推理能力,以及可靠的任务执行能力',
129+
disableBrowserRequest: true,
130+
id: 'hunyuan',
131+
modelList: { showModelFetcher: true },
132+
modelsUrl: 'https://cloud.tencent.com/document/product/1729/104753',
133+
name: 'Hunyuan',
134+
url: 'https://hunyuan.tencent.com',
135+
};
136+
137+
export default Hunyuan;

src/config/modelProviders/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FireworksAIProvider from './fireworksai';
1111
import GithubProvider from './github';
1212
import GoogleProvider from './google';
1313
import GroqProvider from './groq';
14+
import HunyuanProvider from './hunyuan';
1415
import MinimaxProvider from './minimax';
1516
import MistralProvider from './mistral';
1617
import MoonshotProvider from './moonshot';
@@ -57,6 +58,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
5758
UpstageProvider.chatModels,
5859
SparkProvider.chatModels,
5960
Ai21Provider.chatModels,
61+
HunyuanProvider.chatModels,
6062
].flat();
6163

6264
export const DEFAULT_MODEL_PROVIDER_LIST = [
@@ -78,6 +80,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
7880
Ai21Provider,
7981
UpstageProvider,
8082
QwenProvider,
83+
HunyuanProvider,
8184
SparkProvider,
8285
ZhiPuProvider,
8386
ZeroOneProvider,
@@ -110,6 +113,7 @@ export { default as FireworksAIProviderCard } from './fireworksai';
110113
export { default as GithubProviderCard } from './github';
111114
export { default as GoogleProviderCard } from './google';
112115
export { default as GroqProviderCard } from './groq';
116+
export { default as HunyuanProviderCard } from './hunyuan';
113117
export { default as MinimaxProviderCard } from './minimax';
114118
export { default as MistralProviderCard } from './mistral';
115119
export { default as MoonshotProviderCard } from './moonshot';

src/const/settings/llm.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
GithubProviderCard,
1010
GoogleProviderCard,
1111
GroqProviderCard,
12+
HunyuanProviderCard,
1213
MinimaxProviderCard,
1314
MistralProviderCard,
1415
MoonshotProviderCard,
@@ -75,6 +76,10 @@ export const DEFAULT_LLM_CONFIG: UserModelProviderConfig = {
7576
enabled: false,
7677
enabledModels: filterEnabledModels(GroqProviderCard),
7778
},
79+
hunyuan: {
80+
enabled: false,
81+
enabledModels: filterEnabledModels(HunyuanProviderCard),
82+
},
7883
minimax: {
7984
enabled: false,
8085
enabledModels: filterEnabledModels(MinimaxProviderCard),

src/libs/agent-runtime/AgentRuntime.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { LobeFireworksAI } from './fireworksai';
1414
import { LobeGithubAI } from './github';
1515
import { LobeGoogleAI } from './google';
1616
import { LobeGroq } from './groq';
17+
import { LobeHunyuanAI } from './hunyuan';
1718
import { LobeMinimaxAI } from './minimax';
1819
import { LobeMistralAI } from './mistral';
1920
import { LobeMoonshotAI } from './moonshot';
@@ -133,6 +134,7 @@ class AgentRuntime {
133134
github: Partial<ClientOptions>;
134135
google: { apiKey?: string; baseURL?: string };
135136
groq: Partial<ClientOptions>;
137+
hunyuan: Partial<ClientOptions>;
136138
minimax: Partial<ClientOptions>;
137139
mistral: Partial<ClientOptions>;
138140
moonshot: Partial<ClientOptions>;
@@ -300,6 +302,11 @@ class AgentRuntime {
300302
runtimeModel = new LobeAi21AI(params.ai21);
301303
break;
302304
}
305+
306+
case ModelProvider.Hunyuan: {
307+
runtimeModel = new LobeHunyuanAI(params.hunyuan);
308+
break;
309+
}
303310
}
304311

305312
return new AgentRuntime(runtimeModel);

0 commit comments

Comments
 (0)