DocumentationAPI Reference📓 Tutorials🧑‍🍳 Cookbook🤝 Integrations💜 Discord🎨 Studio (Waitlist)
Documentation

Pipeline Templates

Haystack provides templates to create ready-made pipelines for common use cases.

To create a pipeline, the method from_templateof the Pipeline class can be called passing a template identifier in the form PredefinedPipeline.TEMPLATE_IDENTIFIER.

For example, to create and run a pipeline using the INDEXING template you would use Pipeline.from_template(PredefinedPipeline.INDEXING)

In this section we detail the available templates and how they can be used.

Chat with website

Generates a pipeline to read a web page and ask questions about its content.

Template identifierCHAT_WITH_WEBSITE
Template params-
Inputs (* means mandatory)'converter': {'meta': {}}
'fetcher': {'urls': ["https://example.com"]}*
'llm': {'generation_kwargs': {}}
'prompt': {'query': 'the question to ask'}

Example code:

from haystack import Pipeline, PredefinedPipeline

pipeline = Pipeline.from_template(PredefinedPipeline.CHAT_WITH_WEBSITE)
pipeline.run({"fetcher": {"urls": ["https://haystack.deepset.ai:"]}, "prompt": {"query": "what is Haystack?"}})

Generative QA

Generates a simple pipeline to ask a generic query using an OpenAIGenerator.

Template identifierGENERATIVE_QA
Template params-
Inputs (* means mandatory)'generator': {'generation_kwargs': {}}
'prompt_builder': {'question': "" }

Example code:

from haystack import Pipeline, PredefinedPipeline

pipeline = Pipeline.from_template(PredefinedPipeline.GENERATIVE_QA)
pipeline.run({"prompt_builder":{"question":"Where is Rome?"}})

Indexing

Generates a pipeline that imports documents from one or more text files, creates the embeddings for each of them, and finally stores them in an InMemoryDocumentStore.

Template identifierINDEXING
Template params-
Inputs (* means mandatory)'llm': {'generation_kwargs': {}}
'prompt_builder': {'query': ''}
'retriever': {'filters': {}, 'top_k': None}
'text_embedder': {'text': ''}}*

Example code:

from haystack import Pipeline, PredefinedPipeline

pipeline = Pipeline.from_template(PredefinedPipeline.INDEXING)
result = pipe.run({"converter": {"sources": ["some_file.txt"]}})

RAG

Generates a RAG pipeline using data that was previously indexed (you can use the Indexing template).

Template identifierRAG
Template params-
Inputs (* means mandatory)'llm': {'generation_kwargs': {}}
'prompt_builder': {'query': ''}
'retriever': {'filters': {}, 'top_k': None}
'text_embedder': {'text': ''}}*

Example code:

from haystack import Pipeline, PredefinedPipeline

pipeline = Pipeline.from_template(PredefinedPipeline.RAG)
pipeline.run({"text_embedder": {"text": "A question about your documents"}})