mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-18 05:50:30 -07:00
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { normalizeModelId } from './modelUtils.js';
|
||||
|
||||
describe('modelUtils', () => {
|
||||
describe('normalizeModelId', () => {
|
||||
it('should strip "models/" prefix if present', () => {
|
||||
expect(normalizeModelId('models/gemini-3.1-pro-preview')).toBe(
|
||||
'gemini-3.1-pro-preview',
|
||||
);
|
||||
expect(normalizeModelId('models/gemini-1.5-flash')).toBe(
|
||||
'gemini-1.5-flash',
|
||||
);
|
||||
});
|
||||
|
||||
it('should leave model ID untouched if prefix is not present', () => {
|
||||
expect(normalizeModelId('gemini-3.1-pro-preview')).toBe(
|
||||
'gemini-3.1-pro-preview',
|
||||
);
|
||||
expect(normalizeModelId('auto')).toBe('auto');
|
||||
});
|
||||
|
||||
it('should handle empty string', () => {
|
||||
expect(normalizeModelId('')).toBe('');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Strips the 'models/' prefix from a model ID if present.
|
||||
* This ensures internal logic (like family matching) works correctly
|
||||
* even when receiving formal resource names from the API.
|
||||
*
|
||||
* @param modelId The model identifier to normalize.
|
||||
* @returns The model ID without the 'models/' prefix.
|
||||
*/
|
||||
export function normalizeModelId(modelId: string): string {
|
||||
return modelId.startsWith('models/') ? modelId.slice(7) : modelId;
|
||||
}
|
||||
Reference in New Issue
Block a user