File tree Expand file tree Collapse file tree 2 files changed +27
-16
lines changed
Expand file tree Collapse file tree 2 files changed +27
-16
lines changed Original file line number Diff line number Diff line change 66
77import { describe , it , expect } from 'vitest' ;
88import { tokenLimit , DEFAULT_TOKEN_LIMIT } from './tokenLimits.js' ;
9+ import {
10+ DEFAULT_GEMINI_FLASH_LITE_MODEL ,
11+ DEFAULT_GEMINI_FLASH_MODEL ,
12+ DEFAULT_GEMINI_MODEL ,
13+ PREVIEW_GEMINI_FLASH_MODEL ,
14+ PREVIEW_GEMINI_MODEL ,
15+ } from '../config/models.js' ;
916
1017describe ( 'tokenLimit' , ( ) => {
11- it ( 'should return the correct token limit for gemini-1.5-pro' , ( ) => {
12- expect ( tokenLimit ( 'gemini-1.5-pro' ) ) . toBe ( 2_097_152 ) ;
18+ it ( 'should return the correct token limit for default models' , ( ) => {
19+ expect ( tokenLimit ( DEFAULT_GEMINI_MODEL ) ) . toBe ( 1_048_576 ) ;
20+ expect ( tokenLimit ( DEFAULT_GEMINI_FLASH_MODEL ) ) . toBe ( 1_048_576 ) ;
21+ expect ( tokenLimit ( DEFAULT_GEMINI_FLASH_LITE_MODEL ) ) . toBe ( 1_048_576 ) ;
1322 } ) ;
1423
15- it ( 'should return the correct token limit for gemini-1.5-flash' , ( ) => {
16- expect ( tokenLimit ( 'gemini-1.5-flash' ) ) . toBe ( 1_048_576 ) ;
24+ it ( 'should return the correct token limit for preview models' , ( ) => {
25+ expect ( tokenLimit ( PREVIEW_GEMINI_MODEL ) ) . toBe ( 1_048_576 ) ;
26+ expect ( tokenLimit ( PREVIEW_GEMINI_FLASH_MODEL ) ) . toBe ( 1_048_576 ) ;
1727 } ) ;
1828
1929 it ( 'should return the default token limit for an unknown model' , ( ) => {
Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7+ import {
8+ DEFAULT_GEMINI_FLASH_LITE_MODEL ,
9+ DEFAULT_GEMINI_FLASH_MODEL ,
10+ DEFAULT_GEMINI_MODEL ,
11+ PREVIEW_GEMINI_FLASH_MODEL ,
12+ PREVIEW_GEMINI_MODEL ,
13+ } from '../config/models.js' ;
14+
715type Model = string ;
816type TokenCount = number ;
917
@@ -13,19 +21,12 @@ export function tokenLimit(model: Model): TokenCount {
1321 // Add other models as they become relevant or if specified by config
1422 // Pulled from https://ai.google.dev/gemini-api/docs/models
1523 switch ( model ) {
16- case 'gemini-1.5-pro' :
17- return 2_097_152 ;
18- case 'gemini-1.5-flash' :
19- case 'gemini-2.5-pro-preview-05-06' :
20- case 'gemini-2.5-pro-preview-06-05' :
21- case 'gemini-2.5-pro' :
22- case 'gemini-2.5-flash-preview-05-20' :
23- case 'gemini-2.5-flash' :
24- case 'gemini-2.5-flash-lite' :
25- case 'gemini-2.0-flash' :
24+ case PREVIEW_GEMINI_MODEL :
25+ case PREVIEW_GEMINI_FLASH_MODEL :
26+ case DEFAULT_GEMINI_MODEL :
27+ case DEFAULT_GEMINI_FLASH_MODEL :
28+ case DEFAULT_GEMINI_FLASH_LITE_MODEL :
2629 return 1_048_576 ;
27- case 'gemini-2.0-flash-preview-image-generation' :
28- return 32_000 ;
2930 default :
3031 return DEFAULT_TOKEN_LIMIT ;
3132 }
You can’t perform that action at this time.
0 commit comments