Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Haystack Discord
url: https://discord.com/invite/xYvH6drSmA
about: Questions about Haystack itself should go here, not this repo's issue tracker.
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/new_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 🍳 New cookbook example
description: Propose a new notebook for the Haystack Cookbook
labels: ["new example"]
body:
- type: markdown
attributes:
value: |
Thanks for wanting to contribute! Every new notebook must start as an issue.
A maintainer will review it and, once assigned, you can open a PR referencing this issue.
See [CONTRIBUTING.md](https://github.com/deepset-ai/haystack-cookbook/blob/main/CONTRIBUTING.md) for the full process.
- type: input
id: title
attributes:
label: Proposed notebook title
description: A descriptive name (include model providers, databases, or technologies used).
validations:
required: true
- type: textarea
id: haystack-feature
attributes:
label: What Haystack feature or integration does this demonstrate?
description: Name the specific Haystack component(s), pipeline pattern, or best practice this notebook showcases.
validations:
required: true
- type: textarea
id: why
attributes:
label: Why is this a good addition to the cookbook?
description: Explain the use case and what a reader learns about using Haystack. This is not the place to pitch a third-party tool.
validations:
required: true
- type: dropdown
id: third-party
attributes:
label: Does this notebook feature a third-party integration (model provider, vector database, tool, etc.)?
options:
- "No"
- "Yes"
validations:
required: true
- type: textarea
id: third-party-details
attributes:
label: If yes, name the third-party product and explain how it's used with Haystack (not as a standalone demo of that product)
validations:
required: false
- type: checkboxes
id: acknowledge
attributes:
label: Acknowledgement
options:
- label: I understand a maintainer must assign this issue to me before I open a PR.
required: true
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Linked issue

Closes #<!-- issue number -->

<!-- New examples MUST be filed as an issue first and assigned to you by a maintainer
before opening a PR. See CONTRIBUTING.md. PRs without a linked, assigned issue
will be closed automatically. -->

## Checklist

- [ ] This issue was assigned to me by a maintainer before I opened this PR.
- [ ] The notebook is added to `/notebooks`.
- [ ] The notebook is registered in `index.toml` with a title and topics.
- [ ] If the notebook uses an experimental feature, `experimental = true` and the discussion link are set in `index.toml`.
78 changes: 78 additions & 0 deletions .github/workflows/enforce_issue_link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Enforce issue-first contribution

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

permissions:
pull-requests: write
issues: read

jobs:
enforce-issue-link:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const body = context.payload.pull_request.body || "";
const author = context.payload.pull_request.user.login;

const match = body.match(/\b(close[sd]?|fix(e[sd])?|resolve[sd]?)\s+#(\d+)\b/i);

const explain = async (message) => {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: message,
});
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
state: "closed",
});
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["needs-issue"],
});
};

if (!match) {
await explain(
`Hi @${author} — new examples must start as an issue before a PR is opened. ` +
`Please open an issue with the [new example template](../../issues/new?template=new_example.yml), ` +
`get it assigned to you by a maintainer, then reopen this PR with \`Closes #<issue>\` in the description. ` +
`See [CONTRIBUTING.md](../../blob/main/CONTRIBUTING.md).`
);
return;
}

const issueNumber = parseInt(match[3], 10);
let issue;
try {
issue = (await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
})).data;
} catch (e) {
await explain(
`Hi @${author} — issue #${issueNumber} referenced in this PR could not be found. ` +
`Please link a valid, assigned issue. See [CONTRIBUTING.md](../../blob/main/CONTRIBUTING.md).`
);
return;
}

const assignees = (issue.assignees || []).map((a) => a.login.toLowerCase());
if (!assignees.includes(author.toLowerCase())) {
await explain(
`Hi @${author} — issue #${issueNumber} isn't assigned to you. ` +
`A maintainer needs to assign the issue to you before a PR for it is accepted. ` +
`See [CONTRIBUTING.md](../../blob/main/CONTRIBUTING.md).`
);
return;
}
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# AGENTS.md

Instructions for AI coding agents (Claude Code, Copilot, Cursor, etc.) working in this repository.

## What this repo is

