mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-10 00:18:23 +00:00
* 🌐 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
37 lines
975 B
TypeScript
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)] ?? [],
|
|
),
|
|
};
|
|
}
|