File size: 968 Bytes
9705b6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const {
  OPENAI_API_KEY: openAIApiKey,
  AZURE_API_KEY: azureOpenAIApiKey,
  ANTHROPIC_API_KEY: anthropicApiKey,
  CHATGPT_TOKEN: chatGPTToken,
  BINGAI_TOKEN: bingToken,
  PLUGINS_USE_AZURE,
  PALM_KEY: palmKey,
} = process.env ?? {};

const useAzurePlugins = !!PLUGINS_USE_AZURE;

const userProvidedOpenAI = useAzurePlugins
  ? azureOpenAIApiKey === 'user_provided'
  : openAIApiKey === 'user_provided';

function isUserProvided(key) {
  return key ? { userProvide: key === 'user_provided' } : false;
}

const openAI = isUserProvided(openAIApiKey);
const azureOpenAI = isUserProvided(azureOpenAIApiKey);
const bingAI = isUserProvided(bingToken);
const chatGPTBrowser = isUserProvided(chatGPTToken);
const anthropic = isUserProvided(anthropicApiKey);

module.exports = {
  config: {
    openAIApiKey,
    azureOpenAIApiKey,
    useAzurePlugins,
    userProvidedOpenAI,
    palmKey,
    openAI,
    azureOpenAI,
    chatGPTBrowser,
    anthropic,
    bingAI,
  },
};