refactor(providers): drop the transitional tables, document how to add a provider

Step 6 of the provider refactor plan. FIXED_CRED_PROVIDERS, PROVIDER_LOGO_MAP,
OPTIONS_OPEN and NO_KEY_NEEDED had no readers left and are gone; the record's
fields are read where they were used. The fixture that compared the derived
tables with their old literal values is gone with them; tests/unit/providers.test.ts
keeps the record's own rules (21 providers in auto-detection, every note in
every UI language, https defaults only, fixed-credential providers, the
picker's order) and a new check that env.example names every record's
variables. docs/{en,cn,ja}/ai-providers.md end with a section on adding a
provider: one record, two env.example lines, one docs paragraph.
This commit is contained in:
dayuan.jiang
2026-10-12 21:17:51 +09:00
parent f811242568
commit e1c083dae0
7 changed files with 170 additions and 510 deletions
-9
View File
@@ -31,15 +31,6 @@ export const POPULAR_PROVIDERS: ProviderName[] = [
"qwen",
]
/**
* Providers whose base URL usually needs changing (Azure has no default;
* Ollama's is its cloud, SGLang's a local server) or comes with a hint
* (MiniMax, MiMo): their folded options start open
*/
export const OPTIONS_OPEN: ProviderName[] = PROVIDER_NAMES.filter(
(p) => PROVIDERS[p].optionsOpen,
)
/** The groups with only the providers whose name matches the search */
export function filterProviderGroups(query: string) {
const q = query.trim().toLowerCase()
+1 -16
View File
@@ -1,6 +1,6 @@
// Types for multi-provider model configuration
import { PROVIDER_NAMES, PROVIDERS, type ProviderName } from "@/lib/providers"
import { PROVIDERS, type ProviderName } from "@/lib/providers"
// The provider record, under the name the rest of the app imports it by
export {
@@ -67,21 +67,6 @@ export interface FlattenedModel {
isDefault?: boolean
}
// Providers whose server credentials live in fixed env vars
// (AWS_ACCESS_KEY_ID, GOOGLE_VERTEX_API_KEY, OLLAMA_API_KEY) with no
// apiKeyEnv redirection support: their credentials are global
export const FIXED_CRED_PROVIDERS: ProviderName[] = PROVIDER_NAMES.filter(
(p) => PROVIDERS[p].fixedCredentials,
)
// models.dev logo names that differ from the provider name
export const PROVIDER_LOGO_MAP: Record<string, string> = Object.fromEntries(
PROVIDER_NAMES.flatMap((p) => {
const logo = PROVIDERS[p].logo
return logo ? [[p, logo]] : []
}),
)
// Suggested models per provider for quick add
export const SUGGESTED_MODELS: Partial<Record<ProviderName, string[]>> = {
openai: [