UiPath Documentation
activities
latest
false
Integration Service 活动
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

执行 Google Vertex 智能体

使用执行连接器执行 Google Vertex Agent。

描述​

Vertex AI 智能体是 Google Cloud Vertex AI 平台上运行的自主软件系统,利用生成式 AI 与用户或其他智能体一起理解、推理、规划和完成任务。

这些智能体的核心部分是 Vertex AI 智能体引擎,该引擎可为在生产中开发、部署和扩展智能体提供托管运行时。

此活动支持将部署到智能体引擎的智能体作为 Maestro 编排的自动化流程的参与者。

创建 Vertex 智能体​

基于 Vertex AI Agent Engine 的智能体部署方式在不断发展。目前,这是 Vertex AI 中的代码优先配置。Google Vertex 连接器支持智能体引擎支持的所有框架。(例如:google-adk)。

成功部署 Vertex AI 智能体后,系统会在Vertex AI > Agent Builder >智能体引擎下的 Google Cloud 项目下组织该智能体。准备与 UiPath 集成的智能体必须可见,并且在 URL 下分配了资源名称,如下所示:

projects/771273109380/locations/us-central1/reasoningEngines/7522902537708503040
projects/771273109380/locations/us-central1/reasoningEngines/7522902537708503040

在此示例中,项目 ID 为771273109380 。

在大多数 Maestro 场景中,您会提示智能体以 JSON 结构的形式生成输出。例如{"sku1": "9735A45", "sku2": "1735A50"}。

如何使用活动​

要在 Maestro 智能体流程中使用此活动,请按照以下步骤操作:

  1. 在画布中添加服务任务元素,然后打开任务的“属性”面板。
  2. 将服务任务命名为Vertex Hello World 。
  3. 在实施部分的操作下拉列表中,选择启动并等待外部智能体。
  4. 选择Google Vertex连接器。
  5. 选择现有连接或新建连接。有关更多信息,请参阅Google Vertex 身份验证。
  6. 从“活动”中,选择“执行 Google Vertex Agent” 。
  7. 从“智能体名称”中,选择您先前在 Vertex AI 中创建的智能体(例如ORDERS_AGENT)。请注意,使用错误的服务帐户密钥将导致您收到的下拉列表中包含意外智能体,或者根本不包含智能体。
  8. 在“消息”字段中,输入"What can you do?" 。确保在提示词中添加引号。
  9. 在“用户 ID”字段中,输入user 。
  10. 将开始事件连接到服务任务,然后将服务任务连接到画布上的结束事件节点。
  11. 选择“调试”以运行此流程。成功运行后,查看“全局变量”并查找来自源“折点”的{:} 响应。记下回复的结构。例如,以下是智能体对“你可以做什么?”提示的响应:
    {
      "usage_metadata": {
        "candidates_token_count": 404,
        "thoughts_token_count": 46,
        "total_token_count": 1229,
        "prompt_tokens_details": [
          {
            "token_count": 779,
            "modality": "TEXT"
          }
        ],
        "traffic_type": "ON_DEMAND",
        "candidates_tokens_details": [
          {
            "token_count": 404,
            "modality": "TEXT"
          }
        ],
        "prompt_token_count": 779
      },
      "author": "loan_eligibility_agent",
      "invocation_id": "e-a496b1b8-fb54-4120-9aa2-7fac34e1d04d",
      "session_id": "3080378032481894400",
      "id": "26G1y9He",
      "content": {
        "parts": [
          {
            "text": "I am a loan eligibility evaluation agent. My primary function is to assess whether a loan applicant is eligible for approval based on a predefined set of criteria.\n\nHere's what I can do:\n\n1.  **Receive Loan Application Details:** I expect loan application details in a JSON format. If I don't receive it, I will prompt you to provide it.\n2.  **Evaluate Against Criteria:** I will evaluate each field in the provided JSON against specific eligibility criteria, which include:\n    *   Age (21-60)\n    *   Employment status and duration (employed, min 12 months)\n    *   Monthly net income (min $2,500 USD)\n    *   Credit Score (min 650)\n    *   Debt-to-Income Ratio (monthly obligations <= 40% of income)\n    *   Residency Status (legal resident/citizen)\n    *   Loan Purpose (specific allowed purposes, no disallowed ones)\n3.  **Determine Eligibility:** Based on the evaluation, I will determine one of three outcomes:\n    *   `eligible`: If all standard criteria are met.\n    *   `not eligible`: If one or more core criteria are failed, and no compelling justification is provided.\n    *   `manual review: other_criteria`: If one or more core criteria are failed, but an \"other_criteria\" explanation is provided that might justify an exception (e.g., medical hardship, protected populations, employment transition).\n4.  **Provide Justification:** For every determination, I will provide a detailed explanation outlining how the decision was reached, referencing the specific parameters from the eligibility criteria and the applicant's data.\n5.  **Output in JSON:** My final output will always be a JSON object containing the `determination` and `justification`.\n\nEssentially, I automate the initial screening process for personal loan applications according to established rules."
          }
        ],
        "role": "model"
      },
      "timestamp": 1758552780.125623
    }
    {
      "usage_metadata": {
        "candidates_token_count": 404,
        "thoughts_token_count": 46,
        "total_token_count": 1229,
        "prompt_tokens_details": [
          {
            "token_count": 779,
            "modality": "TEXT"
          }
        ],
        "traffic_type": "ON_DEMAND",
        "candidates_tokens_details": [
          {
            "token_count": 404,
            "modality": "TEXT"
          }
        ],
        "prompt_token_count": 779
      },
      "author": "loan_eligibility_agent",
      "invocation_id": "e-a496b1b8-fb54-4120-9aa2-7fac34e1d04d",
      "session_id": "3080378032481894400",
      "id": "26G1y9He",
      "content": {
        "parts": [
          {
            "text": "I am a loan eligibility evaluation agent. My primary function is to assess whether a loan applicant is eligible for approval based on a predefined set of criteria.\n\nHere's what I can do:\n\n1.  **Receive Loan Application Details:** I expect loan application details in a JSON format. If I don't receive it, I will prompt you to provide it.\n2.  **Evaluate Against Criteria:** I will evaluate each field in the provided JSON against specific eligibility criteria, which include:\n    *   Age (21-60)\n    *   Employment status and duration (employed, min 12 months)\n    *   Monthly net income (min $2,500 USD)\n    *   Credit Score (min 650)\n    *   Debt-to-Income Ratio (monthly obligations <= 40% of income)\n    *   Residency Status (legal resident/citizen)\n    *   Loan Purpose (specific allowed purposes, no disallowed ones)\n3.  **Determine Eligibility:** Based on the evaluation, I will determine one of three outcomes:\n    *   `eligible`: If all standard criteria are met.\n    *   `not eligible`: If one or more core criteria are failed, and no compelling justification is provided.\n    *   `manual review: other_criteria`: If one or more core criteria are failed, but an \"other_criteria\" explanation is provided that might justify an exception (e.g., medical hardship, protected populations, employment transition).\n4.  **Provide Justification:** For every determination, I will provide a detailed explanation outlining how the decision was reached, referencing the specific parameters from the eligibility criteria and the applicant's data.\n5.  **Output in JSON:** My final output will always be a JSON object containing the `determination` and `justification`.\n\nEssentially, I automate the initial screening process for personal loan applications according to established rules."
          }
        ],
        "role": "model"
      },
      "timestamp": 1758552780.125623
    }
    

