mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: pass through custom model names in Gemini provider instead of falling back to default
This commit is contained in:
parent
cb83656718
commit
9bca5cc322
2 changed files with 40 additions and 7 deletions
|
|
@ -165,13 +165,25 @@ describe("GeminiHandler", () => {
|
|||
expect(modelInfo.info).toBeDefined()
|
||||
})
|
||||
|
||||
it("should return default model if invalid model specified", () => {
|
||||
const invalidHandler = new GeminiHandler({
|
||||
apiModelId: "invalid-model",
|
||||
it("should pass through custom model names not in the predefined list", () => {
|
||||
const customHandler = new GeminiHandler({
|
||||
apiModelId: "gemini-3.1-flash-lite-preview",
|
||||
geminiApiKey: "test-key",
|
||||
})
|
||||
const modelInfo = invalidHandler.getModel()
|
||||
expect(modelInfo.id).toBe(geminiDefaultModelId) // Default model
|
||||
const modelInfo = customHandler.getModel()
|
||||
expect(modelInfo.id).toBe("gemini-3.1-flash-lite-preview")
|
||||
expect(modelInfo.info).toBeDefined()
|
||||
expect(modelInfo.info.maxTokens).toBe(8192)
|
||||
expect(modelInfo.info.supportsImages).toBe(true)
|
||||
})
|
||||
|
||||
it("should return default model when no model ID is specified", () => {
|
||||
const noModelHandler = new GeminiHandler({
|
||||
apiModelId: undefined as any,
|
||||
geminiApiKey: "test-key",
|
||||
})
|
||||
const modelInfo = noModelHandler.getModel()
|
||||
expect(modelInfo.id).toBe(geminiDefaultModelId)
|
||||
})
|
||||
|
||||
it("should exclude apply_diff and include edit in tool preferences", () => {
|
||||
|
|
|
|||
|
|
@ -348,8 +348,29 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
|
||||
override getModel() {
|
||||
const modelId = this.options.apiModelId
|
||||
let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId
|
||||
let info: ModelInfo = geminiModels[id]
|
||||
|
||||
let id: string
|
||||
let info: ModelInfo
|
||||
|
||||
if (modelId && modelId in geminiModels) {
|
||||
// Known Gemini model -- use its curated ModelInfo.
|
||||
id = modelId as GeminiModelId
|
||||
info = geminiModels[id as GeminiModelId]
|
||||
} else if (modelId) {
|
||||
// Custom model name not in the predefined list.
|
||||
// Pass it through as-is so the user's chosen model is respected.
|
||||
id = modelId
|
||||
info = {
|
||||
maxTokens: 8192,
|
||||
contextWindow: 1_048_576,
|
||||
supportsImages: true,
|
||||
supportsPromptCache: false,
|
||||
}
|
||||
} else {
|
||||
// No model specified -- fall back to the default.
|
||||
id = geminiDefaultModelId
|
||||
info = geminiModels[geminiDefaultModelId]
|
||||
}
|
||||
|
||||
const params = getModelParams({
|
||||
format: "gemini",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue