feat(OpenAIClient): Add HttpsProxyAgent to initializeLLM (#1119)

* feat(OpenAIClient): Add HttpsProxyAgent to initializeLLM

* chore: fix linting error in ModelService
This commit is contained in:
Danny Avila 2023-10-29 13:20:30 -04:00 committed by GitHub
parent 7b30ab3a41
commit 5c1e44eff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -1,4 +1,5 @@
const { encoding_for_model: encodingForModel, get_encoding: getEncoding } = require('tiktoken');
const { HttpsProxyAgent } = require('https-proxy-agent');
const ChatGPTClient = require('./ChatGPTClient');
const BaseClient = require('./BaseClient');
const { getModelMaxTokens, genAzureChatCompletion } = require('../../utils');
@ -461,6 +462,11 @@ If your reverse proxy is compatible to OpenAI specs in every other way, it may s
};
}
if (this.options.proxy) {
configOptions.httpAgent = new HttpsProxyAgent(this.options.proxy);
configOptions.httpsAgent = new HttpsProxyAgent(this.options.proxy);
}
const { req, res, debug } = this.options;
const runManager = new RunManager({ req, res, debug, abortController: this.abortController });
this.runManager = runManager;

View file

@ -29,7 +29,7 @@ const fetchOpenAIModels = async (opts = { azure: false, plugins: false }, _model
if (OPENROUTER_API_KEY) {
reverseProxyUrl = 'https://openrouter.ai/api/v1';
apiKey = OPENROUTER_API_KEY
apiKey = OPENROUTER_API_KEY;
}
if (reverseProxyUrl) {