跳到主要内容

Simple agent

这个流程演示了如何在流程中使用 AgentAgent 使用 LLM 作为其"大脑",在连接的工具中进行选择并完成任务。

在这个流程中,Agent 使用连接的 Language model 组件进行推理。 Agent 选择 Calculator 工具来解决简单的数学问题,选择 URL 工具来搜索 URL 中的内容。

前置条件

打开 Langflow 并启动新流程

  1. 在 Langflow 仪表板中,点击 New Flow

  2. 选择 Simple Agent

Simple Agent 流程已创建。

Simple agent starter flow

运行简单 Agent 流程

  1. 将您的 OpenAI API key 添加到 Agent 组件中。

    可选:为 OpenAI API key 创建一个 全局变量

    1. OpenAI API Key 字段中,点击 Globe,然后点击 Add New Variable
    2. Variable Name 字段中,输入 openai_api_key
    3. Value 字段中,粘贴您的 OpenAI API Key (sk-...)。
    4. 点击 Save Variable
  2. 要运行流程,点击 Playground

  3. 要确认工具已连接,询问 Agent:What tools are available to you? 响应类似于以下内容:


    _10
    I have access to the following tools:
    _10
    Calculator: Perform basic arithmetic operations.
    _10
    fetch_content: Load and retrieve data from specified URLs.
    _10
    fetch_content_text: Load and retrieve text from specified URLs.
    _10
    as_dataframe: Load and retrieve data in a structured format (dataframe) from specified URLs.
    _10
    get_current_date: Returns the current date and time in a selected timezone.

  4. 向 Agent 提问。例如,要求它使用您喜欢的规则集创建一个桌游角色。 Agent 会告诉您何时使用 URL-fetch_content_text 工具搜索规则信息,以及何时使用 CalculatorComponent-evaluate_expression 通过掷骰子生成属性。 最终输出应类似于:


    _10
    Final Attributes
    _10
    Strength (STR): 10
    _10
    Constitution (CON): 12
    _10
    Size (SIZ): 14
    _10
    Dexterity (DEX): 9
    _10
    Intelligence (INT): 11
    _10
    Power (POW): 13
    _10
    Charisma (CHA): 8

现在您的查询已完成从 Chat inputChat output 的整个过程,您已经完成了 Simple Agent 流程。

Search