archied already finds usable providers (key set in the environment, or configured) through the model catalog; the published config view now carries that catalog, providers with their model ids. Settings > Models offers role models only from configured providers, lists the catalog's unconfigured providers as available, and adding one carries its class, key variable and endpoint. Roles and providers are two accordions, each ending in an add row.
23 lines
905 B
TypeScript
23 lines
905 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { availableProviders, roleModelOptions } from "../src/settings/model-choices.ts";
|
|
|
|
const catalog = [
|
|
{ id: "anthropic", name: "Anthropic", class: "anthropic", api_key_env: "ANTHROPIC_API_KEY", models: ["claude-a"] },
|
|
{ id: "openai", name: "OpenAI", class: "openai", api_key_env: "OPENAI_API_KEY", models: ["gpt-a", "gpt-b"] },
|
|
{ id: "groq", name: "Groq", class: "groq", models: ["llama"] },
|
|
];
|
|
|
|
test("role models come only from configured providers", () => {
|
|
assert.deepEqual(roleModelOptions(catalog, ["openai", "deepseek"]), ["openai/gpt-a", "openai/gpt-b"]);
|
|
assert.deepEqual(roleModelOptions(catalog, []), []);
|
|
});
|
|
|
|
test("available providers are the catalog's ones not yet configured", () => {
|
|
assert.deepEqual(
|
|
availableProviders(catalog, ["openai"]).map((p) => p.id),
|
|
["anthropic", "groq"],
|
|
);
|
|
});
|