mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
feat(api): add support for user-provided OpenAI API key (#311)
- Add support for user-provided OpenAI API key by setting OPENAI_KEY to "user_provided" in .env.example - Pass oaiApiKey to titleConvo function in titleConvo.js - Pass oaiApiKey to askClient function in askOpenAI.js - Modify openAI object in endpoints.js to include userProvide property based on whether OPENAI_KEY is set to "user_provided" or not.
This commit is contained in:
parent
61a4231feb
commit
26152d7e5f
4 changed files with 12 additions and 8 deletions
|
|
@ -169,12 +169,13 @@ const ask = async ({
|
|||
};
|
||||
const abortKey = conversationId;
|
||||
abortControllers.set(abortKey, { abortController, ...endpointOption });
|
||||
const oaiApiKey = req.body?.token ?? null;
|
||||
|
||||
let response = await askClient({
|
||||
text,
|
||||
parentMessageId: userParentMessageId,
|
||||
conversationId,
|
||||
oaiApiKey: req.body?.token ?? null,
|
||||
oaiApiKey,
|
||||
...endpointOption,
|
||||
onProgress: progressCallback.call(null, {
|
||||
res,
|
||||
|
|
@ -250,7 +251,7 @@ const ask = async ({
|
|||
res.end();
|
||||
|
||||
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({ endpoint: endpointOption?.endpoint, text, response: responseMessage });
|
||||
const title = await titleConvo({ endpoint: endpointOption?.endpoint, text, response: responseMessage, oaiApiKey });
|
||||
await saveConvo(req.user.id, {
|
||||
conversationId: conversationId,
|
||||
title
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue