Skip to content

Commit

Permalink
🐛 fix: fix bedrock show by default on vercel (lobehub#2634)
Browse files Browse the repository at this point in the history
* 🐛 fix: fix bedrock show by default

* try to log aws key

* try to log aws key

* 🐛 fix: hide Bedrock by default
  • Loading branch information
arvinxx authored May 25, 2024
1 parent d7d34d1 commit 7ad3af2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 63 deletions.
7 changes: 7 additions & 0 deletions docs/self-hosting/environment-variables/model-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ If you need to use Azure OpenAI to provide model services, you can refer to the

## AWS Bedrock

### `ENABLED_AWS_BEDROCK`

- Type:Optional
- Description:Enables AWS Bedrock as a model provider by default, turns on the AWS Bedrock service when set to `1`
- Default:`0`
- Example:`1`

### `AWS_ACCESS_KEY_ID`

- Type: Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,

## AWS Bedrock

### `ENABLED_AWS_BEDROCK`

- 类型:可选
- 描述:当设为 1 时启用 AWS Bedrock 服务
- 默认值:`0`
- 示例:`1`

### `AWS_ACCESS_KEY_ID`

- 类型:必选
Expand Down
102 changes: 39 additions & 63 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,6 @@ declare global {
}

export const getLLMConfig = () => {
const AZURE_API_KEY = process.env.AZURE_API_KEY || '';

const ZHIPU_API_KEY = process.env.ZHIPU_API_KEY || '';

const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID || '';

const DEEPSEEK_API_KEY = process.env.DEEPSEEK_API_KEY || '';

const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || '';

const MOONSHOT_API_KEY = process.env.MOONSHOT_API_KEY || '';

const PERPLEXITY_API_KEY = process.env.PERPLEXITY_API_KEY || '';

const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || '';

const MINIMAX_API_KEY = process.env.MINIMAX_API_KEY || '';

const MISTRAL_API_KEY = process.env.MISTRAL_API_KEY || '';

const GROQ_API_KEY = process.env.GROQ_API_KEY || '';

const OPENROUTER_API_KEY = process.env.OPENROUTER_API_KEY || '';

const ZEROONE_API_KEY = process.env.ZEROONE_API_KEY || '';

const TOGETHERAI_API_KEY = process.env.TOGETHERAI_API_KEY || '';

// region format: iad1,sfo1
let regions: string[] = [];
if (process.env.OPENAI_FUNCTION_REGIONS) {
regions = process.env.OPENAI_FUNCTION_REGIONS.split(',');
}

if (process.env.CUSTOM_MODELS) {
console.warn(
'DEPRECATED: `CUSTOM_MODELS` is deprecated, please use `OPENAI_MODEL_LIST` instead, we will remove `CUSTOM_MODELS` in the LobeChat 1.0',
Expand All @@ -75,6 +41,16 @@ export const getLLMConfig = () => {
);
}

// region format: iad1,sfo1
let regions: string[] = [];
if (process.env.OPENAI_FUNCTION_REGIONS) {
regions = process.env.OPENAI_FUNCTION_REGIONS.split(',');
}

console.log('AWS_REGION:', process.env.AWS_REGION);
console.log('AWS_ACCESS_KEY_ID:', process.env.AWS_ACCESS_KEY_ID);
console.log('AWS_SECRET_ACCESS_KEY:', process.env.AWS_SECRET_ACCESS_KEY);

return createEnv({
server: {
API_KEY_SELECT_MODE: z.string().optional(),
Expand Down Expand Up @@ -152,60 +128,60 @@ export const getLLMConfig = () => {
OPENAI_MODEL_LIST: process.env.OPENAI_MODEL_LIST || process.env.CUSTOM_MODELS,
OPENAI_FUNCTION_REGIONS: regions as any,

ENABLED_AZURE_OPENAI: !!AZURE_API_KEY,
AZURE_API_KEY,
ENABLED_AZURE_OPENAI: !!process.env.AZURE_API_KEY,
AZURE_API_KEY: process.env.AZURE_API_KEY,
AZURE_API_VERSION: process.env.AZURE_API_VERSION,
AZURE_ENDPOINT: process.env.AZURE_ENDPOINT,
AZURE_MODEL_LIST: process.env.AZURE_MODEL_LIST,

ENABLED_ZHIPU: !!ZHIPU_API_KEY,
ZHIPU_API_KEY,
ENABLED_ZHIPU: !!process.env.ZHIPU_API_KEY,
ZHIPU_API_KEY: process.env.ZHIPU_API_KEY,

ENABLED_DEEPSEEK: !!DEEPSEEK_API_KEY,
DEEPSEEK_API_KEY,
ENABLED_DEEPSEEK: !!process.env.DEEPSEEK_API_KEY,
DEEPSEEK_API_KEY: process.env.DEEPSEEK_API_KEY,

ENABLED_GOOGLE: !!GOOGLE_API_KEY,
GOOGLE_API_KEY,
ENABLED_GOOGLE: !!process.env.GOOGLE_API_KEY,
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY,
GOOGLE_PROXY_URL: process.env.GOOGLE_PROXY_URL,

ENABLED_PERPLEXITY: !!PERPLEXITY_API_KEY,
PERPLEXITY_API_KEY,
ENABLED_PERPLEXITY: !!process.env.PERPLEXITY_API_KEY,
PERPLEXITY_API_KEY: process.env.PERPLEXITY_API_KEY,
PERPLEXITY_PROXY_URL: process.env.PERPLEXITY_PROXY_URL,

ENABLED_ANTHROPIC: !!ANTHROPIC_API_KEY,
ANTHROPIC_API_KEY,
ENABLED_ANTHROPIC: !!process.env.ANTHROPIC_API_KEY,
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
ANTHROPIC_PROXY_URL: process.env.ANTHROPIC_PROXY_URL,

ENABLED_MINIMAX: !!MINIMAX_API_KEY,
MINIMAX_API_KEY,
ENABLED_MINIMAX: !!process.env.MINIMAX_API_KEY,
MINIMAX_API_KEY: process.env.MINIMAX_API_KEY,

ENABLED_MISTRAL: !!MISTRAL_API_KEY,
MISTRAL_API_KEY,
ENABLED_MISTRAL: !!process.env.MISTRAL_API_KEY,
MISTRAL_API_KEY: process.env.MISTRAL_API_KEY,

ENABLED_OPENROUTER: !!OPENROUTER_API_KEY,
OPENROUTER_API_KEY,
ENABLED_OPENROUTER: !!process.env.OPENROUTER_API_KEY,
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
OPENROUTER_MODEL_LIST:
process.env.OPENROUTER_MODEL_LIST || process.env.OPENROUTER_CUSTOM_MODELS,

ENABLED_TOGETHERAI: !!TOGETHERAI_API_KEY,
TOGETHERAI_API_KEY,
ENABLED_TOGETHERAI: !!process.env.TOGETHERAI_API_KEY,
TOGETHERAI_API_KEY: process.env.TOGETHERAI_API_KEY,
TOGETHERAI_MODEL_LIST: process.env.TOGETHERAI_MODEL_LIST,

ENABLED_MOONSHOT: !!MOONSHOT_API_KEY,
MOONSHOT_API_KEY,
ENABLED_MOONSHOT: !!process.env.MOONSHOT_API_KEY,
MOONSHOT_API_KEY: process.env.MOONSHOT_API_KEY,
MOONSHOT_PROXY_URL: process.env.MOONSHOT_PROXY_URL,

ENABLED_GROQ: !!GROQ_API_KEY,
ENABLED_GROQ: !!process.env.GROQ_API_KEY,
GROQ_API_KEY: process.env.GROQ_API_KEY,
GROQ_PROXY_URL: process.env.GROQ_PROXY_URL,
GROQ_API_KEY,

ENABLED_ZEROONE: !!ZEROONE_API_KEY,
ZEROONE_API_KEY,
ENABLED_ZEROONE: !!process.env.ZEROONE_API_KEY,
ZEROONE_API_KEY: process.env.ZEROONE_API_KEY,

ENABLED_AWS_BEDROCK: !!AWS_ACCESS_KEY_ID,
ENABLED_AWS_BEDROCK: process.env.ENABLED_AWS_BEDROCK === '1',
AWS_REGION: process.env.AWS_REGION,
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || '',
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,

ENABLED_OLLAMA: process.env.ENABLED_OLLAMA !== '0',
OLLAMA_PROXY_URL: process.env.OLLAMA_PROXY_URL || '',
Expand Down

0 comments on commit 7ad3af2

Please sign in to comment.