Skip to content

Commit 95be704

Browse files
authored
fix(litellm): detect Gemini models with space-separated names for thought signature injection (#10787)
1 parent c40c882 commit 95be704

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/api/providers/__tests__/lite-llm.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,28 @@ describe("LiteLLMHandler", () => {
414414
expect(isGeminiModel("gemini-2.5-flash")).toBe(true)
415415
})
416416

417+
it("should detect Gemini models with spaces (LiteLLM model groups)", () => {
418+
const handler = new LiteLLMHandler(mockOptions)
419+
const isGeminiModel = (handler as any).isGeminiModel.bind(handler)
420+
421+
// LiteLLM model groups often use space-separated names with title case
422+
expect(isGeminiModel("Gemini 3 Pro")).toBe(true)
423+
expect(isGeminiModel("Gemini 3 Flash")).toBe(true)
424+
expect(isGeminiModel("gemini 3 pro")).toBe(true)
425+
expect(isGeminiModel("Gemini 2.5 Pro")).toBe(true)
426+
expect(isGeminiModel("gemini 2.5 flash")).toBe(true)
427+
})
428+
417429
it("should detect provider-prefixed Gemini models", () => {
418430
const handler = new LiteLLMHandler(mockOptions)
419431
const isGeminiModel = (handler as any).isGeminiModel.bind(handler)
420432

421433
expect(isGeminiModel("google/gemini-3-pro")).toBe(true)
422434
expect(isGeminiModel("vertex_ai/gemini-3-pro")).toBe(true)
423435
expect(isGeminiModel("vertex/gemini-2.5-pro")).toBe(true)
436+
// Space-separated variants with provider prefix
437+
expect(isGeminiModel("google/gemini 3 pro")).toBe(true)
438+
expect(isGeminiModel("vertex_ai/gemini 2.5 pro")).toBe(true)
424439
})
425440

426441
it("should not detect non-Gemini models", () => {

src/api/providers/lite-llm.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,21 @@ export class LiteLLMHandler extends RouterProvider implements SingleCompletionHa
4646
private isGeminiModel(modelId: string): boolean {
4747
// Match various Gemini model patterns:
4848
// - gemini-3-pro, gemini-3-flash, gemini-3-*
49+
// - gemini 3 pro, Gemini 3 Pro (space-separated, case-insensitive)
4950
// - gemini/gemini-3-*, google/gemini-3-*
5051
// - vertex_ai/gemini-3-*, vertex/gemini-3-*
5152
// Also match Gemini 2.5+ models which use similar validation
5253
const lowerModelId = modelId.toLowerCase()
5354
return (
55+
// Match hyphenated versions: gemini-3, gemini-2.5
5456
lowerModelId.includes("gemini-3") ||
5557
lowerModelId.includes("gemini-2.5") ||
58+
// Match space-separated versions: "gemini 3", "gemini 2.5"
59+
// This handles model names like "Gemini 3 Pro" from LiteLLM model groups
60+
lowerModelId.includes("gemini 3") ||
61+
lowerModelId.includes("gemini 2.5") ||
5662
// Also match provider-prefixed versions
57-
/\b(gemini|google|vertex_ai|vertex)\/gemini-(3|2\.5)/i.test(modelId)
63+
/\b(gemini|google|vertex_ai|vertex)\/gemini[-\s](3|2\.5)/i.test(modelId)
5864
)
5965
}
6066

0 commit comments

Comments
 (0)