使用应用进行问题排查

本文档介绍如何解决在使用应用时可能发生的错误。

操作架构为空

如果您的应用根据 .operation_schemas() 返回一个空列表,则可能是以下某一问题导致的:

在创建应用期间生成架构失败

问题

部署应用时,您会收到类似以下内容的警告:

WARNING:vertexai.reasoning_engines._reasoning_engines:failed to generate schema: issubclass() arg 1 must be a class

可能的原因

如果您在低于 1.49.0google-cloud-aiplatform 版本上使用预构建的 LangchainAgent 模板部署应用,则可能会出现此警告。如需检查您所使用的版本,请在终端中运行以下命令:

pip show google-cloud-aiplatform

推荐的解决方案

在终端中运行以下命令以更新 google-cloud-aiplatform 软件包:

pip install google-cloud-aiplatform --upgrade

更新 google-cloud-aiplatform 软件包后,请运行以下命令以验证其版本是否为 1.49.0 或更高版本:

pip show google-cloud-aiplatform

如果您在使用笔记本实例(例如 Jupyter、Colab 或 Workbench),则可能需要重启运行时才能使用更新后的软件包。当您验证 google-cloud-aiplatform 版本为 1.49.0 或更高版本后,请尝试再次部署您的应用

查询应用时出现 PermissionDenied 错误

如果您没有所需的权限,您的查询可能会失败。

LLM 权限

问题

您可能会收到类似于以下内容的 PermissionDenied 错误:

PermissionDenied: 403 Permission 'aiplatform.endpoints.predict' denied on resource 
'//aiplatform.googleapis.com/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/
google/models/{MODEL}' (or it may not exist). [reason: "IAM_PERMISSION_DENIED"
domain: "aiplatform.googleapis.com"
metadata {
  key: "permission"
  value: "aiplatform.endpoints.predict"
}
metadata {
  key: "resource"
  value: "projects/{PROJECT_ID}/locations/{LOCATION}/publishers/google/models/{MODEL}"
}
]

可能的原因

您的服务账号可能没有适当的权限来查询您的大语言模型 (LLM)。

推荐的解决方案

确保您的服务账号具有错误消息中列出的适当 Identity and Access Management (IAM) 权限。您可能缺少的 IAM 权限的一个例子是 aiplatform.endpoints.predict。如需了解详情,请参阅设置服务代理权限

请求无效

如果您在查询应用时遇到请求无效的问题,那么这可能是由本部分中所述的某个问题所导致的。

FailedPrecondition

问题

您可能会收到类似于以下内容的 FailedPrecondition 错误:

FailedPrecondition: 400 Reasoning Engine Execution failed. Error Details:
{"detail":"Invalid request: `{'query': ...}`"}

可能的原因

如果您调用 agent.query(query_str) 而不是 agent.query(input=query_str)(也就是将查询的输入指定为位置参数而不是关键字参数),则可能会发生这种情况。

推荐的解决方案

查询已部署的推理引擎实例时,请将所有输入指定为关键字参数(例如 agent.query(input=query_str))。