mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
fix: add proxy to titleConvo
This commit is contained in:
parent
90dc171b34
commit
4a39965b22
1 changed files with 17 additions and 1 deletions
|
|
@ -1,5 +1,21 @@
|
|||
const { Configuration, OpenAIApi } = require('openai');
|
||||
|
||||
const proxyEnvToAxiosProxy = (proxyString) => {
|
||||
if (!proxyString) return null;
|
||||
|
||||
const regex = /^([^:]+):\/\/(?:([^:@]*):?([^:@]*)@)?([^:]+)(?::(\d+))?/;
|
||||
const [, protocol, username, password, host, port] = proxyString.match(regex);
|
||||
const proxyConfig = {
|
||||
protocol,
|
||||
host,
|
||||
port: port ? parseInt(port) : undefined,
|
||||
auth: username && password ? { username, password } : undefined
|
||||
};
|
||||
|
||||
return proxyConfig
|
||||
}
|
||||
console.log(proxyEnvToAxiosProxy(process.env.PROXY || null))
|
||||
|
||||
const titleConvo = async ({ message, response, model }) => {
|
||||
const configuration = new Configuration({
|
||||
apiKey: process.env.OPENAI_KEY
|
||||
|
|
@ -15,7 +31,7 @@ const titleConvo = async ({ message, response, model }) => {
|
|||
},
|
||||
{ role: 'user', content: `In 5 words or less, summarize the conversation below with a title in title case using the language the user writes in. Don't refer to the participants of the conversation by name. Do not include punctuation or quotation marks. Your response should be in title case, exclusively containing the title. Conversation:\n\nUser: "${message}"\n\n${model}: "${response}"\n\nTitle: ` },
|
||||
]
|
||||
});
|
||||
}, { proxy: proxyEnvToAxiosProxy(process.env.PROXY || null) });
|
||||
|
||||
//eslint-disable-next-line
|
||||
return completion.data.choices[0].message.content.replace(/["\.]/g, '');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue