Skip to content

Commit 719d5f2

Browse files
authored
chore: clean up unused models and use consts (google-gemini#16246)
1 parent 61d7ad1 commit 719d5f2

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

packages/core/src/core/tokenLimits.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,24 @@
66

77
import { describe, it, expect } from 'vitest';
88
import { 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

1017
describe('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', () => {

packages/core/src/core/tokenLimits.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
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+
715
type Model = string;
816
type 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
}

0 commit comments

Comments
 (0)