Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/api/providers/__tests__/lite-llm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,28 @@ describe("LiteLLMHandler", () => {
expect(isGeminiModel("gemini-2.5-flash")).toBe(true)
})

it("should detect Gemini models with spaces (LiteLLM model groups)", () => {
const handler = new LiteLLMHandler(mockOptions)
const isGeminiModel = (handler as any).isGeminiModel.bind(handler)

// LiteLLM model groups often use space-separated names with title case
expect(isGeminiModel("Gemini 3 Pro")).toBe(true)
expect(isGeminiModel("Gemini 3 Flash")).toBe(true)
expect(isGeminiModel("gemini 3 pro")).toBe(true)
expect(isGeminiModel("Gemini 2.5 Pro")).toBe(true)
expect(isGeminiModel("gemini 2.5 flash")).toBe(true)
})

it("should detect provider-prefixed Gemini models", () => {
const handler = new LiteLLMHandler(mockOptions)
const isGeminiModel = (handler as any).isGeminiModel.bind(handler)

expect(isGeminiModel("google/gemini-3-pro")).toBe(true)
expect(isGeminiModel("vertex_ai/gemini-3-pro")).toBe(true)
expect(isGeminiModel("vertex/gemini-2.5-pro")).toBe(true)
// Space-separated variants with provider prefix
expect(isGeminiModel("google/gemini 3 pro")).toBe(true)
expect(isGeminiModel("vertex_ai/gemini 2.5 pro")).toBe(true)
})

it("should not detect non-Gemini models", () => {
Expand Down
8 changes: 7 additions & 1 deletion src/api/providers/lite-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,21 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
private isGeminiModel(modelId: string): boolean {
// Match various Gemini model patterns:
// - gemini-3-pro, gemini-3-flash, gemini-3-*
// - gemini 3 pro, Gemini 3 Pro (space-separated, case-insensitive)
// - gemini/gemini-3-*, google/gemini-3-*
// - vertex_ai/gemini-3-*, vertex/gemini-3-*
// Also match Gemini 2.5+ models which use similar validation
const lowerModelId = modelId.toLowerCase()
return (
// Match hyphenated versions: gemini-3, gemini-2.5
lowerModelId.includes("gemini-3") ||
lowerModelId.includes("gemini-2.5") ||
// Match space-separated versions: "gemini 3", "gemini 2.5"
// This handles model names like "Gemini 3 Pro" from LiteLLM model groups
lowerModelId.includes("gemini 3") ||
lowerModelId.includes("gemini 2.5") ||
// Also match provider-prefixed versions
/\b(gemini|google|vertex_ai|vertex)\/gemini-(3|2\.5)/i.test(modelId)
/\b(gemini|google|vertex_ai|vertex)\/gemini[-\s](3|2\.5)/i.test(modelId)
)
}

Expand Down
Loading