Link Search Menu Expand Document Documentation Menu

对话智能体

2.13 版本引入

对话流代理类似,对话式代理将对话存储在一个索引中,在以下示例中,这个索引是 conversation_index。对话式代理可以配置一个大型语言模型 (LLM) 和一组执行特定任务的补充工具。例如,在配置代理时,您可以设置一个 LLM 和一个 CATIndexTool。当您向模型发送问题时,代理还会将 CATIndexTool 作为上下文包含在内。然后 LLM 会决定是否需要使用 CATIndexTool 来回答诸如“我的集群中有多少个索引?”之类的问题。该上下文允许 LLM 回答超出其知识库范围的特定问题。例如,以下代理配置了一个 LLM 和一个 CATIndexTool,用于检索有关您的 OpenSearch 索引的信息。

POST /_plugins/_ml/agents/_register
{
  "name": "Test_Agent_For_ReAct_ClaudeV2",
  "type": "conversational",
  "description": "this is a test agent",
  "llm": {
    "model_id": "YOUR_LLM_MODEL_ID",
    "parameters": {
      "max_iteration": 5,
      "stop_when_no_tool_found": true,
      "response_filter": "$.completion"
    }
  },
  "memory": {
    "type": "conversation_index"
  },
  "tools": [
    {
      "type": "VectorDBTool",
      "name": "VectorDBTool",
      "description": "A tool to search opensearch index with natural language question. If you don't know answer for some question, you should always try to search data with this tool. Action Input: <natural language question>",
      "parameters": {
        "model_id": "YOUR_TEXT_EMBEDDING_MODEL_ID",
        "index": "my_test_data",
        "embedding_field": "embedding",
        "source_field": [ "text" ],
        "input": "${parameters.question}"
      }
    },
    {
      "type": "CatIndexTool",
      "name": "RetrieveIndexMetaTool",
      "description": "Use this tool to get OpenSearch index information: (health, status, index, uuid, primary count, replica count, docs.count, docs.deleted, store.size, primary.store.size)."
    }
  ],
  "app_type": "my app"
}

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

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

后续步骤

剩余 350 字符

有问题?

想要贡献?