mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-05 18:18:51 +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
|
|
@ -17,7 +17,7 @@ const proxyEnvToAxiosProxy = (proxyString) => {
|
|||
return proxyConfig;
|
||||
};
|
||||
|
||||
const titleConvo = async ({ endpoint, text, response }) => {
|
||||
const titleConvo = async ({ endpoint, text, response, oaiApiKey }) => {
|
||||
let title = 'New Chat';
|
||||
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ const titleConvo = async ({ endpoint, text, response }) => {
|
|||
frequency_penalty: 0
|
||||
};
|
||||
|
||||
let apiKey = process.env.OPENAI_KEY;
|
||||
let apiKey = oaiApiKey || process.env.OPENAI_KEY;
|
||||
|
||||
if (azure) {
|
||||
apiKey = process.env.AZURE_OPENAI_API_KEY;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue