使用 LlamaIndex 查询流水线代理

除了使用智能体的一般说明之外,本页还介绍了特定于 LlamaIndexQueryPipelineAgent 的功能。

准备工作

本教程假定您已阅读并遵循以下说明:

支持的操作

LlamaIndexQueryPipelineAgent 支持以下操作:

  • query:用于同步获取对查询的响应。

query 方法支持以下类型的参数:

  • input:要发送给智能体的消息。

查询智能体

命令:

agent.query(input="What is Paul Graham's life in college?")

它相当于以下内容(完整形式):

agent.query(input={"input": "What is Paul Graham's life in college?"})

如需自定义输入字典,请参阅自定义提示模板

您还可以通过向 query() 传递其他关键字参数,来自定义智能体在 input 之外的行为。

response = agent.query(
    input={
      "input" = [
        "What is Paul Graham's life in college?",
        "How did Paul Graham's college experience shape his career?",
        "How did Paul Graham's college experience shape his entrepreneurial mindset?",
      ],
    },
    batch=True  # run the pipeline in batch mode and pass a list of inputs.
)
print(response)

如需查看可用参数的完整列表,请参阅 QueryPipeline.run 代码

后续步骤