feat: manual model IDs when /models is unavailable

Hosted OpenAI-compatible APIs often serve chat but not GET /models
(Volcengine Ark Agent Plan returns 404), so connect failed. Accept a
typed list of model IDs: merged into discovered models when /models
works, used alone when it does not. The typed list is stored as
customProvider.manualModels so reconnects and pin saves keep it.
This commit is contained in:
iamabhishekt
2026-10-28 16:16:30 -04:00
parent 695948271f
commit b4a13f5c3b
6 changed files with 84 additions and 10 deletions
+6
View File
@@ -131,6 +131,12 @@ export async function discoverModels(baseUrl: string, apiKey?: string): Promise<
}
}
export function mergeManualModels(discovered: readonly CustomModel[], manualIds: readonly string[]): CustomModel[] {
const byId = new Map(discovered.map((m) => [m.id, m]));
for (const id of manualIds) if (!byId.has(id)) byId.set(id, { id });
return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
}
/** Model rows from a list response ({data:[…]} | {models:[…]} | bare array),
* or null if unrecognized. */
function modelRows(body: unknown): unknown[] | null {