Link Search Menu Expand Document Documentation Menu

智能体工具

2.13 版本引入

AgentTool 运行任何代理。

步骤 1:为 AgentTool 设置一个代理

设置任何代理。例如,按照 ML 模型工具文档中的步骤设置一个运行 MLModelTool 的流程代理,并从步骤 3 获取其代理 ID

{
  "agent_id": "9X7xWI0Bpc3sThaJdY9i"
}

步骤 2:注册一个将运行 AgentTool 的流程代理

流程代理按顺序运行一系列工具,并返回最后一个工具的输出。要创建流程代理,请发送以下注册代理请求,并提供上一步中的代理 ID

POST /_plugins/_ml/agents/_register
{
  "name": "Test agent tool",
  "type": "flow",
  "description": "this is a test agent",
  "tools": [
    {
      "type": "AgentTool",
      "description": "A general agent to answer any question",
      "parameters": {
        "agent_id": "9X7xWI0Bpc3sThaJdY9i"
      }
    }
  ]
}

有关参数描述,请参阅注册参数

OpenSearch 返回一个代理 ID

{
  "agent_id": "EQyyZ40BT2tRrkdmhT7_"
}

步骤 3:运行代理

通过发送以下请求来运行代理

POST /_plugins/_ml/agents/EQyyZ40BT2tRrkdmhT7_/_execute
{
  "parameters": {
    "question": "what's the population increase of Seattle from 2021 to 2023"
  }
}

OpenSearch 返回推理结果

{
  "inference_results": [
    {
      "output": [
        {
          "name": "response",
          "result": " I do not have direct data on the population increase of Seattle from 2021 to 2023 in the context provided. As a data analyst, I would need to research population statistics from credible sources like the US Census Bureau to analyze population trends and make an informed estimate. Without looking up actual data, I don't have enough information to provide a specific answer to the question."
        }
      ]
    }
  ]
}

注册参数

下表列出了注册代理时可用的所有工具参数。

参数 类型 必需/可选 描述
agent_id 字符串 必需 要运行的代理的代理 ID。

执行参数

下表列出了运行代理时可用的所有工具参数。

参数 类型 必需/可选 描述
问题 字符串 必需 要发送到 LLM 的自然语言问题。
剩余 350 字符

有问题?

想贡献?