A collection of example Jupyter notebooks demonstrating [Haystack](https://github.com/deepset-ai/haystack).
Each notebook is a small, focused demo of a Haystack feature, integration, or best practice —
not a showcase for a third-party product.

## Contribution process — read before writing any new example

New examples require an issue **assigned by a maintainer** before a PR is opened. Do not create a
notebook and open a PR for it speculatively — a CI workflow (`.github/workflows/enforce_issue_link.yml`)
auto-closes PRs that don't reference an issue assigned to the PR author. Full process in
[CONTRIBUTING.md](CONTRIBUTING.md).

If you're an agent acting on behalf of a user who wants to add an example:
1. Check whether an issue for it already exists and is assigned to the user.
2. If not, tell the user to open one via `.github/ISSUE_TEMPLATE/new_example.yml` and wait for assignment.
3. Only write the notebook and PR once the issue is confirmed assigned.

## Adding/editing a notebook

1. Place notebooks in `/notebooks`, named descriptively (model providers, databases, technologies, task).
2. Register every notebook in `index.toml` under `[[cookbook]]` with `title`, `notebook` (filename), and
`topics`. Experimental features also need `experimental = true` and a discussion link.
3. Validate with `python scripts/verify_index.py` — checks every notebook is indexed, every indexed
entry's file exists, and each has a title and topics. This runs in CI on PRs touching notebooks or
`index.toml`.
4. Keep notebook output cells present but minimal — don't leave huge dumps or secrets/API keys in
committed output.
5. Dependencies used by notebooks go in `requirements.txt` when shared, otherwise `pip install` cells
inside the notebook itself (repo convention: check a few existing notebooks in `/notebooks` for the
pattern before adding a new one).

## Don't

- Don't add a notebook that primarily promotes a third-party tool with Haystack as an afterthought.
- Don't open a PR without a linked, assigned issue — it will be auto-closed.
- Don't hardcode API keys or secrets in notebook cells or outputs.
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing to the Haystack Cookbook

This repository showcases how to use [Haystack](https://github.com/deepset-ai/haystack) well — new
model providers, vector databases, retrieval techniques, experimental features, and best practices.
It is not a place to advertise a third-party product; any tool or service shown here must be used
*with* Haystack to demonstrate a Haystack capability, not the other way around.

## The process

1. **Open an issue first.** Use the [new example issue template](.github/ISSUE_TEMPLATE/new_example.yml)
to propose your notebook. Describe the Haystack feature or integration it demonstrates and why it's
a useful addition.
2. **Wait for a maintainer to review and assign it to you.** We check that the proposal fits the
cookbook's goal before any code is written. Issues that read as promotion for a specific product
rather than a Haystack use case will not be assigned.
3. **Open your PR only once the issue is assigned to you**, and reference it with `Closes #<issue>`
in the PR description. PRs that don't reference an issue assigned to their author will be closed
automatically by CI.

## Writing the notebook

1. Add your notebook to `/notebooks`.
2. Give it a descriptive name that includes the model providers, databases, and/or technologies used,
and/or the task it completes.
3. Register it in `index.toml`, including its title and topics. If it uses an experimental feature,
also set `experimental = true` and add the discussion link.

> You can also create a PR directly from Colab: fork this repository, add your example, then use
> "Save a Copy to GitHub" on Colab to push to your fork before opening the PR.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ For more examples, you may also find our [Blog](https://haystack.deepset.ai/blog

### Contributing to the Haystack Cookbook

If you have an example that uses Haystack, you can add it to this repository by creating a PR.
> You can also create a PR directly from Colab by creating a fork of this repository and selecting "Save a Copy to GitHub" on Colab. Once you add your example to your fork, you can create a PR on this repository.

1. Add your notebook to `/notebooks` folder
2. Give a descriptive name to your file that includes the names of (if applicable) the model providers, databases, the technologies you use in your example, and/or the task you are completing in the example.
3. Make sure you add it to `index.toml`, including its title and topics. If the notebook is using an experimental feature, also add the discussion link with the `experimental = true` field.
⚠️ **New examples start as an issue, not a PR.** Open an issue using our
[new example template](.github/ISSUE_TEMPLATE/new_example.yml), and once a maintainer assigns it to
you, open your PR referencing it. PRs without an assigned, linked issue are closed automatically.
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full process.
Loading