Skip to main content
Text classifier node for content classification and topic detection. Analyzes text input and classifies it into predefined categories using ML models. Returns classification results with confidence scores. You can either use a pre-configured text classifier component that could be reused across multiple nodes or node will create a new component for you. Input: String - The data type that TextClassifierNode accepts as input Output: GraphTypes.ClassificationResult - The data type that TextClassifierNode outputs Example:
// Using component configuration
const classifierNode = new TextClassifierNode({
  id: 'content-classifier',
  modelWeightsPath: '/models/classifier_weights.json',
  embedderComponentId: 'text_embedder_component',
  supportedClasses: ['hategroup', 'selfharm', 'sexual', 'sexualminors', 'substance'],
  classifierConfig: {
    classes: [
      { label: 'hategroup', threshold: 0.8 },
      { label: 'selfharm', threshold: 0.9 }
    ]
  }
});

// Using existing text classifier component
const classifierComponent = new TextClassifierComponent({
  id: 'existing-classifier-component',
  modelWeightsPath: '/models/classifier_weights.json',
  embedderComponentId: 'text_embedder_component',
  supportedClasses: ['hategroup', 'selfharm']
});
const classifierNodeWithComponent = new TextClassifierNode({
  id: 'content-classifier',
  textClassifierComponent: classifierComponent
});

Constructor

new TextClassifierNode(
    props: TextClassifierNodeProps | TextClassifierNodeWithComponentProps,
): TextClassifierNode
Creates a new TextClassifierNode instance.

Parameters

props (TextClassifierNodeProps | TextClassifierNodeWithComponentProps) Configuration for the text classifier node. Can provide either classifier settings to create a new internal component, or pass textClassifierComponent to reuse an existing one, but not both.

Returns

TextClassifierNode

Remarks

The TextClassifierNode creates its own text classifier using the factory pattern and doesn’t need a separate TextClassifierComponent. Overrides AbstractNode.constructor