LibreChat/client/src/utils/agentModelSelection.ts
Danny Avila 8b1fcc0fc2
🌐 fix: Expose Gemini Models to Vertex AI Agents (#15234)
* 🌐 fix: Expose Gemini Models to Vertex AI Agents

* ♻️ refactor: Resolve Shared Vertex Model Catalogs

* fix: Preserve Exact Vertex Model Catalogs

* style: Format Agent Model Selection

* test: Preserve Native FS in Stable Diffusion Spec
2026-08-27 06:50:23 -04:00

37 lines
975 B
TypeScript

import { resolveModelCatalogKey } from 'librechat-data-provider';
type ProviderOption = string | { value?: string | number | null };
export function getAvailableModelSelection(model: string, models: readonly string[]): string {
return models.includes(model) ? model : '';
}
export function getAvailableAgentSelection({
provider,
model,
providers,
models,
}: {
provider: string;
model: string;
providers: readonly ProviderOption[];
models: Record<string, string[] | undefined>;
}): { provider: string; model: string } {
const providerExists =
models[resolveModelCatalogKey(provider, models)] != null &&
providers.some((option) =>
typeof option === 'string' ? option === provider : option.value === provider,
);
if (!providerExists) {
return { provider: '', model: '' };
}
return {
provider,
model: getAvailableModelSelection(
model,
models[resolveModelCatalogKey(provider, models)] ?? [],
),
};
}