Gemini: remove non existing models from our definitions, and add a check

This commit is contained in:
Enrico Ros
2025-02-27 17:55:11 -08:00
parent f6abca0663
commit b3ae2b1cbc
2 changed files with 22 additions and 40 deletions
+20 -39
View File
@@ -327,49 +327,11 @@ const _knownGeminiModels: ({
isPreview: true,
interfaces: [LLM_IF_OAI_Chat, LLM_IF_OAI_Vision],
description: 'LearnLM is an experimental task-specific model aligned with learning science principles.',
chatPrice: geminiExpPricingFree,
// hidden: true,
// _delete: true,
},
// Generation 1.0
// Gemini 1.0 Pro Models (Deprecated)
{
id: 'models/gemini-1.0-pro-latest',
// symLink: 'models/gemini-1.0-pro-001',
chatPrice: gemini10ProPricing,
interfaces: [LLM_IF_OAI_Chat],
deprecated: '2025-02-15',
// _delete: true, // kept for reference, but doc states deprecation on 2025-02-15
},
{
id: 'models/gemini-1.0-pro-001',
labelOverride: 'Gemini 1.0 Pro', // remove the 'Tuning'
chatPrice: gemini10ProPricing,
interfaces: [LLM_IF_OAI_Chat],
benchmark: { cbaElo: 1131 },
deprecated: '2025-02-15',
},
{
id: 'models/gemini-1.0-pro',
symLink: 'models/gemini-1.0-pro-001',
chatPrice: gemini10ProPricing,
interfaces: [LLM_IF_OAI_Chat],
deprecated: '2025-02-15',
hidden: true,
},
{
id: 'models/gemini-pro',
symLink: 'models/gemini-1.0-pro',
chatPrice: gemini10ProPricing,
interfaces: [LLM_IF_OAI_Chat],
benchmark: { cbaElo: 1110 },
deprecated: '2025-02-15',
_delete: true, // confusing old model name
},
// Gemini 1.0 Pro Vision Model
{
id: 'models/gemini-1.0-pro-vision-latest',
@@ -386,6 +348,24 @@ const _knownGeminiModels: ({
];
// Add to your code where you process the API response
export function geminiDevCheckForSuperfluosModels_DEV(apiModelIds: string[]): void {
if (DEV_DEBUG_GEMINI_MODELS) {
// editorial model ids
const expectedModelIds = _knownGeminiModels.map(model => model.id);
// find editorial models which aren't present in the API response anymore
const missingModels = expectedModelIds.filter(id => !apiModelIds.includes(id));
if (missingModels.length > 0)
console.warn(`Gemini: superfluous model definitions: [ ${missingModels.join(', ')} ]`);
}
}
export function geminiFilterModels(geminiModel: GeminiWire_API_Models_List.Model): boolean {
const isAllowed = !filterUnallowedNames.some(name => geminiModel.displayName.includes(name));
const isSupported = !filterUnallowedInterfaces.some(iface => geminiModel.supportedGenerationMethods.includes(iface));
@@ -426,6 +406,7 @@ export function geminiSortModels(a: ModelDescriptionSchema, b: ModelDescriptionS
return b.label.localeCompare(a.label);
}
export function geminiModelToModelDescription(geminiModel: GeminiWire_API_Models_List.Model): ModelDescriptionSchema | null {
const { description, displayName, name: modelId, supportedGenerationMethods } = geminiModel;
@@ -11,7 +11,7 @@ import { GeminiWire_API_Models_List, GeminiWire_Safety } from '~/modules/aix/ser
import { fixupHost } from '~/common/util/urlUtils';
import { ListModelsResponse_schema } from '../llm.server.types';
import { geminiFilterModels, geminiModelToModelDescription, geminiSortModels } from './gemini.models';
import { geminiDevCheckForSuperfluosModels_DEV, geminiFilterModels, geminiModelToModelDescription, geminiSortModels } from './gemini.models';
// Default hosts
@@ -98,6 +98,7 @@ export const llmGeminiRouter = createTRPCRouter({
// get the models
const wireModels = await geminiGET(input.access, null, GeminiWire_API_Models_List.getPath, false);
const detailedModels = GeminiWire_API_Models_List.Response_schema.parse(wireModels).models;
geminiDevCheckForSuperfluosModels_DEV(detailedModels.map(model => model.name));
// NOTE: no need to retrieve info for each of the models (e.g. /v1beta/model/gemini-pro).,
// as the List API already all the info on all the models