我目前正在利用 LangChain 来查询和解析 VertexAI 模型的输出。最近,在 Google Cloud Platform (GCP) 中从测试项目转换到生产项目并通过
gcloud init
在本地更新凭据时,我的请求被拒绝。我遇到的错误信息如下:
{
"detail": "403 Permission 'aiplatform.endpoints.predict' denied on resource '//aiplatform.googleapis.com/projects/my-project/locations/us-central1/publishers/google/models/textembedding-gecko@003' (or it may not exist). [reason: \"IAM_PERMISSION_DENIED\"\ndomain: \"aiplatform.googleapis.com\"\nmetadata {\n key: \"resource\"\n value: \"projects/my-project/locations/us-central1/publishers/google/models/textembedding-gecko@003\"\n}\nmetadata {\n key: \"permission\"\n value: \"aiplatform.endpoints.predict\"\n}\n]"
}
我的区域配置为
us-central1
,并且我已将“所有者”角色分配给我正在使用的帐户,这与我在测试项目中拥有的权限级别相同,它运行时没有出现问题。
我尝试创建具有不同权限的不同服务帐户,从 AIplatform 到 AIplatform 和 VertexAI 所有者,但都没有解决问题。我还尝试过更改区域以匹配我在 GCP 上使用的其他服务,但这也不起作用。
为了清楚起见,以下是我在代码中设置模型对象的方法:
from langchain_google_vertexai import VertexAIEmbeddings
from langchain_google_vertexai import VertexAI
model = VertexAI(project=config["gcpProjectID"], model_name="text-bison@002", temperature=0.0)
embeddings = VertexAIEmbeddings(project=config["gcpProjectID"], model_name="textembedding-gecko")
我不知道这个问题的原因,非常感谢任何有关如何继续的建议。
提前致谢。
确保您的计算机已使用
gcloud auth login
或 gcloud auth application-default login
通过 gcloud 进行身份验证