让 AI 指定工具参数#
¥Let AI specify the tool parameters
配置连接到工具代理的 tools 时,许多参数可以由 AI 模型自动填充。人工智能模型将利用任务上下文和其他已连接工具的信息来填充相应的细节。
¥When configuring tools connected to the Tools Agent, many parameters can be filled in by the AI model itself. The AI model will use the context from the task and information from other connected tools to fill in the appropriate details.
你可以通过两种方式执行此操作,并且可以在它们之间切换。
¥There are two ways to do this, and you can switch between them.
让模型填充参数#
¥Let the model fill in the parameter
工具编辑对话框中每个相应的参数字段末尾都有一个额外的按钮:
¥Each appropriate parameter field in the tool's editing dialog has an extra button at the end:
激活此按钮后,AI 代理 将自动填充表达式,无需用户输入任何其他信息。字段本身会填充一条消息,指示该参数已由模型自动定义。
¥On activating this button, the AI Agent will fill in the expression for you, with no need for any further user input. The field itself is filled in with a message indicating that the parameter has been defined automatically by the model.
如果你想自行定义参数,请点击此框中的 'X' 以恢复为用户自定义值。请注意,'expression' 字段现在将包含此功能生成的表达式,但你现在可以对其进行进一步编辑,以添加更多详细信息,如下一节所述。
¥If you want to define the parameter yourself, click on the 'X' in this box to revert to user-defined values. Note that the 'expression' field will now contain the expression generated by this feature, though you can now edit it further to add extra details as described in the following section.
Warning
激活此功能将覆盖你可能已添加的任何手动定义。
¥Activating this feature will overwrite any manual definition you may have already added.
使用 $fromAI() 函数#
¥Use the $fromAI() function
$fromAI() 函数使用 AI 动态填充连接到 工具 AI 代理 的工具的参数。
¥The $fromAI() function uses AI to dynamically fill in parameters for tools connected to the Tools AI agent.
Only for tools
$fromAI() 函数仅适用于连接到 AI Agent 节点的工具。$fromAI() 函数不适用于 代码 工具或 其他非工具集群子节点 工具。
¥The $fromAI() function is only available for tools connected to the AI Agent node. The $fromAI() function doesn't work with the Code tool or with other non-tool cluster sub-nodes.
要使用 $fromAI() 函数,请使用所需的 key 参数调用它:
¥To use the $fromAI() function, call it with the required key parameter:
{{ $fromAI('email') }}
key 参数以及 $fromAI() 函数的其他参数并非对现有值的引用。请将这些参数视为 AI 模型用来填充正确数据的提示。
¥The key parameter and other arguments to the $fromAI() function aren't references to existing values. Instead, think of these arguments as hints that the AI model will use to populate the right data.
例如,如果你选择名为 email 的键,AI 模型将在其上下文、其他工具和输入数据中查找电子邮件地址。在聊天工作流中,如果找不到用户的电子邮件地址,它可能会要求用户提供电子邮件地址。你可以选择传递其他参数(例如 description)来为 AI 模型提供额外的上下文信息。
¥For instance, if you choose a key called email, the AI Model will look for an email address in its context, other tools, and input data. In chat workflows, it may ask the user for an email address if it can't find one elsewhere. You can optionally pass other parameters like description to give extra context to the AI model.
参数#
¥Parameters
$fromAI() 函数接受以下参数:
¥The $fromAI() function accepts the following parameters:
| 参数 | 类型 | 是否必填? | 描述 |
|---|---|---|---|
key |
string | :white_check_mark: | 表示参数键或名称的字符串。长度必须介于 1 到 64 个字符之间,并且只能包含小写字母、大写字母、数字、下划线和连字符。 |
description |
string | 描述参数的字符串。 | |
type |
string | 指定数据类型的字符串。可以是字符串、数字、布尔值或 JSON(默认为字符串)。 | |
defaultValue |
any | 该参数的默认值。 |
示例#
¥Examples
例如,你可以使用以下 $fromAI() 表达式动态填充一个字段的名称:
¥As an example, you could use the following $fromAI() expression to dynamically populate a field with a name:
1 | |
如果你不需要可选参数,可以将其简化为:
¥If you don't need the optional parameters, you could simplify this as:
1 | |
要动态填充库存商品数量,你可以使用如下的 $fromAI() 表达式:
¥To dynamically populate the number of items you have in stock, you could use a $fromAI() expression like this:
1 | |
如果你只想使用模型中的动态值填充字段的部分内容,也可以在普通表达式中使用它。例如,如果你希望模型自动填充电子邮件地址的 subject 参数,但始终在生成的值前加上字符串 '由人工智能生成:',则可以使用以下表达式:
¥If you only want to fill in parts of a field with a dynamic value from the model, you can use it in a normal expression as well. For example, if you want the model to fill out the subject parameter for an e-mail, but always pre-fix the generated value with the string 'Generated by AI:', you could use the following expression:
1 | |
模板#
¥Templates
你可以在以下 templates 中看到 $fromAI() 函数的实际应用:
¥You can see the $fromAI() function in action in the following templates:
¥Angie, Personal AI Assistant with Telegram Voice and Text
¥Automate Customer Support Issue Resolution using AI Text Classifier
¥Scale Deal Flow with a Pitch Deck AI Vision, Chatbot and QDrant Vector Store
