mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix(minimax): pass through custom model IDs with default info fallback
Previously, unknown model IDs were silently replaced with the default model ID in both backend getModel() and ignored in the frontend useSelectedModel hook (returning undefined info, causing context window to display as 1). Now custom/unknown model IDs are preserved for API calls while falling back to the default model info for context window and pricing metadata.
This commit is contained in:
parent
b19f2eed99
commit
418a4bf1c5
4 changed files with 29 additions and 3 deletions
|
|
@ -196,6 +196,16 @@ describe("MiniMaxHandler", () => {
|
|||
const model = handlerDefault.getModel()
|
||||
expect(model.id).toBe("MiniMax-M2.7")
|
||||
})
|
||||
|
||||
it("should pass through unknown model ID and fall back to default model info", () => {
|
||||
const handlerCustom = new MiniMaxHandler({
|
||||
minimaxApiKey: "test-minimax-api-key",
|
||||
apiModelId: "some-future-minimax-model",
|
||||
})
|
||||
const model = handlerCustom.getModel()
|
||||
expect(model.id).toBe("some-future-minimax-model")
|
||||
expect(model.info).toEqual(minimaxModels[minimaxDefaultModelId])
|
||||
})
|
||||
})
|
||||
|
||||
describe("API Methods", () => {
|
||||
|
|
|
|||
|
|
@ -271,8 +271,8 @@ export class MiniMaxHandler extends BaseProvider implements SingleCompletionHand
|
|||
|
||||
getModel() {
|
||||
const modelId = this.options.apiModelId
|
||||
const id = modelId && modelId in minimaxModels ? (modelId as MinimaxModelId) : minimaxDefaultModelId
|
||||
const info = minimaxModels[id]
|
||||
const id = modelId || minimaxDefaultModelId
|
||||
const info = minimaxModels[id as MinimaxModelId] ?? minimaxModels[minimaxDefaultModelId]
|
||||
|
||||
const params = getModelParams({
|
||||
format: "anthropic",
|
||||
|
|
|
|||
|
|
@ -773,5 +773,19 @@ describe("useSelectedModel", () => {
|
|||
expect(result.current.id).toBe("MiniMax-M2.7")
|
||||
expect(result.current.info).toEqual(minimaxModels["MiniMax-M2.7"])
|
||||
})
|
||||
|
||||
it("should fall back to default model info for unknown model IDs", () => {
|
||||
const apiConfiguration: ProviderSettings = {
|
||||
apiProvider: "minimax",
|
||||
apiModelId: "some-future-minimax-model",
|
||||
}
|
||||
|
||||
const wrapper = createWrapper()
|
||||
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })
|
||||
|
||||
expect(result.current.provider).toBe("minimax")
|
||||
expect(result.current.id).toBe("some-future-minimax-model")
|
||||
expect(result.current.info).toEqual(minimaxModels[minimaxDefaultModelId])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -243,7 +243,9 @@ function getSelectedModel({
|
|||
}
|
||||
case "minimax": {
|
||||
const id = apiConfiguration.apiModelId ?? defaultModelId
|
||||
const info = minimaxModels[id as keyof typeof minimaxModels]
|
||||
const info =
|
||||
minimaxModels[id as keyof typeof minimaxModels] ??
|
||||
minimaxModels[defaultModelId as keyof typeof minimaxModels]
|
||||
return { id, info }
|
||||
}
|
||||
case "zai": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue