Class TextClassifierExecutor

java.lang.Object
ai.nervemind.app.executor.TextClassifierExecutor
All Implemented Interfaces:
NodeExecutor

@Component public class TextClassifierExecutor extends Object implements NodeExecutor
Executor for the "textClassifier" node type - classifies text into categories using LLM.

Uses a Large Language Model to analyze text and categorize it into one or more predefined categories. Useful for sentiment analysis, intent detection, spam filtering, and content tagging.

Node Parameters

Text Classifier node configuration parameters
Parameter Type Default Description
provider String "openai" LLM provider ("openai", "anthropic", "ollama")
model String provider-specific Model name (optimized for classification)
text String - Text to classify (supports interpolation)
categories List<String> [] List of valid categories
multiLabel Boolean false Allow multiple categories per text
includeConfidence Boolean true Include confidence scores
timeout Integer 60 Request timeout in seconds

Output Data (Single Label)

Output keys when multiLabel=false
Key Type Description
category String The predicted category
confidence Double Confidence score (0.0-1.0)
allScores Map Scores for all candidate categories

Output Data (Multi Label)

Output keys when multiLabel=true
Key Type Description
categories List<String> List of predicted categories
confidences List<Double> Confidence scores for predicted categories

Prompt Engineering

This executor automatically constructs a specialized system prompt that forces the LLM to return valid JSON with constrained output corresponding to the provided categories.

See Also:
  • Constructor Details

    • TextClassifierExecutor

      public TextClassifierExecutor(ai.nervemind.common.service.SettingsServiceInterface settingsService)
      Creates a new text classifier executor with configured HTTP client.
      Parameters:
      settingsService - the settings service for configuration access
  • Method Details

    • execute

      public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String,Object> input, ExecutionService.ExecutionContext context)
      Description copied from interface: NodeExecutor
      Executes the business logic for this node type.
      Specified by:
      execute in interface NodeExecutor
      Parameters:
      node - The node definition containing parameters and configuration. Use Node.parameters() to access user settings.
      input - Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.
      context - Verification context providing access to workflow-scoped services, logger, and execution metadata.
      Returns:
      A Map containing the results of this node's execution. Keys in this map become available variables for downstream nodes.
      Note: Returning null is treated as an empty map.
    • getNodeType

      public String getNodeType()
      Description copied from interface: NodeExecutor
      Unique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.
      Specified by:
      getNodeType in interface NodeExecutor
      Returns:
      The unique type string (e.g., "httpRequest", "llmChat").