mirror of
https://github.com/anomalyco/opencode.git
synced 2026-06-02 06:16:48 +02:00
zen: disable models
This commit is contained in:
@@ -483,27 +483,29 @@ export async function handler(
|
|||||||
modelTpsLimits: Record<string, boolean> | undefined,
|
modelTpsLimits: Record<string, boolean> | undefined,
|
||||||
) {
|
) {
|
||||||
const modelProvider = (() => {
|
const modelProvider = (() => {
|
||||||
|
const allProviders = modelInfo.providers.filter((provider) => !provider.disabled)
|
||||||
|
|
||||||
// Byok is top priority b/c if user set their own API key, we should use it
|
// Byok is top priority b/c if user set their own API key, we should use it
|
||||||
// instead of using the sticky provider for the same session
|
// instead of using the sticky provider for the same session
|
||||||
if (authInfo?.provider?.credentials) {
|
if (authInfo?.provider?.credentials) {
|
||||||
return modelInfo.providers.find((provider) => provider.id === modelInfo.byokProvider)
|
return allProviders.find((provider) => provider.id === modelInfo.byokProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use the same provider for the same session
|
// Always use the same provider for the same session
|
||||||
if (stickyProvider) {
|
if (stickyProvider) {
|
||||||
const provider = modelInfo.providers.find((provider) => provider.id === stickyProvider)
|
const provider = allProviders.find((provider) => provider.id === stickyProvider)
|
||||||
if (provider) return provider
|
if (provider) return provider
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trialProviders) {
|
if (trialProviders) {
|
||||||
const trialProvider = trialProviders[Math.floor(Math.random() * trialProviders.length)]
|
const trialProvider = trialProviders[Math.floor(Math.random() * trialProviders.length)]
|
||||||
const provider = modelInfo.providers.find((provider) => provider.id === trialProvider)
|
const provider = allProviders.find((provider) => provider.id === trialProvider)
|
||||||
if (provider) return provider
|
if (provider) return provider
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retry.retryCount !== MAX_FAILOVER_RETRIES) {
|
if (retry.retryCount !== MAX_FAILOVER_RETRIES) {
|
||||||
let topPriority = Infinity
|
let topPriority = Infinity
|
||||||
const providers = modelInfo.providers
|
const providers = allProviders
|
||||||
.filter((provider) => !provider.disabled)
|
.filter((provider) => !provider.disabled)
|
||||||
.filter((provider) => provider.weight !== 0)
|
.filter((provider) => provider.weight !== 0)
|
||||||
.filter((provider) => !retry.excludeProviders.includes(provider.id))
|
.filter((provider) => !retry.excludeProviders.includes(provider.id))
|
||||||
@@ -536,7 +538,7 @@ export async function handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fallback provider
|
// fallback provider
|
||||||
return modelInfo.providers.find((provider) => provider.id === modelInfo.fallbackProvider)
|
return allProviders.find((provider) => provider.id === modelInfo.fallbackProvider)
|
||||||
})()
|
})()
|
||||||
|
|
||||||
if (!modelProvider) throw new ModelError(t("zen.api.error.noProviderAvailable"))
|
if (!modelProvider) throw new ModelError(t("zen.api.error.noProviderAvailable"))
|
||||||
|
|||||||
Reference in New Issue
Block a user