mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-12 21:02:17 +02:00
fix(onboarding): filter non-chat models from provider list using models.dev
This commit is contained in:
parent
6040c54807
commit
1368d84bac
2 changed files with 30 additions and 1 deletions
|
|
@ -224,3 +224,22 @@ export async function listOnboardingModels(): Promise<{ providers: ProviderSumma
|
|||
|
||||
return { providers, lastUpdated: fetchedAt };
|
||||
}
|
||||
|
||||
export async function getChatModelIds(
|
||||
flavor: "openai" | "anthropic" | "google",
|
||||
): Promise<Set<string>> {
|
||||
try {
|
||||
const { data } = await getModelsDevData();
|
||||
const provider = pickProvider(data, flavor);
|
||||
if (!provider) return new Set();
|
||||
const ids = new Set<string>();
|
||||
for (const [id, model] of Object.entries(provider.models)) {
|
||||
if (isStableModel(model) && supportsToolCall(model)) {
|
||||
ids.add(model.id ?? id);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
} catch {
|
||||
return new Set();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { LlmModelConfig, LlmProvider } from "@x/shared/dist/models.js";
|
|||
import z from "zod";
|
||||
import { getGatewayProvider } from "./gateway.js";
|
||||
import { getDefaultModelAndProvider, resolveProviderConfig } from "./defaults.js";
|
||||
import { getChatModelIds } from "./models-dev.js";
|
||||
import { withUseCase } from "../analytics/use_case.js";
|
||||
|
||||
export const Provider = LlmProvider;
|
||||
|
|
@ -158,7 +159,16 @@ export async function listModelsForProvider(
|
|||
// OpenAI-shaped: { data: [{ id: "..." }] }
|
||||
ids = (data.data ?? []).map((m: { id: string }) => m.id);
|
||||
}
|
||||
return ids.filter((id: string) => typeof id === "string" && id.length > 0);
|
||||
const cleaned = ids.filter((id: string) => typeof id === "string" && id.length > 0);
|
||||
if (flavor === "openai" || flavor === "anthropic" || flavor === "google") {
|
||||
const chatIds = await getChatModelIds(flavor);
|
||||
// Only filter when models.dev returned data; if it's empty (offline/no
|
||||
// cache/unknown provider) keep the full list rather than showing none.
|
||||
if (chatIds.size > 0) {
|
||||
return cleaned.filter((id) => chatIds.has(id));
|
||||
}
|
||||
}
|
||||
return cleaned;
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue