wip: zen
This commit is contained in:
@@ -389,11 +389,7 @@ export async function handler(
|
||||
if (provider) return provider
|
||||
}
|
||||
|
||||
if (retry.retryCount === MAX_FAILOVER_RETRIES) {
|
||||
const provider = modelInfo.providers.find((provider) => provider.id === modelInfo.fallbackProvider)
|
||||
if (provider) return provider
|
||||
}
|
||||
|
||||
if (retry.retryCount !== MAX_FAILOVER_RETRIES) {
|
||||
const providers = modelInfo.providers
|
||||
.filter((provider) => !provider.disabled)
|
||||
.filter((provider) => !retry.excludeProviders.includes(provider.id))
|
||||
@@ -406,7 +402,12 @@ export async function handler(
|
||||
h = (h * 31 + sessionId.charCodeAt(i)) | 0 // 32-bit int
|
||||
}
|
||||
const index = (h >>> 0) % providers.length // make unsigned + range 0..length-1
|
||||
return providers[index || 0]
|
||||
const provider = providers[index || 0]
|
||||
if (provider) return provider
|
||||
}
|
||||
|
||||
// fallback provider
|
||||
return modelInfo.providers.find((provider) => provider.id === modelInfo.fallbackProvider)
|
||||
})()
|
||||
|
||||
if (!modelProvider) throw new ModelError("No provider available")
|
||||
|
||||
Reference in New Issue
Block a user