fix(OpenAIClient/PluginsClient): allow non-v1 reverse proxy, handle "v1/completions" reverse proxy (#1029)

* fix(OpenAIClient): handle completions request in reverse proxy, also force prompt by env var

* fix(reverseProxyUrl): allow url without /v1/ but add server warning as it will not be compatible with plugins

* fix(ModelService): handle reverse proxy without v1

* refactor: make changes cleaner

* ci(OpenAIClient): add tests for OPENROUTER_API_KEY, FORCE_PROMPT, and reverseProxyUrl handling in setOptions
This commit is contained in:
Danny Avila 2023-10-08 16:57:25 -04:00 committed by GitHub
parent d61e44742d
commit 2dd545eaa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 14 deletions

View file

@ -28,7 +28,7 @@ const fetchOpenAIModels = async (opts = { azure: false, plugins: false }, _model
}
if (reverseProxyUrl) {
basePath = reverseProxyUrl.match(/.*v1/)[0];
basePath = reverseProxyUrl.match(/.*v1/)?.[0];
}
const cachedModels = await modelsCache.get(basePath);