🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
📝 docs: add Vertex AI configuration options and update documentation (#10331)
bbbuggc5d1b0494a97
diff --git a/Dockerfile b/Dockerfileindex 697e2b118cc..7da9cadad48 100644--- a/Dockerfile+++ b/Dockerfile@@ -231,6 +231,8 @@ ENV \GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \GOOGLE_API_KEY="" GOOGLE_MODEL_LIST="" GOOGLE_PROXY_URL="" \+ # Vertex AI+ VERTEXAI_CREDENTIALS="" VERTEXAI_PROJECT="" VERTEXAI_LOCATION="" VERTEXAI_MODEL_LIST="" \# GroqGROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \# Higressdiff --git a/docs/self-hosting/environment-variables/model-provider.mdx b/docs/self-hosting/environment-variables/model-provider.mdxindex 87e0811f1f9..29d5cee4f14 100644--- a/docs/self-hosting/environment-variables/model-provider.mdx+++ b/docs/self-hosting/environment-variables/model-provider.mdx@@ -121,6 +121,37 @@ If you need to use Azure OpenAI to provide model services, you can refer to the- Default: `-`- Example: `-all,+gemini-1.5-flash-latest,+gemini-1.5-pro-latest`+## Vertex AI++### `VERTEXAI_CREDENTIALS`++- Type: Required+- Description: A JSON string of your Google Cloud service account key, you can get the key from [here](/docs/usage/providers/vertexai).+- Default: -+- Example: `{"type": "service_account", "project_id": "your-gcp-project-id", ...}`++### `VERTEXAI_PROJECT`++- Type: Optional+- Description: Your Google Cloud project ID. If not set, it will be obtained from the `project_id` field in `VERTEXAI_CREDENTIALS`.+- Default: -+- Example: `your-gcp-project-id`++### `VERTEXAI_LOCATION`++- Type: Optional+- Description: The region where your Vertex AI model is located.+- Default: `global`+- Example: `us-central1`+++### `VERTEXAI_MODEL_LIST`++- Type: Optional+- Description: Used to control the model list, use `+` to add a model, use `-` to hide a model, use `model_name=display_name` to customize the display name of a model, separated by commas. Definition syntax rules see [model-list][model-list]+- Default: `-`+- Example: `-all,+gemini-1.5-flash-latest,+gemini-1.5-pro-latest`+## Anthropic AI### `ANTHROPIC_API_KEY`diff --git a/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx b/docs/self-hosting/environment-variables/model-provider.zh-CN.mdxindex bc69a681607..60cf064f26e 100644--- a/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx+++ b/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx@@ -119,6 +119,36 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,- 默认值:`-`- 示例:`-all,+gemini-1.5-flash-latest,+gemini-1.5-pro-latest`+## Vertex AI++### `VERTEXAI_CREDENTIALS`++- 类型:必选+- 描述:Google Cloud 服务账号密钥的 JSON 字符串。用于认证和授权访问 Vertex AI 服务,获取方法请参考 [这里](/zh/docs/usage/providers/vertexai)+- 默认值:-+- 示例:`{"type": "service_account", "project_id": "your-gcp-project-id", ...}`++### `VERTEXAI_PROJECT`++- 类型:可选+- 描述:你的 Google Cloud 项目 ID。如果未设置,将从 `VERTEXAI_CREDENTIALS` 中的 `project_id` 字段获取。+- 默认值:-+- 示例:`your-gcp-project-id`++### `VERTEXAI_LOCATION`++- 类型:可选+- 描述:你的 Vertex AI 模型所在的区域。+- 默认值:`global`+- 示例:`us-central1`++### `VERTEXAI_MODEL_LIST`++- 类型:可选+- 描述:用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名<扩展配置>` 来自定义模型的展示名,用英文逗号隔开。模型定义语法规则见 [模型列表][model-list]+- 默认值:`-`+- 示例:`-all,+gemini-1.5-flash-latest,+gemini-1.5-pro-latest`+## Anthropic AI### `ANTHROPIC_API_KEY`diff --git a/src/config/modelProviders/vertexai.ts b/src/config/modelProviders/vertexai.tsindex 27f84be3541..95fe23f8b17 100644--- a/src/config/modelProviders/vertexai.ts+++ b/src/config/modelProviders/vertexai.ts@@ -3,7 +3,7 @@ import { ModelProviderCard } from '@/types/llm';// ref: https://ai.google.dev/gemini-api/docs/models/geminiconst VertexAI: ModelProviderCard = {chatModels: [],- checkModel: 'gemini-1.5-flash-001',+ checkModel: 'gemini-2.0-flash',description:'Google 的 Gemini 系列是其最先进、通用的 AI模型,由 Google DeepMind 打造,专为多模态设计,支持文本、代码、图像、音频和视频的无缝理解与处理。适用于从数据中心到移动设备的多种环境,极大提升了AI模型的效率与应用广泛性。',id: 'vertexai',diff --git a/src/envs/llm.ts b/src/envs/llm.tsindex de88ada8b87..2b266c76439 100644--- a/src/envs/llm.ts+++ b/src/envs/llm.ts@@ -28,6 +28,8 @@ export const getLLMConfig = () => {ENABLED_GOOGLE: z.boolean(),GOOGLE_API_KEY: z.string().optional(),+ ENABLED_VERTEXAI: z.boolean(),+ENABLED_MOONSHOT: z.boolean(),MOONSHOT_API_KEY: z.string().optional(),@@ -237,6 +239,8 @@ export const getLLMConfig = () => {ENABLED_GOOGLE: !!process.env.GOOGLE_API_KEY,GOOGLE_API_KEY: process.env.GOOGLE_API_KEY,+ ENABLED_VERTEXAI: !!process.env.VERTEXAI_CREDENTIALS,+ENABLED_VOLCENGINE: !!process.env.VOLCENGINE_API_KEY,VOLCENGINE_API_KEY: process.env.VOLCENGINE_API_KEY,diff --git a/src/server/modules/ModelRuntime/index.ts b/src/server/modules/ModelRuntime/index.tsindex 02d4ec524b2..9dde39779d6 100644--- a/src/server/modules/ModelRuntime/index.ts+++ b/src/server/modules/ModelRuntime/index.ts@@ -162,18 +162,18 @@ const buildVertexOptions = (payload: ClientSecretPayload,params: Partial<GoogleGenAIOptions> = {},): GoogleGenAIOptions => {- const rawCredentials = payload.apiKey ?? process.env.VERTEXAI_CREDENTIALS ?? '';+ const rawCredentials = payload.apiKey || process.env.VERTEXAI_CREDENTIALS || '';const credentials = safeParseJSON<Record<string, string>>(rawCredentials);const projectFromParams = params.project as string | undefined;const projectFromCredentials = credentials?.project_id;const projectFromEnv = process.env.VERTEXAI_PROJECT;- const project = projectFromParams ?? projectFromCredentials ?? projectFromEnv;+ const project = projectFromParams || projectFromCredentials || projectFromEnv;const location =- (params.location as string | undefined) ?? payload.vertexAIRegion ?? process.env.VERTEXAI_LOCATION ?? undefined;+ (params.location as string | undefined) || payload.vertexAIRegion || process.env.VERTEXAI_LOCATION || undefined;- const googleAuthOptions = params.googleAuthOptions ?? (credentials ? { credentials } : undefined);+ const googleAuthOptions = params.googleAuthOptions || (credentials ? { credentials } : undefined);const options: GoogleGenAIOptions = {...params,