Files
wehub-resource-sync c56bef871b
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
Docker image release / Build base image (push) Has been cancelled
Sync docs with Docusaurus / sync (push) Has been cancelled
Tests / Check if changed (push) Has been cancelled
Tests / format (push) Has been cancelled
Tests / check-imports (push) Has been cancelled
Tests / Unit / macos-latest (push) Has been cancelled
Tests / Unit / ubuntu-latest (push) Has been cancelled
Tests / Unit / windows-latest (push) Has been cancelled
Tests / mypy (push) Has been cancelled
Tests / Integration / ubuntu-latest (push) Has been cancelled
Tests / Integration / macos-latest (push) Has been cancelled
Tests / Integration / windows-latest (push) Has been cancelled
Tests / notify-slack-on-failure (push) Has been cancelled
Tests / Mark tests as completed (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:28 +08:00

113 lines
3.4 KiB
Plaintext

---
title: "Pipeline Templates"
id: pipeline-templates
slug: "/pipeline-templates"
---
# Pipeline Templates
Haystack provides templates to create ready-made pipelines for common use cases.
To create a pipeline, the method `from_template`of 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.
<div className="key-value-table">
| | |
| --- | --- |
| Template identifier | `CHAT_WITH_WEBSITE` |
| Template params | \- |
| Inputs (**\*** means mandatory) | `'converter': {'meta': {}} ` <br />`'fetcher': {'urls': ["https://example.com"]}`**\*** <br />`'llm': {'generation_kwargs': {}}` <br />`'prompt': {'query': 'the question to ask'}` |
</div>
Example code:
```python
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`.
<div className="key-value-table">
| | |
| --- | --- |
| Template identifier | `CHAT_WITH_WEBSITE` |
| Template params | \- |
| Inputs (**\*** means mandatory) | `'converter': {'meta': {}} ` <br />`'fetcher': {'urls': ["https://example.com"]}`**\*** <br />`'llm': {'generation_kwargs': {}}` <br />`'prompt': {'query': 'the question to ask'}` |
</div>
Example code:
```python
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`](../../document-stores/inmemorydocumentstore.mdx).
<div className="key-value-table">
| | |
| --- | --- |
| Template identifier | `CHAT_WITH_WEBSITE` |
| Template params | \- |
| Inputs (**\*** means mandatory) | `'converter': {'meta': {}} ` <br />`'fetcher': {'urls': ["https://example.com"]}`**\*** <br />`'llm': {'generation_kwargs': {}}` <br />`'prompt': {'query': 'the question to ask'}` |
</div>
Example code:
```python
from haystack import Pipeline, PredefinedPipeline
pipeline = Pipeline.from_template(PredefinedPipeline.INDEXING)
result = pipeline.run({"converter": {"sources": ["some_file.txt"]}})
```
### RAG
Generates a RAG pipeline using data that was previously indexed (you can use the Indexing template).
<div className="key-value-table">
| | |
| --- | --- |
| Template identifier | `CHAT_WITH_WEBSITE` |
| Template params | \- |
| Inputs (**\*** means mandatory) | `'converter': {'meta': {}} ` <br />`'fetcher': {'urls': ["https://example.com"]}`**\*** <br />`'llm': {'generation_kwargs': {}}` <br />`'prompt': {'query': 'the question to ask'}` |
</div>
Example code:
```python
from haystack import Pipeline, PredefinedPipeline
pipeline = Pipeline.from_template(PredefinedPipeline.RAG)
pipeline.run({"text_embedder": {"text": "A question about your documents"}})
```