fix(server): compatible with gateway.ai.cloudflare.com (#2029)

This commit is contained in:
Lukin 2024-03-06 13:17:10 +08:00 committed by GitHub
parent 15903fae38
commit c520580cda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -70,8 +70,13 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
}
}
if (isNotEmptyString(OPENAI_API_BASE_URL))
if (isNotEmptyString(OPENAI_API_BASE_URL)) {
// if find /v1 in OPENAI_API_BASE_URL then use it
if (OPENAI_API_BASE_URL.includes('/v1'))
options.apiBaseUrl = `${OPENAI_API_BASE_URL}`
else
options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`
}
setupProxy(options)