This commit is contained in:
Ryan J. Dillon 2025-07-07 09:03:42 +02:00 committed by GitHub
commit 69e57d8e7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -157,6 +157,10 @@ export namespace Config {
.array(z.string())
.optional()
.describe("Disable providers that are loaded automatically"),
onlyConfigModels: z
.boolean()
.optional()
.describe("Only show models that are explicitly defined in the config (global setting)"),
model: z
.string()
.describe(
@ -168,6 +172,10 @@ export namespace Config {
ModelsDev.Provider.partial().extend({
models: z.record(ModelsDev.Model.partial()),
options: z.record(z.any()).optional(),
onlyConfigModels: z
.boolean()
.optional()
.describe("Only show models that are explicitly defined in the config for this provider"),
}),
)
.optional()

View file

@ -266,13 +266,18 @@ export namespace Provider {
for (const [providerID, provider] of configProviders) {
const existing = database[providerID]
// Check if onlyConfigModels is enabled (per-provider setting takes precedence over global)
const onlyConfigModels = provider.onlyConfigModels ?? config.onlyConfigModels ?? false
const parsed: ModelsDev.Provider = {
id: providerID,
npm: provider.npm ?? existing?.npm,
name: provider.name ?? existing?.name ?? providerID,
env: provider.env ?? existing?.env ?? [],
api: provider.api ?? existing?.api,
models: existing?.models ?? {},
// If onlyConfigModels is true, start with empty models, otherwise use database models
models: onlyConfigModels ? {} : (existing?.models ?? {}),
}
for (const [modelID, model] of Object.entries(provider.models ?? {})) {