You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Sharing code between pipeline wrappers](#sharing-code-between-pipeline-wrappers)
63
66
-[Deployment Guidelines](#deployment-guidelines)
64
-
-[Legacy Features](#legacy-features)
65
-
-[Deploy Pipeline Using YAML](#deploy-a-pipeline-using-only-its-yaml-definition)
66
67
-[License](#license)
67
68
68
69
## Quick start with Docker Compose
69
70
70
71
To quickly get started with Hayhooks, we provide a ready-to-use Docker Compose 🐳 setup with pre-configured integration with [open-webui](https://openwebui.com/).
71
72
72
-
It's available [here](https://github.com/deepset-ai/hayhooks-open-webui-docker-compose).
73
+
It's available in the [Hayhooks + Open WebUI Docker Compose repository](https://github.com/deepset-ai/hayhooks-open-webui-docker-compose).
73
74
74
75
## Quick start
75
76
@@ -162,8 +163,8 @@ CLI commands are basically wrappers around the HTTP API of the server. The full
162
163
hayhooks run # Start the server
163
164
hayhooks status # Check the status of the server and show deployed pipelines
164
165
165
-
hayhooks pipeline deploy-files <path_to_dir># Deploy a pipeline using PipelineWrapper
166
-
hayhooks pipeline deploy<pipeline_name># Deploy a pipeline from a YAML file
166
+
hayhooks pipeline deploy-files <path_to_dir># Deploy a pipeline using PipelineWrapper files (preferred)
167
+
hayhooks pipeline deploy-yaml <path_to_yaml># Deploy a pipeline from a YAML file
167
168
hayhooks pipeline undeploy <pipeline_name># Undeploy a pipeline
168
169
hayhooks pipeline run <pipeline_name># Run a pipeline
169
170
```
@@ -195,7 +196,7 @@ The pipeline wrapper provides a flexible foundation for deploying Haystack pipel
195
196
- Define custom execution logic with configurable inputs and outputs
196
197
- Optionally expose OpenAI-compatible chat endpoints with streaming support for integration with interfaces like [open-webui](https://openwebui.com/)
197
198
198
-
The `pipeline_wrapper.py` file must contain an implementation of the `BasePipelineWrapper` class (see [here](src/hayhooks/server/utils/base_pipeline_wrapper.py) for more details).
199
+
The `pipeline_wrapper.py` file must contain an implementation of the `BasePipelineWrapper` class (see [BasePipelineWrapper source](src/hayhooks/server/utils/base_pipeline_wrapper.py) for more details).
This will deploy the pipeline with the name `chat_with_website`. Any error encountered during development will be printed to the console and show in the server logs.
276
277
278
+
Alternatively, you can deploy via HTTP: `POST /deploy_files`.
279
+
277
280
#### PipelineWrapper development with `overwrite` option
278
281
279
282
During development, you can use the `--overwrite` flag to redeploy your pipeline without restarting the Hayhooks server:
@@ -318,6 +321,64 @@ Then, assuming you've installed the Hayhooks package in a virtual environment, y
318
321
pip install trafilatura
319
322
```
320
323
324
+
## Deploy a YAML Pipeline
325
+
326
+
You can deploy a Haystack pipeline directly from its YAML definition using the `/deploy-yaml` endpoint. This mode builds request/response schemas from the YAML-declared `inputs` and `outputs`.
327
+
328
+
Note: You can also deploy YAML pipelines from the CLI with `hayhooks pipeline deploy-yaml`. Wrapper-based deployments continue to use `/deploy_files`.
329
+
330
+
Tip: You can obtain a pipeline's YAML from an existing `Pipeline` instance using `pipeline.dumps()`. See the [Haystack serialization docs](https://docs.haystack.deepset.ai/docs/serialization) for details.
331
+
332
+
Requirements:
333
+
334
+
- The YAML must declare both `inputs` and `outputs` fields so the API request/response schemas can be generated. If you have generated the YAML from a `Pipeline` using `pipeline.dumps()`, you will need to add the `inputs` and `outputs` fields _manually_.
-d '{"urls": ["https://haystack.deepset.ai"], "query": "What is Haystack?"}'
366
+
```
367
+
368
+
Note: when deploying a YAML pipeline, Hayhooks will create an `AsyncPipeline` instance from the YAML source code. This is because we are in an async context, so we should avoid running sync methods using e.g. `run_in_threadpool`. With AsyncPipeline, we can await `run_async` directly, so we make use of the current event loop.
369
+
370
+
Limitations:
371
+
372
+
- YAML-deployed pipelines do not support OpenAI-compatible chat completion endpoints, so they cannot be used with Open WebUI. If you need chat completion/streaming, use a `PipelineWrapper` and implement `run_chat_completion` or `run_chat_completion_async` (see the OpenAI compatibility section below).
373
+
374
+
Available CLI options for `hayhooks pipeline deploy-yaml`:
375
+
376
+
-`--name, -n`: override the pipeline name (default: YAML file stem)
377
+
-`--description`: optional human-readable description (used in MCP tool listing)
378
+
-`--overwrite, -o`: overwrite if the pipeline already exists
379
+
-`--skip-mcp`: skip exposing this pipeline as an MCP Tool
380
+
-`--save-file/--no-save-file`: save the YAML under `pipelines/{name}.yml` on the server (default: `--save-file`)
381
+
321
382
## Deploy an Agent
322
383
323
384
Deploying a [Haystack Agent](https://docs.haystack.deepset.ai/docs/agents) is very similar to deploying a pipeline.
@@ -358,6 +419,41 @@ As you can see, the `run_chat_completion_async` method is the one that will be u
358
419
359
420
The `async_streaming_generator` function is a utility function that [will handle the streaming of the agent's responses](#async_streaming_generator).
360
421
422
+
## Load pipelines or agents at startup
423
+
424
+
Hayhooks can automatically deploy pipelines or agents on startup by scanning a pipelines directory.
425
+
426
+
- Set `HAYHOOKS_PIPELINES_DIR` (defaults to `./pipelines`).
427
+
- On startup, Hayhooks will:
428
+
- Deploy every YAML file at the directory root (`*.yml`/`*.yaml`) using the file name as the pipeline name.
429
+
- Deploy every immediate subfolder as a wrapper-based pipeline/agent if it contains a `pipeline_wrapper.py`.
430
+
431
+
Example layout:
432
+
433
+
```text
434
+
my-project/
435
+
├── .env
436
+
└── pipelines/
437
+
├── inputs_outputs_pipeline.yml # YAML-only pipeline -> POST /inputs_outputs_pipeline/run
438
+
├── chat_with_website/ # Wrapper-based pipeline -> POST /chat_with_website/run (+ chat endpoints if implemented)
439
+
│ ├── pipeline_wrapper.py
440
+
│ └── chat_with_website.yml
441
+
└── agent_streaming/
442
+
└── pipeline_wrapper.py
443
+
```
444
+
445
+
Configure via environment or `.env`:
446
+
447
+
```shell
448
+
# .env
449
+
HAYHOOKS_PIPELINES_DIR=./pipelines
450
+
```
451
+
452
+
Notes:
453
+
454
+
- YAML-deployed pipelines require `inputs` and `outputs` in the YAML and do not expose OpenAI-compatible chat endpoints. For chat/streaming, use a `PipelineWrapper` and implement `run_chat_completion`/`run_chat_completion_async`.
455
+
- If your wrappers import shared code, set `HAYHOOKS_ADDITIONAL_PYTHON_PATH` (see “Sharing code between pipeline wrappers”).
456
+
361
457
## Support file uploads
362
458
363
459
Hayhooks can easily handle uploaded files in your pipeline wrapper `run_api` method by adding `files: Optional[List[UploadFile]] = None` as an argument.
@@ -445,6 +541,52 @@ hayhooks mcp run
445
541
446
542
This will start the Hayhooks MCP Server on `HAYHOOKS_MCP_HOST:HAYHOOKS_MCP_PORT`.
447
543
544
+
### Expose a YAML pipeline as a MCP Tool
545
+
546
+
Hayhooks can expose YAML-deployed pipelines as MCP Tools. When you deploy a pipeline via `/deploy-yaml` (or the CLI `hayhooks pipeline deploy-yaml`), Hayhooks:
547
+
548
+
- Builds flat request/response models from YAML-declared `inputs` and `outputs`.
549
+
- Registers the pipeline as an `AsyncPipeline` and adds it to the registry with metadata required for MCP Tools.
550
+
- Lists it in MCP `list_tools()` with:
551
+
-`name`: the pipeline name (YAML file stem or provided `--name`)
552
+
-`description`: the optional description you pass during deployment (defaults to the pipeline name)
553
+
-`inputSchema`: JSON schema derived from YAML `inputs`
554
+
555
+
Calling a YAML pipeline via MCP `call_tool` executes the pipeline asynchronously and returns the pipeline result as a JSON string in `TextContent`.
556
+
557
+
Sample YAML for a simple `sum` pipeline using only the `haystack.testing.sample_components.sum.Sum` component:
558
+
559
+
```yaml
560
+
components:
561
+
sum:
562
+
init_parameters: {}
563
+
type: haystack.testing.sample_components.sum.Sum
564
+
565
+
connections: []
566
+
567
+
metadata: {}
568
+
569
+
inputs:
570
+
values: sum.values
571
+
572
+
outputs:
573
+
total: sum.total
574
+
```
575
+
576
+
Example (Streamable HTTP via MCP client):
577
+
578
+
```python
579
+
tools = await client.list_tools()
580
+
# Find YAML tool by name, e.g., "sum" (the pipeline name)
581
+
result = await client.call_tool("sum", {"values": [1, 2, 3]})
582
+
assert result.content[0].text == '{"total": 6}'
583
+
```
584
+
585
+
Notes and limitations:
586
+
587
+
- YAML pipelines must declare `inputs` and `outputs`.
588
+
- YAML pipelines are run-only via MCP and return JSON text; if you need OpenAI-compatible chat endpoints or streaming, use a `PipelineWrapper` and implement `run_chat_completion`/`run_chat_completion_async`.
589
+
448
590
### Create a PipelineWrapper for exposing a Haystack pipeline as a MCP Tool
449
591
450
592
A [MCP Tool](https://modelcontextprotocol.io/docs/concepts/tools) requires the following properties:
@@ -971,24 +1113,6 @@ We have some dedicated documentation for deployment:
971
1113
972
1114
We also have some additional deployment guidelines, see [deployment_guidelines.md](docs/deployment_guidelines.md).
973
1115
974
-
### Legacy Features
975
-
976
-
#### Deploy a pipeline using only its YAML definition
977
-
978
-
**⚠️ This way of deployment is not maintained anymore and will be deprecated in the future**.
979
-
980
-
We're still supporting the Hayhooks _former_ way to deploy a pipeline.
981
-
982
-
The former command `hayhooks deploy` is now changed to `hayhooks pipeline deploy` and can be used to deploy a pipeline only from a YAML definition file.
This will deploy the pipeline with the name `chat_with_website` from the YAML definition file `examples/pipeline_wrappers/chat_with_website/chat_with_website.yml`. You then can check the generated docs at `http://HAYHOOKS_HOST:HAYHOOKS_PORT/docs` or `http://HAYHOOKS_HOST:HAYHOOKS_PORT/redoc`, looking at the `POST /chat_with_website` endpoint.
991
-
992
1116
### License
993
1117
994
1118
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
0 commit comments