mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
feat: Add config flag to filter provider models
This commit is contained in:
parent
33b5fe236a
commit
637f317023
2 changed files with 14 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -241,13 +241,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 ?? {})) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue