初始化GemmaVertexAIModelGarden失败:端点名称无效排查求助
问题
按照Colab官方教程《Get started with Gemma and LangChain》部署Model Garden中的模型,填入获取到的项目ID、端点ID和位置参数后,运行代码触发InvalidArgument错误,提示端点名称无效。
运行代码
from langchain_google_vertexai import GemmaVertexAIModelGarden, GemmaChatVertexAIModelGarden llm = GemmaVertexAIModelGarden( endpoint_id=endpoint_id, project=project, location=location, ) output = llm.invoke("What is the meaning of life?") print(output)
报错栈
_InactiveRpcError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs) 75 try: ---> 76 return callable_(*args, **kwargs) 77 except grpc.RpcError as exc: 11 frames _InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy." debug_error_string = "UNKNOWN:Error received from peer ipv4:173.194.215.95:443 {created_time:"2024-08-02T15:38:59.269976555+00:00", grpc_status:3, grpc_message:"Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy."}" > The above exception was the direct cause of the following exception: InvalidArgument Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs) 76 return callable_(*args, **kwargs) 77 except grpc.RpcError as exc: ---> 78 raise exceptions.from_grpc_error(exc) from exc 79 80 return error_remapped_callable InvalidArgument: 400 Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy.
问题原因与解决方法
- 核心原因:传入的
endpoint_id参数错误,你用了模型的部署名称google_gemma-1_1-2b-it-mg-one-click-deploy,但Vertex AI要求端点ID是一串纯数字的标识符,而非模型名称。 - 解决步骤:
- 打开Google Cloud控制台,进入Vertex AI -> 端点页面
- 找到你部署的Gemma模型对应的端点,复制其纯数字格式的端点ID
- 将代码中的
endpoint_id参数替换为这串数字ID - 重新运行代码验证
内容的提问来源于stack exchange,提问作者chanp
相关产品推荐
相关产品推荐

