fabro/apps/fabro-web/app/lib/model-offerings.ts
Scott Werner 758ddc532b Fetch provider names only for failed runs, through a shared helper
Every run page asked for the provider catalog, though only a failed or
dead run's banner uses it. useProviders takes an enabled flag, and the
id-to-display-name map settings-models built by hand is now
providerNamesById, shared with the run page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 14:01:35 -04:00

20 lines
674 B
TypeScript

import type { Model, Provider } from "@qltysh/fabro-api-client";
type ModelOfferingIdentity = Pick<Model, "provider" | "id">;
export function modelOfferingKey(model: ModelOfferingIdentity): string {
return `${model.provider}\u0000${model.id}`;
}
/** Provider ids to the names the catalog displays, falling back to the id. */
export function providerNamesById(
providers: readonly Pick<Provider, "id" | "display_name">[],
): Map<string, string> {
return new Map(providers.map((p) => [p.id, p.display_name || p.id]));
}
export function modelOfferingTestArgs(
model: ModelOfferingIdentity,
): [id: string, provider: string] {
return [model.id, model.provider];
}