Hide experimental models

This commit is contained in:
Frank
2025-09-09 03:16:44 -04:00
parent 34a33dfc16
commit 0f263bfefe
3 changed files with 12 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ export namespace Flag {
export const OPENCODE_PERMISSION = process.env["OPENCODE_PERMISSION"]
export const OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS")
export const OPENCODE_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD")
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
function truthy(key: string) {
const value = process.env[key]?.toLowerCase()

View File

@@ -28,6 +28,7 @@ export namespace ModelsDev {
context: z.number(),
output: z.number(),
}),
experimental: z.boolean().optional(),
options: z.record(z.any()),
})
.openapi({

View File

@@ -11,6 +11,7 @@ import { NamedError } from "../util/error"
import { Auth } from "../auth"
import { Instance } from "../project/instance"
import { Global } from "../global"
import { Flag } from "../flag/flag"
export namespace Provider {
const log = Log.create({ service: "provider" })
@@ -286,14 +287,18 @@ export namespace Provider {
for (const [providerID, provider] of configProviders) {
mergeProvider(providerID, provider.options ?? {}, "config")
}
console.log("!@#!@#", Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS)
for (const [providerID, provider] of Object.entries(providers)) {
// Filter out blacklisted models
const filteredModels = Object.fromEntries(
Object.entries(provider.info.models).filter(
([modelID]) =>
modelID !== "gpt-5-chat-latest" && !(providerID === "openrouter" && modelID === "openai/gpt-5-chat"),
),
Object.entries(provider.info.models)
// Filter out blacklisted models
.filter(
([modelID]) =>
modelID !== "gpt-5-chat-latest" && !(providerID === "openrouter" && modelID === "openai/gpt-5-chat"),
)
// Filter out experimental models
.filter(([, model]) => !model.experimental || Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS),
)
provider.info.models = filteredModels