fix: sync Moonshot Kimi K2 models (#818) (thanks @mickahouan)
Co-authored-by: mickahouan <mickahouan@users.noreply.github.com>
This commit is contained in:
39
ui/src/ui/data/moonshot-kimi-k2.ts
Normal file
39
ui/src/ui/data/moonshot-kimi-k2.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export const MOONSHOT_KIMI_K2_DEFAULT_ID = "kimi-k2-0905-preview";
|
||||
export const MOONSHOT_KIMI_K2_CONTEXT_WINDOW = 256000;
|
||||
export const MOONSHOT_KIMI_K2_MAX_TOKENS = 8192;
|
||||
export const MOONSHOT_KIMI_K2_INPUT = ["text"] as const;
|
||||
export const MOONSHOT_KIMI_K2_COST = {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
} as const;
|
||||
|
||||
export const MOONSHOT_KIMI_K2_MODELS = [
|
||||
{
|
||||
id: "kimi-k2-0905-preview",
|
||||
name: "Kimi K2 0905 Preview",
|
||||
alias: "Kimi K2",
|
||||
reasoning: false,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-turbo-preview",
|
||||
name: "Kimi K2 Turbo",
|
||||
alias: "Kimi K2 Turbo",
|
||||
reasoning: false,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-thinking",
|
||||
name: "Kimi K2 Thinking",
|
||||
alias: "Kimi K2 Thinking",
|
||||
reasoning: true,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-thinking-turbo",
|
||||
name: "Kimi K2 Thinking Turbo",
|
||||
alias: "Kimi K2 Thinking Turbo",
|
||||
reasoning: true,
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type MoonshotKimiK2Model = (typeof MOONSHOT_KIMI_K2_MODELS)[number];
|
||||
@@ -173,6 +173,12 @@ describe("config view", () => {
|
||||
const raw = String(onRawChange.mock.calls.at(-1)?.[0] ?? "");
|
||||
expect(raw).toContain("https://api.moonshot.ai/v1");
|
||||
expect(raw).toContain("moonshot/kimi-k2-0905-preview");
|
||||
expect(raw).toContain("moonshot/kimi-k2-turbo-preview");
|
||||
expect(raw).toContain("moonshot/kimi-k2-thinking");
|
||||
expect(raw).toContain("moonshot/kimi-k2-thinking-turbo");
|
||||
expect(raw).toContain("Kimi K2 Turbo");
|
||||
expect(raw).toContain("Kimi K2 Thinking");
|
||||
expect(raw).toContain("Kimi K2 Thinking Turbo");
|
||||
expect(raw).toContain("MOONSHOT_API_KEY");
|
||||
expect(onFormPatch).toHaveBeenCalledWith(
|
||||
["agents", "defaults", "model", "primary"],
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import { html, nothing } from "lit";
|
||||
import {
|
||||
MOONSHOT_KIMI_K2_CONTEXT_WINDOW,
|
||||
MOONSHOT_KIMI_K2_COST,
|
||||
MOONSHOT_KIMI_K2_DEFAULT_ID,
|
||||
MOONSHOT_KIMI_K2_INPUT,
|
||||
MOONSHOT_KIMI_K2_MAX_TOKENS,
|
||||
MOONSHOT_KIMI_K2_MODELS,
|
||||
} from "../data/moonshot-kimi-k2";
|
||||
import type { ConfigUiHints } from "../types";
|
||||
import { analyzeConfigSchema, renderConfigForm } from "./config-form";
|
||||
|
||||
@@ -265,67 +273,27 @@ function buildModelPresetPatches(base: Record<string, unknown>): Array<{
|
||||
value: "openai-completions",
|
||||
});
|
||||
}
|
||||
const moonshotModelDefinitions = MOONSHOT_KIMI_K2_MODELS.map((model) => ({
|
||||
id: model.id,
|
||||
name: model.name,
|
||||
reasoning: model.reasoning,
|
||||
input: [...MOONSHOT_KIMI_K2_INPUT],
|
||||
cost: { ...MOONSHOT_KIMI_K2_COST },
|
||||
contextWindow: MOONSHOT_KIMI_K2_CONTEXT_WINDOW,
|
||||
maxTokens: MOONSHOT_KIMI_K2_MAX_TOKENS,
|
||||
}));
|
||||
|
||||
if (!moonshotHasModels) {
|
||||
moonshot.push({
|
||||
path: moonshotModelsPath as Array<string | number>,
|
||||
value: [
|
||||
{
|
||||
id: "kimi-k2-0905-preview",
|
||||
name: "Kimi K2 0905 Preview",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 256000,
|
||||
maxTokens: 8192,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-turbo-preview",
|
||||
name: "Kimi K2 Turbo",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 256000,
|
||||
maxTokens: 8192,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-thinking",
|
||||
name: "Kimi K2 Thinking",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 256000,
|
||||
maxTokens: 8192,
|
||||
},
|
||||
{
|
||||
id: "kimi-k2-thinking-turbo",
|
||||
name: "Kimi K2 Thinking Turbo",
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 256000,
|
||||
maxTokens: 8192,
|
||||
},
|
||||
],
|
||||
value: moonshotModelDefinitions,
|
||||
});
|
||||
}
|
||||
moonshot.push(setPrimary("moonshot/kimi-k2-0905-preview"));
|
||||
const moonshotAlias = safeAlias("moonshot/kimi-k2-0905-preview", "Kimi K2");
|
||||
if (moonshotAlias) moonshot.push(moonshotAlias);
|
||||
const moonshotTurboAlias = safeAlias(
|
||||
"moonshot/kimi-k2-turbo-preview",
|
||||
"Kimi K2 Turbo",
|
||||
);
|
||||
if (moonshotTurboAlias) moonshot.push(moonshotTurboAlias);
|
||||
const moonshotThinkingAlias = safeAlias(
|
||||
"moonshot/kimi-k2-thinking",
|
||||
"Kimi K2 Thinking",
|
||||
);
|
||||
if (moonshotThinkingAlias) moonshot.push(moonshotThinkingAlias);
|
||||
const moonshotThinkingTurboAlias = safeAlias(
|
||||
"moonshot/kimi-k2-thinking-turbo",
|
||||
"Kimi K2 Thinking Turbo",
|
||||
);
|
||||
if (moonshotThinkingTurboAlias) moonshot.push(moonshotThinkingTurboAlias);
|
||||
moonshot.push(setPrimary(`moonshot/${MOONSHOT_KIMI_K2_DEFAULT_ID}`));
|
||||
for (const model of MOONSHOT_KIMI_K2_MODELS) {
|
||||
const moonshotAlias = safeAlias(`moonshot/${model.id}`, model.alias);
|
||||
if (moonshotAlias) moonshot.push(moonshotAlias);
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user