Skip to content

Commit

Permalink
💄 style: add kimi-latest for Moonshot (lobehub#6295)
Browse files Browse the repository at this point in the history
* 💄 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
  • Loading branch information
hezhijie0327 authored and bentwnghk committed Feb 20, 2025
1 parent 91ed11a commit b27d344
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 14 deletions.
42 changes: 36 additions & 6 deletions src/config/aiModels/moonshot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
import { AIChatModelCard } from '@/types/aiModel';

const moonshotChatModels: AIChatModelCard[] = [
{
abilities: {
functionCall: true,
vision: true,
},
contextWindowTokens: 131_072,
description:
'Kimi 智能助手产品使用最新的 Kimi 大模型,可能包含尚未稳定的特性。支持图片理解,同时会自动根据请求的上下文长度选择 8k/32k/128k 模型作为计费模型',
displayName: 'Kimi Latest',
enabled: true,
id: 'kimi-latest',
pricing: {
cachedInput: 1,
currency: 'CNY',
input: 60,
output: 60,
},
releasedAt: '2025-02-17',
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description:
'Moonshot V1 Auto 可以根据当前上下文占用的 Tokens 数量来选择合适的模型',
displayName: 'Moonshot V1 Auto',
id: 'moonshot-v1-auto',
pricing: {
currency: 'CNY',
input: 60,
output: 60,
},
type: 'chat',
},
{
abilities: {
functionCall: true,
Expand All @@ -9,7 +45,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Moonshot V1 8K 专为生成短文本任务设计,具有高效的处理性能,能够处理8,192个tokens,非常适合简短对话、速记和快速内容生成。',
displayName: 'Moonshot V1 8K',
enabled: true,
id: 'moonshot-v1-8k',
pricing: {
currency: 'CNY',
Expand All @@ -26,7 +61,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Moonshot V1 32K 提供中等长度的上下文处理能力,能够处理32,768个tokens,特别适合生成各种长文档和复杂对话,应用于内容创作、报告生成和对话系统等领域。',
displayName: 'Moonshot V1 32K',
enabled: true,
id: 'moonshot-v1-32k',
pricing: {
currency: 'CNY',
Expand All @@ -43,7 +77,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Moonshot V1 128K 是一款拥有超长上下文处理能力的模型,适用于生成超长文本,满足复杂的生成任务需求,能够处理多达128,000个tokens的内容,非常适合科研、学术和大型文档生成等应用场景。',
displayName: 'Moonshot V1 128K',
enabled: true,
id: 'moonshot-v1-128k',
pricing: {
currency: 'CNY',
Expand All @@ -61,7 +94,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
displayName: 'Moonshot V1 8K Vision Preview',
enabled: true,
id: 'moonshot-v1-8k-vision-preview',
pricing: {
currency: 'CNY',
Expand All @@ -80,7 +112,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
displayName: 'Moonshot V1 32K Vision Preview',
enabled: true,
id: 'moonshot-v1-32k-vision-preview',
pricing: {
currency: 'CNY',
Expand All @@ -99,7 +130,6 @@ const moonshotChatModels: AIChatModelCard[] = [
description:
'Kimi 视觉模型(包括 moonshot-v1-8k-vision-preview/moonshot-v1-32k-vision-preview/moonshot-v1-128k-vision-preview 等)能够理解图片内容,包括图片文字、图片颜色和物体形状等内容。',
displayName: 'Moonshot V1 128K Vision Preview',
enabled: true,
id: 'moonshot-v1-128k-vision-preview',
pricing: {
currency: 'CNY',
Expand Down
2 changes: 1 addition & 1 deletion src/config/modelProviders/moonshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Moonshot: ModelProviderCard = {
},
},
],
checkModel: 'moonshot-v1-8k',
checkModel: 'kimi-latest',
description:
'Moonshot 是由北京月之暗面科技有限公司推出的开源平台,提供多种自然语言处理模型,应用领域广泛,包括但不限于内容创作、学术研究、智能推荐、医疗诊断等,支持长文本处理和复杂生成任务。',
id: 'moonshot',
Expand Down
43 changes: 36 additions & 7 deletions src/libs/agent-runtime/moonshot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,42 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({
transformModel: (m) => {
const model = m as unknown as MoonshotModelCard;

return {
enabled: LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.endsWith(m.id))?.enabled || false,
functionCall: true,
id: model.id,
vision: model.id.toLowerCase().includes('vision'),
};
},
const functionCallKeywords = [
'moonshot-v1',
'kimi-latest',
]

const visionKeywords = [
'kimi-latest',
'vision',
]

const modelsPage = await client.models.list() as any;
const modelList: MoonshotModelCard[] = modelsPage.data;

return modelList
.map((model) => {
const knownModel = LOBE_DEFAULT_MODEL_LIST.find((m) => model.id.toLowerCase() === m.id.toLowerCase());

return {
contextWindowTokens: knownModel?.contextWindowTokens ?? undefined,
displayName: knownModel?.displayName ?? undefined,
enabled: knownModel?.enabled || false,
functionCall:
functionCallKeywords.some(keyword => model.id.toLowerCase().includes(keyword))
|| knownModel?.abilities?.functionCall
|| false,
id: model.id,
reasoning:
knownModel?.abilities?.reasoning
|| false,
vision:
visionKeywords.some(keyword => model.id.toLowerCase().includes(keyword))
|| knownModel?.abilities?.vision
|| false,
};
})
.filter(Boolean) as ChatModelCard[];
},
provider: ModelProvider.Moonshot,
});

0 comments on commit b27d344

Please sign in to comment.