mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-28 05:04:23 +01:00
Hide experimental models
This commit is contained in:
@@ -7,6 +7,7 @@ export namespace Flag {
|
|||||||
export const OPENCODE_PERMISSION = process.env["OPENCODE_PERMISSION"]
|
export const OPENCODE_PERMISSION = process.env["OPENCODE_PERMISSION"]
|
||||||
export const OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS")
|
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_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD")
|
||||||
|
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
|
||||||
|
|
||||||
function truthy(key: string) {
|
function truthy(key: string) {
|
||||||
const value = process.env[key]?.toLowerCase()
|
const value = process.env[key]?.toLowerCase()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export namespace ModelsDev {
|
|||||||
context: z.number(),
|
context: z.number(),
|
||||||
output: z.number(),
|
output: z.number(),
|
||||||
}),
|
}),
|
||||||
|
experimental: z.boolean().optional(),
|
||||||
options: z.record(z.any()),
|
options: z.record(z.any()),
|
||||||
})
|
})
|
||||||
.openapi({
|
.openapi({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { NamedError } from "../util/error"
|
|||||||
import { Auth } from "../auth"
|
import { Auth } from "../auth"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { Global } from "../global"
|
import { Global } from "../global"
|
||||||
|
import { Flag } from "../flag/flag"
|
||||||
|
|
||||||
export namespace Provider {
|
export namespace Provider {
|
||||||
const log = Log.create({ service: "provider" })
|
const log = Log.create({ service: "provider" })
|
||||||
@@ -286,14 +287,18 @@ export namespace Provider {
|
|||||||
for (const [providerID, provider] of configProviders) {
|
for (const [providerID, provider] of configProviders) {
|
||||||
mergeProvider(providerID, provider.options ?? {}, "config")
|
mergeProvider(providerID, provider.options ?? {}, "config")
|
||||||
}
|
}
|
||||||
|
console.log("!@#!@#", Flag.OPENCODE_ENABLE_EXPERIMENTAL_MODELS)
|
||||||
|
|
||||||
for (const [providerID, provider] of Object.entries(providers)) {
|
for (const [providerID, provider] of Object.entries(providers)) {
|
||||||
// Filter out blacklisted models
|
|
||||||
const filteredModels = Object.fromEntries(
|
const filteredModels = Object.fromEntries(
|
||||||
Object.entries(provider.info.models).filter(
|
Object.entries(provider.info.models)
|
||||||
([modelID]) =>
|
// Filter out blacklisted models
|
||||||
modelID !== "gpt-5-chat-latest" && !(providerID === "openrouter" && modelID === "openai/gpt-5-chat"),
|
.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
|
provider.info.models = filteredModels
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user