mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50: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
|
|
@ -38,9 +38,11 @@ router.get('/', async function (req, res) {
|
|||
const google =
|
||||
key || palmUser ? { userProvide: palmUser, availableModels: ['chat-bison', 'text-bison'] } : false;
|
||||
const azureOpenAI = !!process.env.AZURE_OPENAI_KEY;
|
||||
const apiKey = process.env.OPENAI_KEY || process.env.AZURE_OPENAI_API_KEY;
|
||||
console.log('API KEY', apiKey);
|
||||
const openAI =
|
||||
process.env.OPENAI_KEY || process.env.AZURE_OPENAI_API_KEY
|
||||
? { availableModels: getOpenAIModels(), userProvide: true }
|
||||
apiKey
|
||||
? { availableModels: getOpenAIModels(), userProvide: apiKey === 'user_provided' }
|
||||
: false;
|
||||
const bingAI = process.env.BINGAI_TOKEN
|
||||
? { userProvide: process.env.BINGAI_TOKEN == 'user_provided' }
|
||||
|
|
@ -55,4 +57,4 @@ router.get('/', async function (req, res) {
|
|||
res.send(JSON.stringify({ azureOpenAI, openAI, google, bingAI, chatGPTBrowser }));
|
||||
});
|
||||
|
||||
module.exports = { router, getOpenAIModels, getChatGPTBrowserModels };
|
||||
module.exports = { router, getOpenAIModels, getChatGPTBrowserModels };
|
||||
Loading…
Add table
Add a link
Reference in a new issue