mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix(titleConvo): use openAIApiKey and azure config from route handler (#637)
* fix(titleConvo): use openAIApiKey from route handler, handle azure conditional from route * chore: remove comment
This commit is contained in:
parent
3e5c5a828d
commit
1b999108e4
3 changed files with 24 additions and 14 deletions
|
|
@ -167,17 +167,17 @@ const ask = async ({ text, endpoint, endpointOption, parentMessageId = null, con
|
|||
...endpointOption
|
||||
};
|
||||
|
||||
let oaiApiKey = req.body?.token ?? process.env.OPENAI_API_KEY;
|
||||
let openAIApiKey = req.body?.token ?? process.env.OPENAI_API_KEY;
|
||||
if (process.env.PLUGINS_USE_AZURE) {
|
||||
clientOptions.azure = getAzureCredentials();
|
||||
oaiApiKey = clientOptions.azure.azureOpenAIApiKey;
|
||||
openAIApiKey = clientOptions.azure.azureOpenAIApiKey;
|
||||
}
|
||||
|
||||
if (oaiApiKey && oaiApiKey.includes('azure') && !clientOptions.azure) {
|
||||
if (openAIApiKey && openAIApiKey.includes('azure') && !clientOptions.azure) {
|
||||
clientOptions.azure = JSON.parse(req.body?.token) ?? getAzureCredentials();
|
||||
oaiApiKey = clientOptions.azure.azureOpenAIApiKey;
|
||||
openAIApiKey = clientOptions.azure.azureOpenAIApiKey;
|
||||
}
|
||||
const chatAgent = new PluginsClient(oaiApiKey, clientOptions);
|
||||
const chatAgent = new PluginsClient(openAIApiKey, clientOptions);
|
||||
|
||||
const onAgentAction = (action) => {
|
||||
const formattedAction = formatAction(action);
|
||||
|
|
@ -235,7 +235,12 @@ const ask = async ({ text, endpoint, endpointOption, parentMessageId = null, con
|
|||
res.end();
|
||||
|
||||
if (parentMessageId == '00000000-0000-0000-0000-000000000000' && newConvo) {
|
||||
const title = await titleConvo({ text, response });
|
||||
const title = await titleConvo({
|
||||
text,
|
||||
response,
|
||||
openAIApiKey,
|
||||
azure: !!clientOptions.azure,
|
||||
});
|
||||
await saveConvo(req.user.id, {
|
||||
conversationId: conversationId,
|
||||
title
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue