Skip to main content

SuperComponent

Wrap an entire pipeline in SuperComponent and use itas a single reusable component with simplified inputs and outputs.

Basic Information

  • Type: haystack.core.super_component.super_component.SuperComponent
  • Components it can connect with depend on the pipeline inputs and outputs.

Inputs

Inputs are dynamically defined based on the input_mapping configuration. By default, all pipeline inputs are exposed.

Outputs

Outputs are dynamically defined based on the output_mapping configuration. By default, all pipeline outputs are exposed.

Overview

Use SuperComponent to encapsulate a complete pipeline as a single component. This is useful for:

  • Creating reusable pipeline building blocks
  • Simplifying complex pipelines by hiding internal complexity
  • Defining tools for agents that execute entire pipelines

With SuperComponent, you can remap input and output names, making the wrapped pipeline's interface cleaner and easier to use.

Usage Example

This is an example RAG pipeline using SuperComponent to wrap a retrieval sub-pipeline as a reusable tool:

components:
rag_tool:
type: haystack.core.super_component.super_component.SuperComponent
init_parameters:
input_mapping:
query:
- bm25_retriever.query
- query_embedder.text
- ranker.query
- prompt_builder.query
output_mapping:
generator.replies: answer
ranker.documents: documents
pipeline:
components:
bm25_retriever:
type: haystack_integrations.components.retrievers.opensearch.bm25_retriever.OpenSearchBM25Retriever
init_parameters:
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: 'default'
max_chunk_bytes: 104857600
embedding_dim: 768
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
top_k: 20
fuzziness: 0
query_embedder:
type: deepset_cloud_custom_nodes.embedders.nvidia.text_embedder.DeepsetNvidiaTextEmbedder
init_parameters:
normalize_embeddings: true
model: intfloat/e5-base-v2
embedding_retriever:
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: 'default'
max_chunk_bytes: 104857600
embedding_dim: 768
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
top_k: 20
document_joiner:
type: haystack.components.joiners.document_joiner.DocumentJoiner
init_parameters:
join_mode: concatenate
ranker:
type: deepset_cloud_custom_nodes.rankers.nvidia.ranker.DeepsetNvidiaRanker
init_parameters:
model: intfloat/simlm-msmarco-reranker
top_k: 8
prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: "You are a helpful assistant answering the user's questions based on the provided documents.\nDo not use your own knowledge.\n\nProvided documents:\n{% for document in documents %}\nDocument [{{ loop.index }}]:\n{{ document.content }}\n{% endfor %}\n\nQuestion: {{ query }}\nAnswer:"
generator:
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
init_parameters:
api_key:
type: env_var
env_vars:
- OPENAI_API_KEY
strict: false
model: gpt-4o
generation_kwargs:
max_tokens: 1000
temperature: 0.7
connections:
- sender: bm25_retriever.documents
receiver: document_joiner.documents
- sender: query_embedder.embedding
receiver: embedding_retriever.query_embedding
- sender: embedding_retriever.documents
receiver: document_joiner.documents
- sender: document_joiner.documents
receiver: ranker.documents
- sender: ranker.documents
receiver: prompt_builder.documents
- sender: prompt_builder.prompt
receiver: generator.messages

answer_builder:
type: deepset_cloud_custom_nodes.augmenters.deepset_answer_builder.DeepsetAnswerBuilder
init_parameters:
reference_pattern: acm

connections:
- sender: rag_tool.answer
receiver: answer_builder.replies
- sender: rag_tool.documents
receiver: answer_builder.documents

inputs:
query:
- "rag_tool.query"
- "answer_builder.query"

outputs:
documents: "rag_tool.documents"
answers: "answer_builder.answers"

max_runs_per_component: 100

metadata: {}

Parameters

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
pipelineUnion[Pipeline, AsyncPipeline]The pipeline instance to be wrapped.
input_mappingOptional[Dict[str, List[str]]]NoneA dictionary mapping component input names to pipeline input socket paths. If not provided, a default mapping is created based on all pipeline inputs. Example: {"query": ["retriever.query", "prompt_builder.query"]}
output_mappingOptional[Dict[str, str]]NoneA dictionary mapping pipeline output socket paths to component output names. If not provided, a default mapping is created based on all pipeline outputs. Example: {"generator.replies": "replies"}

Run Method Parameters

The run method parameters are dynamically determined by the input_mapping configuration. Each key in the input mapping becomes a parameter that can be passed at runtime.