Skip to content

文本分类器节点#

¥Text Classifier node

使用 Text Classifier 节点对传入数据进行分类(归类)。使用参数中提供的类别(见下文),将每个项目传递给模型以确定其类别。

¥Use the Text Classifier node to classify (categorize) incoming data. Using the categories provided in the parameters (see below), each item is passed to the model to determine its category.

本页包含文本分类器节点的节点参数以及更多资源的链接。

¥On this page, you'll find the node parameters for the Text Classifier node, and links to more resources.

节点参数#

¥Node parameters

  • 输入提示定义要分类的输入。这通常是一个引用输入项中某个字段的表达式。例如,如果输入是聊天触发器,则该属性可以是 {{ $json.chatInput }}。默认情况下,它引用 text 字段。

¥Input Prompt defines the input to classify. This is usually an expression that references a field from the input items. For example, this could be {{ $json.chatInput }} if the input is a chat trigger. By default it references the text field.

  • 类别:添加你希望对输入进行分类的类别。类别包含名称和描述。使用描述告诉模型类别的含义。如果含义不明确,这一点很重要。你可以添加任意数量的类别。

¥Categories: Add the categories that you want to classify your input as. Categories have a name and a description. Use the description to tell the model what the category means. This is important if the meaning isn't obvious. You can add as many categories as you like.

节点选项#

¥Node options

  • 允许多个类为真:你可以将分类器配置为每个项目始终输出一个类别(已关闭),或允许模型选择多个类别(已开启)。

¥Allow Multiple Classes To Be True: You can configure the classifier to always output a single class per item (turned off), or allow the model to select multiple classes (turned on).

  • 没有明确匹配项时:定义当模型找不到与某个项目匹配的结果时会发生什么。有两种选项:

¥When No Clear Match: Define what happens if the model can't find a good match for an item. There are two options:

  • 丢弃项目(默认):如果节点未检测到任何类别,则会删除该项。

    ¥Discard Item (the default): If the node doesn't detect any of the categories, it drops the item.

  • 在 Extra 和 '其他' 分支上输出:创建一个名为“其他”的单独输出分支。当节点未检测到任何类别时,它会在此分支中输出项。

    ¥Output on Extra, 'Other' Branch: Creates a separate output branch called Other. When the node doesn't detect any of the categories, it outputs items in this branch.

  • 系统提示模板:使用此选项可更改用于分类的系统提示。它使用 {categories} 占位符来表示类别。

¥System Prompt Template: Use this option to change the system prompt that's used for the classification. It uses the {categories} placeholder for the categories.

  • 启用自动修复:启用后,节点会自动修复模型输出,以确保其符合预期格式。将模式解析错误发送给 LLM 并请求其修复。

¥Enable Auto-Fixing: When enabled, the node automatically fixes model outputs to ensure they match the expected format. Do this by sending the schema parsing error to the LLM and asking it to fix it.

相关资源#

¥Related resources

View n8n's Advanced AI documentation.