mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Moonshot AI China model metadata to include Kimi K2.7 Code, and omitted unsupported thinking-off payloads for Kimi K2.7 Code models ([#5760](https://github.com/earendil-works/pi/issues/5760)).
|
||||
|
||||
## [0.79.4] - 2026-06-15
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -68,6 +68,8 @@ const KIMI_STATIC_HEADERS = {
|
||||
"User-Agent": "KimiCLI/1.5",
|
||||
} as const;
|
||||
|
||||
const MOONSHOT_CN_MIRRORED_MODEL_IDS = new Set(["kimi-k2.7-code", "kimi-k2.7-code-highspeed"]);
|
||||
|
||||
const TOGETHER_BASE_URL = "https://api.together.ai/v1";
|
||||
const TOGETHER_BASE_COMPAT: OpenAICompletionsCompat = {
|
||||
supportsStore: false,
|
||||
@@ -347,6 +349,15 @@ function applyThinkingLevelMetadata(model: Model<any>): void {
|
||||
if (model.provider === "openai-codex" && supportsOpenAiXhigh(model.id)) {
|
||||
mergeThinkingLevelMap(model, { minimal: "low" });
|
||||
}
|
||||
if (
|
||||
(model.provider === "moonshotai" || model.provider === "moonshotai-cn") &&
|
||||
(model.id === "kimi-k2.7-code" || model.id === "kimi-k2.7-code-highspeed")
|
||||
) {
|
||||
// Kimi K2.7 Code is always-thinking. Official docs say
|
||||
// `thinking: { type: "disabled" }` is rejected, and callers can omit
|
||||
// the thinking parameter to use the enabled default.
|
||||
mergeThinkingLevelMap(model, { off: null });
|
||||
}
|
||||
if (model.provider === "openrouter" && model.id.startsWith("inception/mercury-2")) {
|
||||
// Mercury 2 in instant mode (reasoning_effort: "none") disables tool calling.
|
||||
// Mark "off" unsupported so the openai-completions provider omits the reasoning param
|
||||
@@ -1262,12 +1273,27 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
|
||||
supportsStrictMode: false,
|
||||
thinkingFormat: "deepseek",
|
||||
};
|
||||
const getMoonshotProviderModels = (key: "moonshotai" | "moonshotai-cn"): Record<string, ModelsDevModel> => {
|
||||
const providerModels = data[key]?.models as Record<string, ModelsDevModel> | undefined;
|
||||
return providerModels ? { ...providerModels } : {};
|
||||
};
|
||||
const moonshotModels = {
|
||||
moonshotai: getMoonshotProviderModels("moonshotai"),
|
||||
"moonshotai-cn": getMoonshotProviderModels("moonshotai-cn"),
|
||||
};
|
||||
|
||||
// models.dev can lag the CN catalog while the global Moonshot catalog already
|
||||
// has the model. Mirror selected current model IDs into moonshotai-cn until
|
||||
// upstream CN metadata catches up.
|
||||
for (const modelId of MOONSHOT_CN_MIRRORED_MODEL_IDS) {
|
||||
const model = moonshotModels.moonshotai[modelId];
|
||||
if (model && !moonshotModels["moonshotai-cn"][modelId]) {
|
||||
moonshotModels["moonshotai-cn"][modelId] = model;
|
||||
}
|
||||
}
|
||||
|
||||
for (const { key, provider, baseUrl } of moonshotVariants) {
|
||||
if (!data[key]?.models) continue;
|
||||
|
||||
for (const [modelId, model] of Object.entries(data[key].models)) {
|
||||
const m = model as ModelsDevModel;
|
||||
for (const [modelId, m] of Object.entries(moonshotModels[key])) {
|
||||
if (m.tool_call !== true) continue;
|
||||
|
||||
models.push({
|
||||
|
||||
@@ -6425,6 +6425,7 @@ export const MODELS = {
|
||||
baseUrl: "https://api.moonshot.ai/v1",
|
||||
compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":false,"maxTokensField":"max_tokens","supportsStrictMode":false,"thinkingFormat":"deepseek"},
|
||||
reasoning: true,
|
||||
thinkingLevelMap: {"off":null},
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 0.95,
|
||||
@@ -6563,6 +6564,25 @@ export const MODELS = {
|
||||
contextWindow: 262144,
|
||||
maxTokens: 262144,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"kimi-k2.7-code": {
|
||||
id: "kimi-k2.7-code",
|
||||
name: "Kimi K2.7 Code",
|
||||
api: "openai-completions",
|
||||
provider: "moonshotai-cn",
|
||||
baseUrl: "https://api.moonshot.cn/v1",
|
||||
compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":false,"maxTokensField":"max_tokens","supportsStrictMode":false,"thinkingFormat":"deepseek"},
|
||||
reasoning: true,
|
||||
thinkingLevelMap: {"off":null},
|
||||
input: ["text", "image"],
|
||||
cost: {
|
||||
input: 0.95,
|
||||
output: 4,
|
||||
cacheRead: 0.19,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
maxTokens: 262144,
|
||||
} satisfies Model<"openai-completions">,
|
||||
},
|
||||
"nvidia": {
|
||||
"meta/llama-3.1-70b-instruct": {
|
||||
|
||||
@@ -564,7 +564,11 @@ function buildParams(
|
||||
preserve_thinking: true,
|
||||
};
|
||||
} else if (compat.thinkingFormat === "deepseek" && model.reasoning) {
|
||||
(params as any).thinking = { type: options?.reasoningEffort ? "enabled" : "disabled" };
|
||||
if (options?.reasoningEffort) {
|
||||
(params as any).thinking = { type: "enabled" };
|
||||
} else if (model.thinkingLevelMap?.off !== null) {
|
||||
(params as any).thinking = { type: "disabled" };
|
||||
}
|
||||
if (options?.reasoningEffort && compat.supportsReasoningEffort) {
|
||||
(params as any).reasoning_effort =
|
||||
model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
|
||||
|
||||
@@ -1118,6 +1118,54 @@ describe("openai-completions tool_choice", () => {
|
||||
expect(params.reasoning_effort).toBeUndefined();
|
||||
});
|
||||
|
||||
it("omits disabled thinking for Moonshot Kimi K2.7 Code models", async () => {
|
||||
const cases = [getModel("moonshotai", "kimi-k2.7-code"), getModel("moonshotai-cn", "kimi-k2.7-code")];
|
||||
|
||||
for (const model of cases) {
|
||||
expect(model).toBeDefined();
|
||||
let payload: unknown;
|
||||
|
||||
await streamSimple(
|
||||
model!,
|
||||
{
|
||||
messages: [{ role: "user", content: "Hi", timestamp: Date.now() }],
|
||||
},
|
||||
{
|
||||
apiKey: "test",
|
||||
onPayload: (params: unknown) => {
|
||||
payload = params;
|
||||
},
|
||||
},
|
||||
).result();
|
||||
|
||||
const params = (payload ?? mockState.lastParams) as { thinking?: unknown; reasoning_effort?: string };
|
||||
expect(params.thinking).toBeUndefined();
|
||||
expect(params.reasoning_effort).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps disabled thinking for Moonshot Kimi K2.6 when thinking is off", async () => {
|
||||
const model = getModel("moonshotai-cn", "kimi-k2.6")!;
|
||||
let payload: unknown;
|
||||
|
||||
await streamSimple(
|
||||
model,
|
||||
{
|
||||
messages: [{ role: "user", content: "Hi", timestamp: Date.now() }],
|
||||
},
|
||||
{
|
||||
apiKey: "test",
|
||||
onPayload: (params: unknown) => {
|
||||
payload = params;
|
||||
},
|
||||
},
|
||||
).result();
|
||||
|
||||
const params = (payload ?? mockState.lastParams) as { thinking?: unknown; reasoning_effort?: string };
|
||||
expect(params.thinking).toEqual({ type: "disabled" });
|
||||
expect(params.reasoning_effort).toBeUndefined();
|
||||
});
|
||||
|
||||
it("sends max_tokens for OpenCode completions models", async () => {
|
||||
const cases = [getModel("opencode-go", "kimi-k2.6")!, getModel("opencode", "grok-build-0.1")!] as const;
|
||||
|
||||
|
||||
@@ -69,6 +69,15 @@ describe("getSupportedThinkingLevels", () => {
|
||||
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high"]);
|
||||
});
|
||||
|
||||
it("excludes thinking off for Moonshot Kimi K2.7 Code models", () => {
|
||||
const cases = [getModel("moonshotai", "kimi-k2.7-code"), getModel("moonshotai-cn", "kimi-k2.7-code")];
|
||||
|
||||
for (const model of cases) {
|
||||
expect(model).toBeDefined();
|
||||
expect(getSupportedThinkingLevels(model!)).toEqual(["minimal", "low", "medium", "high"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("includes only high for OpenCode Grok Build", () => {
|
||||
const model = getModel("opencode", "grok-build-0.1");
|
||||
expect(model).toBeDefined();
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed inherited Moonshot AI China model metadata to include Kimi K2.7 Code, and omitted unsupported thinking-off payloads for Kimi K2.7 Code models ([#5760](https://github.com/earendil-works/pi/issues/5760)).
|
||||
|
||||
## [0.79.4] - 2026-06-15
|
||||
|
||||
### New Features
|
||||
|
||||
Reference in New Issue
Block a user