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:
Danny Avila 2023-07-13 23:59:14 -04:00 committed by GitHub
parent 3e5c5a828d
commit 1b999108e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 14 deletions

View file

@ -2,7 +2,7 @@
const _ = require('lodash');
const { genAzureChatCompletion, getAzureCredentials } = require('../utils/');
const titleConvo = async ({ text, response, oaiApiKey }) => {
const titleConvo = async ({ text, response, openAIApiKey, azure = false }) => {
let title = 'New Chat';
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
@ -19,7 +19,6 @@ const titleConvo = async ({ text, response, oaiApiKey }) => {
||>Title:`
};
const azure = process.env.AZURE_API_KEY ? true : false;
const options = {
azure,
reverseProxyUrl: process.env.OPENAI_REVERSE_PROXY || null,
@ -35,7 +34,9 @@ const titleConvo = async ({ text, response, oaiApiKey }) => {
frequency_penalty: 0
};
let apiKey = oaiApiKey || process.env.OPENAI_API_KEY;
let apiKey = openAIApiKey ?? process.env.OPENAI_API_KEY;
console.log('title api key', apiKey);
if (azure) {
apiKey = process.env.AZURE_API_KEY;