智能体的输出必须分配给流程变量,以便影响 Maestro 流程的进度,例如,根据布尔值评估做出决策,或使用分类任务的答案。

  1. 在设计模式下,从设计画布中选择智能体。
  2. 选择( “属性” >“属性” )。
  3. 在“输出”下,选择“新增” ,然后添加一个名为agent_reponse 的字符串类型变量。
  4. 对于“值”,选择“Vertex Hello World” > “response(对象)” > “Content(对象)” > “Content text(字符串)” 。
提示:

在实践中,指定您选择的智能体的结构化输出,然后使用表达式编辑器在 Maestro 中评估输出,以按照流程所需的类型提取所需的输出的特定部分。

故障排除和调整​

除了建立连接外,您还应该在 Vertex 工作区和 Maestro 中测试提示词。这可确保您获得所需的输出,这些输出最适合 Maestro 使用,分配给变量,并传递给流程中的其他参与者。

我们建议将详细提示保留在 Vertex 中智能体的系统提示中。Maestro 在运行时向智能体提供的用户提示应该简明扼要。其作用主要是指示智能体执行特定任务并生成预期的一致输出所需的相关变量。

针对人类的输出(例如升级原因)可以轻松地作为自然文本传递给人类。API/机器人操作的预期输出必须经过严格撰写。以下是智能体生成特定输出的用户提示示例。使用 Studio 中的 C# 表达式编辑器根据需要添加变量。

"What is the quantity on inventory of Order ID " + vars.orderId_1 + "respond only with a JSON object with the quantity in the key Order_Quantity. No explanations, only JSON"
"What is the quantity on inventory of Order ID " + vars.orderId_1 + "respond only with a JSON object with the quantity in the key Order_Quantity. No explanations, only JSON"

智能体将回复:

{"Order_Quantity":"100"}
{"Order_Quantity":"100"}

类型处理​

请特别注意您向智能体发出的请求和实际响应中所包含的类型。即使响应看起来像JSON类型,它实际上可能是string类型。

  • 描述​
  • 创建 Vertex 智能体​
  • 如何使用活动​
  • 故障排除和调整​
  • 类型处理​

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新