Class TextClassifierExecutor
java.lang.Object
ai.nervemind.app.executor.TextClassifierExecutor
- All Implemented Interfaces:
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
| 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)
| 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)
| 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 Summary
ConstructorsConstructorDescriptionTextClassifierExecutor(ai.nervemind.common.service.SettingsServiceInterface settingsService) Creates a new text classifier executor with configured HTTP client. -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
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:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.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: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-