Link Search Menu Expand Document Documentation Menu

流程智能体

2.13 版本引入

流代理配置了一组按顺序运行的工具。例如,以下代理先运行 VectorDBTool,然后运行 MLModelTool。代理协调这些工具,使一个工具的输出可以成为另一个工具的输入。在此示例中,VectorDBTool 查询 k-NN 索引,代理将其输出 ${parameters.VectorDBTool.output} 作为上下文以及 ${parameters.question}(参见 prompt 参数)传递给 MLModelTool

POST /_plugins/_ml/agents/_register
{
  "name": "Test_Agent_For_RAG",
  "type": "flow",
  "description": "this is a test agent",
  "tools": [
    {
      "type": "VectorDBTool",
      "parameters": {
        "model_id": "YOUR_TEXT_EMBEDDING_MODEL_ID",
        "index": "my_test_data",
        "embedding_field": "embedding",
        "source_field": ["text"],
        "input": "${parameters.question}"
      }
    },
    {
      "type": "MLModelTool",
      "description": "A general tool to answer any question",
      "parameters": {
        "model_id": "YOUR_LLM_MODEL_ID",
        "prompt": "\n\nHuman:You are a professional data analyst. You will always answer a question based on the given context first. If the answer is not directly shown in the context, you will analyze the data and find the answer. If you don't know the answer, just say you don't know. \n\n Context:\n${parameters.VectorDBTool.output}\n\nHuman:${parameters.question}\n\nAssistant:"
      }
    }
  ]
}

有关注册代理 API 请求字段的更多信息,请参阅请求体字段

有关分步教程,请参阅代理和工具教程

后续步骤

剩余 350 字符

有问题?

想贡献吗?