LangChain中Google ChatVertexAI模型地域设置无效,求正确配置方法
解决LangChain中ChatVertexAI地域设置不生效的问题
- 直接在ChatVertexAI构造参数顶层设置
location参数不会生效,正确的方式是将地域配置嵌套在clientOptions中传递。 - 修正后的可用代码:
import { ChatVertexAI } from "@langchain/google-vertexai"; const model = new ChatVertexAI({ model: 'gemini-1.0-pro', temperature: 0.01, clientOptions: { location: 'northamerica-northeast1' } });
- 另一种可选方式:通过
apiEndpoint直接指定对应地域的API端点(适用于新版包):
import { ChatVertexAI } from "@langchain/google-vertexai"; const model = new ChatVertexAI({ model: 'gemini-1.0-pro', temperature: 0.01, apiEndpoint: 'northamerica-northeast1-aiplatform.googleapis.com' });
内容的提问来源于stack exchange,提问作者Michael Hua
相关产品推荐
相关产品推荐

