SuperComponent

An experimental component that wraps pipelines so that you can use them as Agent tools.

Basic Information

  • Type: haystack.core.super_component.super_component.SuperComponent
  • Components it can connect with:
    • SuperComponent is currently only used to wrap pipelines as Agent tools. It's not used as a pipeline component on its own.

Inputs

NameTypeDescription
*kwargsAnyKeyword arguments that match the input names expected by the wrapped pipeline.

Outputs

NameTypeDescription
Dictionary of strings and anyThe outputs of the wrapped pipeline.

Overview

SuperComponent makes it possible to encapsulate an entire pipeline as a single component to be used as a tool by an Agent. This lets the Agent treat a pipeline like a single building block.

For details on how to use it with an Agent, see Agent and Tools.

Usage Example

Here’s an example showing how to use SuperComponent as a tool for an Agent:

- type: haystack.tools.component_tool.ComponentTool # Marks this as an Agent tool
  data: # Required field for all Agent tools
    component: # Defines the component to wrap
      type: haystack.core.super_component.super_component.SuperComponent # Specifies that the tool uses a SuperComponent
      init_parameters:
        input_mapping: # Maps external inputs to internal pipeline component inputs
          query: # Passes the external 'query' input to these components
            - query_embedder.text
            - OpenSearchBM25Retriever.query
            - ranker.query
          filters: # Passes the external 'filters' input to these components
            - OpenSearchBM25Retriever.filters
            - OpenSearchEmbeddingRetriever.filters
        output_mapping: # Defines the SuperComponent's outputs based on internal component outputs
          ranker.documents: documents
        pipeline: # Defines the internal pipeline structure
          components:
            query_embedder:
              type: deepset_cloud_custom_nodes.embedders.nvidia.text_embedder.DeepsetNvidiaTextEmbedder
              init_parameters:
                model: intfloat/e5-base-v2
            OpenSearchBM25Retriever:
              type: haystack_integrations.components.retrievers.opensearch.bm25_retriever.OpenSearchBM25Retriever
              init_parameters:
                document_store:
                  type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
                  init_parameters:
                    index: default
                    embedding_dim: 768
                    return_embedding: false
                    max_chunk_bytes: 104857600
                    create_index: true
                filters:
                fuzziness: AUTO
                top_k: 20
            OpenSearchEmbeddingRetriever:
              type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
              init_parameters:
                document_store:
                  type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
                  init_parameters:
                    index: default
                    embedding_dim: 768
                    return_embedding: false
                    max_chunk_bytes: 104857600
                    create_index: true
                filters:
                top_k: 20
                efficient_filtering: false
            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: 2
          connection_type_validation: true
          connections:
            - sender: query_embedder.embedding
              receiver: OpenSearchEmbeddingRetriever.query_embedding
            - sender: OpenSearchBM25Retriever.documents
              receiver: document_joiner.documents
            - sender: OpenSearchEmbeddingRetriever.documents
              receiver: document_joiner.documents
            - sender: document_joiner.documents
              receiver: ranker.documents
          max_runs_per_component: 100
          metadata: {}
          # the parameters below are ComponentTool's parameters
    description: A tool that searches the internal database.
    name: internal_policies
    outputs_to_state:
      documents:
        source: documents

Parameters

Init Parameters

You can configure the following parameters when using SuperComponent with an Agent:

ParameterTypePossible ValuesDescription
pipelinePipelineThe pipeline to wrap. Construct it just as you would a regular pipeline, specifying components, their configuration, and connections.
Required.
input_mappingDictionary of string and list of stringsDefault: NoneMaps inputs passed to the SuperComponent to the inputs of the components inside the pipeline.
You pass them in the format: name_of_external_input: component_name: input_name.
For example:
input_mapping: query: ranker.query query_embedder.text
In this example, the SuperComponent receives an external input called query, which it passes to the query input of the ranker and the text input of the query_embedder.
Optional.
output_mappingDictionary of stringsDefault: NoneMaps outputs from components in the pipeline to the output keys of the SuperComponent. You specify them in the format: component_name.output: SuperComponent_output_name. The component's output name must match its actual output name, but you can choose any name for the SuperComponent’s output.
For example:
input_mapping: retriever.documents: retrieved_documents
This sets the final output of the SuperComponent to the documents retrieved by the ranker, which will be labeled as retrieved_documents.
Optional.

Related Links