File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff 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" , ( ) => {
Original file line number Diff line number Diff 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 ( g e m i n i | g o o g l e | v e r t e x _ a i | v e r t e x ) \/ g e m i n i - ( 3 | 2 \. 5 ) / i. test ( modelId )
63+ / \b ( g e m i n i | g o o g l e | v e r t e x _ a i | v e r t e x ) \/ g e m i n i [ - \s ] ( 3 | 2 \. 5 ) / i. test ( modelId )
5864 )
5965 }
6066
You can’t perform that action at this time.
0 commit comments