管理已部署的代理
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页介绍了如何管理已部署到 Agent Engine 托管运行时的代理。在 Vertex AI 中,已部署的代理是 reasoningEngine
类型的资源。
列出已部署的代理
列出给定项目和位置的所有已部署代理:
Python 版 Vertex AI SDK
from vertexai import agent_engines
agent_engines.list()
如需按 display_name
过滤列表,请执行以下操作:
from vertexai import agent_engines
agent_engines.list(filter='display_name="Demo Langchain Agent"')
REST
调用 reasoningEngines.list
方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID
:您的 GCP 项目 ID
LOCATION
:支持的区域
HTTP 方法和网址:
GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines" | Select-Object -Expand Content
您应该会收到一个成功的状态代码 (2xx) 和一个空响应。
获取已部署的代理
每个已部署的代理都有一个唯一的 RESOURCE_ID
标识符。如需了解详情,请参阅部署代理。
Python 版 Vertex AI SDK
通过以下代码,您可以获取特定的已部署代理:
from vertexai import agent_engines
remote_agent = agent_engines.get("RESOURCE_ID")
或者,您也可以提供完全限定的资源名称:
from vertexai import agent_engines
remote_agent = agent_engines.get(
"projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID"
)
REST
调用 reasoningEngines.get
方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID
:您的 GCP 项目 ID
LOCATION
:支持的区域
RESOURCE_ID
:已部署代理的资源 ID
HTTP 方法和网址:
GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID"
PowerShell (Windows)
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID" | Select-Object -Expand Content
您应该会收到一个成功的状态代码 (2xx) 和一个空响应。
更新已部署的代理
您可以同时更新已部署代理的一个或多个字段,但必须至少指定一个要更新的字段。更新已部署的代理所需的时间取决于所执行的更新,但通常需要几秒到几分钟。
Python 版 Vertex AI SDK
如需将已部署的代理(对应于 RESOURCE_NAME
)更新为更新后的代理(对应于 UPDATED_AGENT
),请执行以下操作:
from vertexai import agent_engines
agent_engines.update(
resource_name=RESOURCE_NAME, # Required.
agent_engine=UPDATED_AGENT, # Optional.
requirements=REQUIREMENTS, # Optional.
display_name="DISPLAY_NAME", # Optional.
description="DESCRIPTION", # Optional.
extra_packages=EXTRA_PACKAGES, # Optional.
)
这些参数与部署代理时使用的参数相同。您可以在 API 参考文档中找到详细信息。
REST
调用 reasoningEngines.patch
方法并提供 update_mask
以指定要更新的字段。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID
:您的 GCP 项目 ID
LOCATION
:支持的区域
RESOURCE_ID
:已部署代理的资源 ID
update_mask
:要更新的以英文逗号分隔的字段列表
HTTP 方法和网址:
PATCH https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID?update_mask="display_name,description"
请求 JSON 正文:
{
"displayName": "DISPLAY_NAME",
"description": "DESCRIPTION"
}
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID?update_mask="display_name,description""
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID?update_mask="display_name,description"" | Select-Object -Expand Content
您应该会收到一个成功的状态代码 (2xx) 和一个空响应。
删除已部署的代理
Python 版 Vertex AI SDK
如果您已经有已部署的代理的实例(以 remote_agent
的形式),则可以运行以下命令:
remote_agent.delete()
或者,您也可以调用 agent_engines.delete()
以以下方式删除与 RESOURCE_NAME
对应的已部署代理:
from vertexai import agent_engines
agent_engines.delete(RESOURCE_NAME)
REST
调用 reasoningEngines.delete
方法。
在使用任何请求数据之前,请先进行以下替换:
PROJECT_ID
:您的 GCP 项目 ID
LOCATION
:支持的区域
RESOURCE_ID
:已部署代理的资源 ID
HTTP 方法和网址:
DELETE https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID
请求 JSON 正文:
{
"displayName": "DISPLAY_NAME",
"description": "DESCRIPTION"
}
如需发送您的请求,请展开以下选项之一:
curl(Linux、macOS 或 Cloud Shell)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID"
PowerShell (Windows)
将请求正文保存在名为 request.json
的文件中,然后执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/RESOURCE_ID" | Select-Object -Expand Content
您应该会收到一个成功的状态代码 (2xx) 和一个空响应。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-04。"],[],[]]