mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-13 04:59:51 +08:00
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:
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user