mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-10 03:28:03 +00:00
Merge df31ccdf38 into 14922f127e
This commit is contained in:
commit
fcb2a3f77d
4 changed files with 68 additions and 6 deletions
|
|
@ -283,4 +283,46 @@ export const geminiModels = {
|
||||||
supportsReasoningBudget: true,
|
supportsReasoningBudget: true,
|
||||||
maxThinkingTokens: 24_576,
|
maxThinkingTokens: 24_576,
|
||||||
},
|
},
|
||||||
|
// Gemma 4 models
|
||||||
|
// https://ai.google.dev/gemma/docs/core
|
||||||
|
"gemma-4-31b-it": {
|
||||||
|
maxTokens: 8_192,
|
||||||
|
contextWindow: 131_072,
|
||||||
|
supportsImages: true,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0,
|
||||||
|
outputPrice: 0,
|
||||||
|
},
|
||||||
|
"gemma-4-12b-it": {
|
||||||
|
maxTokens: 8_192,
|
||||||
|
contextWindow: 131_072,
|
||||||
|
supportsImages: true,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0,
|
||||||
|
outputPrice: 0,
|
||||||
|
},
|
||||||
|
"gemma-4-6b-it": {
|
||||||
|
maxTokens: 8_192,
|
||||||
|
contextWindow: 32_768,
|
||||||
|
supportsImages: true,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0,
|
||||||
|
outputPrice: 0,
|
||||||
|
},
|
||||||
|
"gemma-4-4b-it": {
|
||||||
|
maxTokens: 8_192,
|
||||||
|
contextWindow: 32_768,
|
||||||
|
supportsImages: true,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0,
|
||||||
|
outputPrice: 0,
|
||||||
|
},
|
||||||
|
"gemma-4-1b-it": {
|
||||||
|
maxTokens: 8_192,
|
||||||
|
contextWindow: 32_768,
|
||||||
|
supportsImages: false,
|
||||||
|
supportsPromptCache: false,
|
||||||
|
inputPrice: 0,
|
||||||
|
outputPrice: 0,
|
||||||
|
},
|
||||||
} as const satisfies Record<string, ModelInfo>
|
} as const satisfies Record<string, ModelInfo>
|
||||||
|
|
|
||||||
|
|
@ -165,13 +165,33 @@ describe("GeminiHandler", () => {
|
||||||
expect(modelInfo.info).toBeDefined()
|
expect(modelInfo.info).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return default model if invalid model specified", () => {
|
it("should preserve unknown model ID instead of silently falling back to default", () => {
|
||||||
const invalidHandler = new GeminiHandler({
|
const invalidHandler = new GeminiHandler({
|
||||||
apiModelId: "invalid-model",
|
apiModelId: "invalid-model",
|
||||||
geminiApiKey: "test-key",
|
geminiApiKey: "test-key",
|
||||||
})
|
})
|
||||||
const modelInfo = invalidHandler.getModel()
|
const modelInfo = invalidHandler.getModel()
|
||||||
expect(modelInfo.id).toBe(geminiDefaultModelId) // Default model
|
expect(modelInfo.id).toBe("invalid-model") // Preserves user-provided ID
|
||||||
|
expect(modelInfo.info).toBeDefined() // Falls back to default model info
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should use default model when no model ID is provided", () => {
|
||||||
|
const noModelHandler = new GeminiHandler({
|
||||||
|
geminiApiKey: "test-key",
|
||||||
|
})
|
||||||
|
const modelInfo = noModelHandler.getModel()
|
||||||
|
expect(modelInfo.id).toBe(geminiDefaultModelId)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should recognize Gemma 4 models natively", () => {
|
||||||
|
const gemmaHandler = new GeminiHandler({
|
||||||
|
apiModelId: "gemma-4-31b-it",
|
||||||
|
geminiApiKey: "test-key",
|
||||||
|
})
|
||||||
|
const modelInfo = gemmaHandler.getModel()
|
||||||
|
expect(modelInfo.id).toBe("gemma-4-31b-it")
|
||||||
|
expect(modelInfo.info.contextWindow).toBe(131_072)
|
||||||
|
expect(modelInfo.info.supportsImages).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should exclude apply_diff and include edit in tool preferences", () => {
|
it("should exclude apply_diff and include edit in tool preferences", () => {
|
||||||
|
|
|
||||||
|
|
@ -348,8 +348,8 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
|
||||||
|
|
||||||
override getModel() {
|
override getModel() {
|
||||||
const modelId = this.options.apiModelId
|
const modelId = this.options.apiModelId
|
||||||
let id = modelId && modelId in geminiModels ? (modelId as GeminiModelId) : geminiDefaultModelId
|
const id: string = modelId ?? geminiDefaultModelId
|
||||||
let info: ModelInfo = geminiModels[id]
|
let info: ModelInfo = geminiModels[id as GeminiModelId] ?? geminiModels[geminiDefaultModelId]
|
||||||
|
|
||||||
const params = getModelParams({
|
const params = getModelParams({
|
||||||
format: "gemini",
|
format: "gemini",
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ export class VertexHandler extends GeminiHandler implements SingleCompletionHand
|
||||||
|
|
||||||
override getModel() {
|
override getModel() {
|
||||||
const modelId = this.options.apiModelId
|
const modelId = this.options.apiModelId
|
||||||
let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId
|
const id: string = modelId ?? vertexDefaultModelId
|
||||||
let info: ModelInfo = vertexModels[id]
|
let info: ModelInfo = vertexModels[id as VertexModelId] ?? vertexModels[vertexDefaultModelId]
|
||||||
const params = getModelParams({
|
const params = getModelParams({
|
||||||
format: "gemini",
|
format: "gemini",
|
||||||
modelId: id,
|
modelId: id,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue