Skip to content

Commit b27d344

Browse files
hezhijie0327bentwnghk
authored andcommitted
💄 style: add kimi-latest for Moonshot (lobehub#6295)
* 💄 style: add `kimi-latest` for Moonshot * 💄 style: update model list * 💄 style: update model desc and cachedInput * 💄 style: fix no model enabled * 💄 style: update check model
1 parent 91ed11a commit b27d344

File tree

3 files changed

+73
-14
lines changed

3 files changed

+73
-14
lines changed

src/config/aiModels/moonshot.ts

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
import { AIChatModelCard } from '@/types/aiModel';
22

33
const moonshotChatModels: AIChatModelCard[] = [
4+
{
5+
abilities: {
6+
functionCall: true,
7+
vision: true,
8+
},
9+
contextWindowTokens: 131_072,
10+
description:
11+
'Kimi 智能助手产品使用最新的 Kimi 大模型,可能包含尚未稳定的特性。支持图片理解,同时会自动根据请求的上下文长度选择 8k/32k/128k 模型作为计费模型',
12+
displayName: 'Kimi Latest',
13+
enabled: true,
14+
id: 'kimi-latest',
15+
pricing: {
16+
cachedInput: 1,
17+
currency: 'CNY',
18+
input: 60,
19+
output: 60,
20+
},
21+
releasedAt: '2025-02-17',
22+
type: 'chat',
23+
},
24+
{
25+
abilities: {
26+
functionCall: true,
27+
},
28+
contextWindowTokens: 131_072,
29+
description:
30+
'Moonshot V1 Auto 可以根据当前上下文占用的 Tokens 数量来选择合适的模型',
31+
displayName: 'Moonshot V1 Auto',
32+
id: 'moonshot-v1-auto',
33+
pricing: {
34+
currency: 'CNY',
35+
input: 60,
36+
output: 60,
37+
},
38+
type: 'chat',
39+
},
440
{
541
abilities: {
642
functionCall: true,
@@ -9,7 +45,6 @@ const moonshotChatModels: AIChatModelCard[] = [
945
description:
1046
'Moonshot V1 8K 专为生成短文本任务设计,具有高效的处理性能,能够处理8,192个tokens,非常适合简短对话、速记和快速内容生成。',
1147
displayName: 'Moonshot V1 8K',
12-
enabled: true,
1348
id: 'moonshot-v1-8k',
1449
pricing: {
1550
currency: 'CNY',
@@ -26,7 +61,6 @@ const moonshotChatModels: AIChatModelCard[] = [
2661
description:
2762
'Moonshot V1 32K 提供中等长度的上下文处理能力,能够处理32,768个tokens,特别适合生成各种长文档和复杂对话,应用于内容创作、报告生成和对话系统等领域。',
2863
displayName: 'Moonshot V1 32K',
29-
enabled: true,
3064
id: 'moonshot-v1-32k',
3165
pricing: {
3266
currency: 'CNY',
@@ -43,7 +77,6 @@ const moonshotChatModels: AIChatModelCard[] = [
4377
description:
4478
'Moonshot V1 128K 是一款拥有超长上下文处理能力的模型,适用于生成超长文本,满足复杂的生成任务需求,能够处理多达128,000个tokens的内容,非常适合科研、学术和大型文档生成等应用场景。',
4579
displayName: 'Moonshot V1 128K',
46-
enabled: true,
4780
id: 'moonshot-v1-128k',
4881
pricing: {
4982
currency: 'CNY',
@@ -61,7 +94,6 @@ const moonshotChatModels: AIChatModelCard[] = [
6194
description:
6295
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
6396
displayName: 'Moonshot V1 8K Vision Preview',
64-
enabled: true,
6597
id: 'moonshot-v1-8k-vision-preview',
6698
pricing: {
6799
currency: 'CNY',
@@ -80,7 +112,6 @@ const moonshotChatModels: AIChatModelCard[] = [
80112
description:
81113
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
82114
displayName: 'Moonshot V1 32K Vision Preview',
83-
enabled: true,
84115
id: 'moonshot-v1-32k-vision-preview',
85116
pricing: {
86117
currency: 'CNY',
@@ -99,7 +130,6 @@ const moonshotChatModels: AIChatModelCard[] = [
99130
description:
100131
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
101132
displayName: 'Moonshot V1 128K Vision Preview',
102-
enabled: true,
103133
id: 'moonshot-v1-128k-vision-preview',
104134
pricing: {
105135
currency: 'CNY',

src/config/modelProviders/moonshot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Moonshot: ModelProviderCard = {
4646
},
4747
},
4848
],
49-
checkModel: 'moonshot-v1-8k',
49+
checkModel: 'kimi-latest',
5050
description:
5151
'Moonshot 是由北京月之暗面科技有限公司推出的开源平台,提供多种自然语言处理模型,应用领域广泛,包括但不限于内容创作、学术研究、智能推荐、医疗诊断等,支持长文本处理和复杂生成任务。',
5252
id: 'moonshot',

src/libs/agent-runtime/moonshot/index.ts

+36-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,42 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({
2828
transformModel: (m) => {
2929
const model = m as unknown as MoonshotModelCard;
3030

31-
return {
32-
enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false,
33-
functionCall: true,
34-
id: model.id,
35-
vision: model.id.toLowerCase().includes('vision'),
36-
};
37-
},
31+
const functionCallKeywords = [
32+
'moonshot-v1',
33+
'kimi-latest',
34+
]
35+
36+
const visionKeywords = [
37+
'kimi-latest',
38+
'vision',
39+
]
40+
41+
const modelsPage = await client.models.list() as any;
42+
const modelList: MoonshotModelCard[] = modelsPage.data;
43+
44+
return modelList
45+
.map((model) => {
46+
const knownModel = LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.toLowerCase() === m.id.toLowerCase());
47+
48+
return {
49+
contextWindowTokens: knownModel?.contextWindowTokens ?? undefined,
50+
displayName: knownModel?.displayName ?? undefined,
51+
enabled: knownModel?.enabled || false,
52+
functionCall:
53+
functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword))
54+
|| knownModel?.abilities?.functionCall
55+
|| false,
56+
id: model.id,
57+
reasoning:
58+
knownModel?.abilities?.reasoning
59+
|| false,
60+
vision:
61+
visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword))
62+
|| knownModel?.abilities?.vision
63+
|| false,
64+
};
65+
})
66+
.filter(Boolean) as ChatModelCard[];
3867
},
3968
provider: ModelProvider.Moonshot,
4069
});

0 commit comments

Comments
 (0)