Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

Fix Kimi temperature compatibility

nash_su5716351bd9f2
diff --git a/src/lib/__tests__/llm-providers.test.ts b/src/lib/__tests__/llm-providers.test.ts
index 76c13161..ab2691ff 100644
--- a/src/lib/__tests__/llm-providers.test.ts
+++ b/src/lib/__tests__/llm-providers.test.ts
@@ -370,6 +370,22 @@ describe("Sampling override translation across wires", () => {
expect(body.max_completion_tokens).toBeUndefined()
})
+ it("custom Kimi routes strip unsupported temperature overrides", () => {
+ const cfg = getProviderConfig({
+ provider: "custom",
+ apiKey: "k",
+ model: "kimi-k2.6",
+ ollamaUrl: "",
+ customEndpoint: "https://api.moonshot.ai/v1",
+ apiMode: "chat_completions",
+ maxContextSize: 256000,
+ })
+ const body = cfg.buildBody(baseMessages, { temperature: 0.1, max_tokens: 4096 }) as Record<string, unknown>
+
+ expect(body.temperature).toBeUndefined()
+ expect(body.max_tokens).toBe(4096)
+ })
+
it("Anthropic maps stop → stop_sequences and respects max_tokens override", () => {
const cfg = getProviderConfig({
provider: "anthropic",
diff --git a/src/lib/llm-providers.test.ts b/src/lib/llm-providers.test.ts
index 3f1cb708..5eee3d14 100644
--- a/src/lib/llm-providers.test.ts
+++ b/src/lib/llm-providers.test.ts
@@ -226,6 +226,22 @@ describe("reasoning controls", () => {
expect(body.chat_template_kwargs).toEqual({ enable_thinking: false })
})
+ it("strips temperature for Kimi/Moonshot OpenAI-compatible endpoints", () => {
+ const cfg = mkConfig({
+ provider: "custom",
+ model: "kimi-k2.6",
+ customEndpoint: "https://api.moonshot.ai/v1",
+ apiMode: "chat_completions",
+ })
+ const body = getProviderConfig(cfg).buildBody(
+ [{ role: "user", content: "hi" }],
+ { temperature: 0.1, max_tokens: 4096 },
+ ) as Record<string, unknown>
+
+ expect(body.temperature).toBeUndefined()
+ expect(body.max_tokens).toBe(4096)
+ })
+
it("maps Anthropic reasoning budget to extended thinking and removes sampling knobs", () => {
const cfg = mkConfig({ provider: "anthropic", model: "claude-sonnet-4-5-20250929" })
const body = getProviderConfig(cfg).buildBody(
diff --git a/src/lib/llm-providers.ts b/src/lib/llm-providers.ts
index 195445e7..8a94a8de 100644
--- a/src/lib/llm-providers.ts
+++ b/src/lib/llm-providers.ts
@@ -239,6 +239,12 @@ function isQwenThinkingModel(model: string): boolean {
return /qwen[-_]?3/i.test(model)
}
+function isKimiEndpoint(config: LlmConfig): boolean {
+ return /(^|[/:.-])kimi([/:.-]|$)/i.test(config.model)
+ || /moonshot/i.test(config.model)
+ || /api\.moonshot\.(ai|cn)/i.test(config.customEndpoint)
+}
+
function isOpenAiStrictCompletionModel(config: LlmConfig): boolean {
if (config.provider !== "openai") return false
const model = config.model.trim().toLowerCase()
@@ -262,6 +268,16 @@ function adaptOpenAiStrictCompletionBody(config: LlmConfig, body: Record<string,
delete body.top_k
}
+function adaptKimiBody(config: LlmConfig, body: Record<string, unknown>): void {
+ if (!isKimiEndpoint(config)) return
+
+ // Moonshot/Kimi OpenAI-compatible endpoints reject non-default
+ // temperature values for several current models ("only 1 is allowed").
+ // Structured ingest/dedup pass temperature=0.1 for determinism, so
+ // omit it and let the endpoint use its required default.
+ delete body.temperature
+}
+
function buildOpenAiCompatibleBody(
config: LlmConfig,
messages: ChatMessage[],
@@ -270,6 +286,7 @@ function buildOpenAiCompatibleBody(
const reasoning = effectiveReasoning(config, overrides)
const body: Record<string, unknown> = buildOpenAiBody(messages, stripWireAgnosticOverrides(overrides))
adaptOpenAiStrictCompletionBody(config, body)
+ adaptKimiBody(config, body)
if (isDeepSeekEndpoint(config)) {
// DeepSeek V4 thinking mode. `thinking.type=disabled` is the most