mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-12 23:01:21 +00:00
fix: override Kimi-K2 context window to 131K to match OpenRouter advertised specs
- OpenRouter API returns 63K for moonshotai/kimi-k2 but their website shows 131K - Added manual override in parseOpenRouterModel to set correct context window - Added test to verify the override works correctly Fixes #6759
This commit is contained in:
parent
2b647ed9a1
commit
a324a9d927
2 changed files with 31 additions and 0 deletions
|
|
@ -332,5 +332,30 @@ describe("OpenRouter API", () => {
|
|||
expect(result.maxTokens).toBe(64000)
|
||||
expect(result.contextWindow).toBe(128000)
|
||||
})
|
||||
|
||||
it("overrides kimi-k2 model context window to 131K", () => {
|
||||
const mockModel = {
|
||||
name: "MoonshotAI: Kimi K2",
|
||||
description: "Kimi K2 model",
|
||||
context_length: 63000, // API returns 63K
|
||||
max_completion_tokens: null,
|
||||
pricing: {
|
||||
prompt: "0.000003",
|
||||
completion: "0.000015",
|
||||
},
|
||||
}
|
||||
|
||||
const result = parseOpenRouterModel({
|
||||
id: "moonshotai/kimi-k2",
|
||||
model: mockModel,
|
||||
modality: "text",
|
||||
maxTokens: null,
|
||||
})
|
||||
|
||||
// Should override to 131K (131072) instead of using the API's 63K
|
||||
expect(result.contextWindow).toBe(131072)
|
||||
// Max tokens should be calculated as 20% of context window
|
||||
expect(result.maxTokens).toBe(Math.ceil(63000 * 0.2)) // Still uses original for maxTokens calculation
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -247,5 +247,11 @@ export const parseOpenRouterModel = ({
|
|||
modelInfo.maxTokens = 32768
|
||||
}
|
||||
|
||||
// Override kimi-k2 context window to match OpenRouter's advertised 131K
|
||||
// The API returns 63K but the website shows 131K
|
||||
if (id === "moonshotai/kimi-k2") {
|
||||
modelInfo.contextWindow = 131072
|
||||
}
|
||||
|
||||
return modelInfo
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue