Simple agent
这个流程演示了如何在流程中使用 Agent。 Agent 使用 LLM 作为其"大脑",在连接的工具中进行选择并完成任务。
在这个流程中,Agent 使用连接的 Language model 组件进行推理。 Agent 选择 Calculator 工具来解决简单的数学问题,选择 URL 工具来搜索 URL 中的内容。
前置条件
打开 Langflow 并启动新流程
-
在 Langflow 仪表板中,点击 New Flow。
-
选择 Simple Agent。
Simple Agent 流程已创建。
运行简单 Agent 流程
-
将您的 OpenAI API key 添加到 Agent 组件中。
可选:为 OpenAI API key 创建一个 全局变量。
- 在 OpenAI API Key 字段中,点击 Globe,然后点击 Add New Variable。
- 在 Variable Name 字段中,输入
openai_api_key
。 - 在 Value 字段中,粘贴您的 OpenAI API Key (
sk-...
)。 - 点击 Save Variable。
-
要运行流程,点击 Playground。
-
要确认工具已连接,询问 Agent:
What tools are available to you?
响应类似于以下内容:_10I have access to the following tools:_10Calculator: Perform basic arithmetic operations._10fetch_content: Load and retrieve data from specified URLs._10fetch_content_text: Load and retrieve text from specified URLs._10as_dataframe: Load and retrieve data in a structured format (dataframe) from specified URLs._10get_current_date: Returns the current date and time in a selected timezone. -
向 Agent 提问。例如,要求它使用您喜欢的规则集创建一个桌游角色。 Agent 会告诉您何时使用
URL-fetch_content_text
工具搜索规则信息,以及何时使用CalculatorComponent-evaluate_expression
通过掷骰子生成属性。 最终输出应类似于:_10Final Attributes_10Strength (STR): 10_10Constitution (CON): 12_10Size (SIZ): 14_10Dexterity (DEX): 9_10Intelligence (INT): 11_10Power (POW): 13_10Charisma (CHA): 8
现在您的查询已完成从 Chat input 到 Chat output 的整个过程,您已经完成了 Simple Agent 流程。