MultiFileConverter
Convert multiple file types to documents in a single operation. The component automatically detects each file's type and applies the appropriate converter.
Key Features
- Automatically detects file types and applies the right converter for each file.
- Supports CSV, DOCX, HTML, JSON, Markdown, plain text, PDF, PPTX, and XLSX files.
- Combines
FileTypeRouter, nine converters, andDocumentJoinerinto a single SuperComponent. - Reports files that fail to convert in a separate
failedoutput list. - Configurable text encoding and JSON content key.
- Simplifies multi-format indexing without manually connecting individual converter components.
Configuration
- Drag the
MultiFileConvertercomponent onto the canvas from the Component Library. - Click the component to open the configuration panel.
- Configure the parameters as needed.
Connections
MultiFileConverter accepts a list of file paths or ByteStream objects (sources) as input. It outputs a list of successfully converted documents (documents) and a list of files that failed to convert (failed).
Typically, MultiFileConverter receives files from a FilesInput component and sends its documents output directly to a preprocessor such as DocumentSplitter.
Usage Example
Using the Component in an Index
In this index, MultiFileConverter receives files, converts them, and then sends them to DocumentSplitter.
components:
MultiFileConverter:
type: haystack.components.converters.multi_file_converter.MultiFileConverter
init_parameters:
encoding: utf-8
json_content_key: content
DocumentSplitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 200
split_overlap: 0
split_threshold: 0
splitting_function:
respect_sentence_boundary: false
language: en
use_split_rules: true
extend_abbreviations: true
skip_empty_documents: true
DeepsetNvidiaDocumentEmbedder:
type: deepset_cloud_custom_nodes.embedders.nvidia.document_embedder.DeepsetNvidiaDocumentEmbedder
init_parameters:
model: intfloat/multilingual-e5-base
prefix: ''
suffix: ''
batch_size: 32
meta_fields_to_embed:
embedding_separator: \n
truncate:
normalize_embeddings: true
timeout:
backend_kwargs:
DocumentWriter:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
policy: NONE
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: ''
max_chunk_bytes: 104857600
embedding_dim: 768
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
connections:
- sender: MultiFileConverter.documents
receiver: DocumentSplitter.documents
- sender: DocumentSplitter.documents
receiver: DeepsetNvidiaDocumentEmbedder.documents
- sender: DeepsetNvidiaDocumentEmbedder.documents
receiver: DocumentWriter.documents
max_runs_per_component: 100
metadata: {}
inputs:
files:
- MultiFileConverter.sources
Parameters
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| sources | List[Union[str, Path, ByteStream]] | A list of file paths or byte streams to convert. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | A list of converted documents. Only included if at least one file is successfully converted. | |
| failed | List[str] | A list of files that failed to convert. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| encoding | str | utf-8 | The encoding to use when reading text files. |
| json_content_key | str | content | The key to extract content from JSON files. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| sources | List[Union[str, Path, ByteStream]] | A list of file paths or byte streams to convert. |
Was this page helpful?