Class RagExecutor
java.lang.Object
ai.nervemind.app.executor.RagExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "rag" node type - implements Retrieval-Augmented Generation.
Combines document retrieval with Large Language Models to answer questions based on specific context. This node orchestrates the full RAG pipeline: embedding generation for the query, vector similarity search against documents, and LLM generation with retrieved context.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| provider | String | "openai" | LLM provider ("openai", "anthropic", "ollama") |
| chatModel | String | auto | Model for answer generation (e.g., "gpt-4o") |
| embeddingModel | String | auto | Model for embedding generation |
| apiKey | String | from settings | API key for the provider |
| baseUrl | String | provider default | Custom base URL for API |
| query | String | - | User's question/query (supports interpolation) |
| documents | List | [] | Documents to search (content + metadata) |
| topK | Integer | 3 | Number of documents to retrieve |
| includeContext | Boolean | true | Include retrieved text in output |
Pipeline Steps
- Embedding: Generates vector for the user
query - Indexing: Generates embeddings for
documents(if missing) - Retrieval: Finds top K documents using cosine similarity
- Generation: Sends query + retrieved context to LLM
Output Data
| Key | Type | Description |
|---|---|---|
| response | String | The LLM's generated answer |
| context | List | Retrieved documents (if includeContext=true) |
| sources | List | Metadata from retrieved documents |
| documentsRetrieved | Integer | Number of documents found |
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RAG executor with default HTTP client configuration. -
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
-
RagExecutor
public RagExecutor()Creates a new RAG executor with default HTTP client configuration.
-
-
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").
-