Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
35ca3cd
adding test-ignore to snippets that require API keys
davidsbatista Mar 30, 2026
55b1fdb
adding test-ignore to snippets that require extra dependencies
davidsbatista Mar 30, 2026
f386931
fixing wrong placement of ignore tag
davidsbatista Mar 30, 2026
ba8f685
adding ignore to fixture files / bad placeholders / network calls
davidsbatista Mar 30, 2026
e3cca7a
Revert "adding test-ignore to snippets that require API keys"
davidsbatista Mar 30, 2026
e4ffdc1
Reapply "adding test-ignore to snippets that require API keys"
davidsbatista Mar 30, 2026
8e2faf5
Revert "adding ignore to fixture files / bad placeholders / network c…
davidsbatista Mar 30, 2026
0fa4fcf
Revert "fixing wrong placement of ignore tag"
davidsbatista Mar 30, 2026
13c1001
Revert "adding test-ignore to snippets that require extra dependencies"
davidsbatista Mar 30, 2026
f4b6c12
Revert "adding test-ignore to snippets that require API keys"
davidsbatista Mar 30, 2026
6eae596
fixing some more code snippets and ignoring some
davidsbatista Mar 31, 2026
23fe1d2
fixing some more code snippets and ignoring some
davidsbatista Mar 31, 2026
ef6e287
adding fixture files from tests
davidsbatista Mar 31, 2026
ce75f21
setting path in workflow file
davidsbatista Mar 31, 2026
b3e0293
activating push triggers
davidsbatista Mar 31, 2026
d3ed80d
using gtp-4o-mini
davidsbatista Mar 31, 2026
f253af8
generating new md files
davidsbatista Mar 31, 2026
8b27b21
install hatch
davidsbatista Mar 31, 2026
8003e4a
install hatch
davidsbatista Mar 31, 2026
fdb9df4
install ffmpeg
davidsbatista Mar 31, 2026
2bcebdb
debugging
davidsbatista Mar 31, 2026
4bb3ecf
debugging
davidsbatista Mar 31, 2026
dcb7066
Merge branch 'main' into test/fix-running-code-snippets
davidsbatista Mar 31, 2026
e69c3db
debugging
davidsbatista Mar 31, 2026
0b837aa
adding extra requirements
davidsbatista Mar 31, 2026
c1a62e5
Update .github/workflows/docs-website-test-docs-snippets.yml
davidsbatista Mar 31, 2026
651d699
Apply suggestion from @anakin87
davidsbatista Mar 31, 2026
bd971b5
Apply suggestion from @anakin87
davidsbatista Mar 31, 2026
81150dd
Apply suggestion from @anakin87
davidsbatista Mar 31, 2026
b46b259
wip
davidsbatista Mar 31, 2026
1d417bf
wip
davidsbatista Mar 31, 2026
d647af1
wip
davidsbatista Mar 31, 2026
927b3c3
wip
davidsbatista Mar 31, 2026
9249358
running OpenAPIServiceConnector docstring code
davidsbatista Mar 31, 2026
fb0cd9d
running OpenAPIConnector docstring code
davidsbatista Mar 31, 2026
6c5df76
running OpenAI Embedder docstring code
davidsbatista Mar 31, 2026
c00c54f
temporary enabling running on PR
davidsbatista Mar 31, 2026
3b34b4b
Merge branch 'main' into test/fix-running-code-snippets
davidsbatista Mar 31, 2026
8bdfd80
running serperdev code snippets
davidsbatista Mar 31, 2026
97e6fd2
using test files for the llm_document_content_extractor.py docstring
davidsbatista Mar 31, 2026
c124c46
adding AZURE env vars and step summary to github
davidsbatista Mar 31, 2026
7e829d6
adding more embbeders to run
davidsbatista Mar 31, 2026
c76dfad
temporary disabling openai text embedder
davidsbatista Mar 31, 2026
d4db9bb
debugging error on text embedders docstring
davidsbatista Mar 31, 2026
408171b
cleaning + installing dev deps from pyproject.toml
davidsbatista Mar 31, 2026
5b2d030
trying use deps from pyproject.toml
davidsbatista Mar 31, 2026
d4a48f3
skip script to generate dependencies
davidsbatista Mar 31, 2026
09581d0
debugging error embedders docstring
davidsbatista Mar 31, 2026
3d1fe96
debugging
davidsbatista Mar 31, 2026
b8e8759
debugging
davidsbatista Mar 31, 2026
85fea0b
debugging: reverting to external requirements
davidsbatista Apr 1, 2026
018bc07
using pyproject.toml dependencies + disabling SERPERDEV code snippets
davidsbatista Apr 1, 2026
2534de3
removing extra requirements.txt
davidsbatista Apr 1, 2026
8303a38
adding slack notification + disabling one more snippet relying on SER…
davidsbatista Apr 1, 2026
e97a40b
removing all triggers runs only daily at 3:17 and has a workflow_disp…
davidsbatista Apr 1, 2026
bf64c91
Merge branch 'main' into test/fix-running-code-snippets
davidsbatista Apr 1, 2026
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
62 changes: 28 additions & 34 deletions .github/workflows/docs-website-test-docs-snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ on:
default: 'main'
type: string

# TEMPORARILY DISABLED
# push:
# paths:
# - 'docs-website/docs/**'
# - 'docs-website/versioned_docs/**'
# - 'docs-website/scripts/test_python_snippets.py'
# - 'docs-website/scripts/generate_requirements.py'
# - '.github/workflows/docs-website-test-docs-snippets.yml'
env:
HATCH_VERSION: "1.16.5"
PYTHON_VERSION: "3.11"

jobs:
test-docs-snippets:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 30
env:
# TODO: We'll properly set these after migration to core project
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_AD_TOKEN: ${{ secrets.AZURE_OPENAI_AD_TOKEN }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
CORE_AZURE_CS_ENDPOINT: ${{ secrets.CORE_AZURE_CS_ENDPOINT }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SERPERDEV_API_KEY: ${{ secrets.SERPERDEV_API_KEY }}

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -36,34 +36,28 @@ jobs:
with:
python-version: '3.11'

- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}

- name: Generate API reference for Docusaurus
run: hatch run docs

- name: Install base dependencies
run: |
python -m pip install --upgrade pip
pip install requests toml

- name: Generate requirements.txt
run: |
# Use input version or default to main
if [ "${{ github.event.inputs.haystack_version }}" != "" ]; then
VERSION="${{ github.event.inputs.haystack_version }}"
else
VERSION="main"
fi
echo "Generating requirements.txt for Haystack version: $VERSION"
python docs-website/scripts/generate_requirements.py --version "$VERSION"

- name: Install dependencies
run: |
if [ -f requirements.txt ]; then
echo "Installing dependencies from requirements.txt"
pip install -r requirements.txt
else
echo "Error: requirements.txt was not generated"
exit 1
fi

- name: Run snippet tests (verbose)
shell: bash
run: |
# TEMPORARY: Testing with single file to make CI green
# TODO: Expand to run all docs: --paths docs versioned_docs
python docs-website/scripts/test_python_snippets.py docs-website/reference/haystack-api/agents_api.md
hatch -e test env run -- python docs-website/scripts/test_python_snippets.py --verbose tmp_api_reference/

notify-slack-on-failure:
if: failure() && github.ref_name == 'main'
needs:
- test-docs-snippets
runs-on: ubuntu-slim
steps:
- uses: deepset-ai/notify-slack-action@3cda73b77a148f16f703274198e7771340cf862b # v1
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }}
156 changes: 0 additions & 156 deletions docs-website/scripts/generate_requirements.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs-website/scripts/test_python_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument(
"targets",
nargs="*",
help=("Optional positional list of files or directories to scan. If omitted, --paths is used."),
help="Optional positional list of files or directories to scan. If omitted, --paths is used.",
)
parser.add_argument(
"--paths",
Expand Down
2 changes: 1 addition & 1 deletion haystack/components/audio/whisper_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LocalWhisperTranscriber:
[GitHub repository](https://github.com/openai/whisper).

### Usage example

<!-- test-ignore -->
Comment thread
anakin87 marked this conversation as resolved.
```python
from haystack.components.audio import LocalWhisperTranscriber

Expand Down
12 changes: 9 additions & 3 deletions haystack/components/connectors/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ class OpenAPIConnector:
pass input arguments to this component.

Example:
<!-- test-ignore -->
```python
from haystack.utils import Secret
from haystack.components.connectors.openapi import OpenAPIConnector

serper_dev_token = Secret.from_env_var("SERPERDEV_API_KEY")

def my_custom_config_factory():
# Create and return a custom configuration for the OpenAPIClient
pass

connector = OpenAPIConnector(
openapi_spec="https://bit.ly/serperdev_openapi",
credentials=Secret.from_env_var("SERPERDEV_API_KEY"),
service_kwargs={"config_factory": my_custom_config_factory}
credentials=serper_dev_token,
service_kwargs={"config_factory": my_custom_config_factory()}
)
Comment thread
davidsbatista marked this conversation as resolved.
response = connector.run(
operation_id="search",
arguments={"q": "Who was Nikola Tesla?"}
)
```
Note:
- The `parameters` argument is required for this component.
- The `service_kwargs` argument is optional, it can be used to pass additional options to the OpenAPIClient.

"""
Expand Down
10 changes: 7 additions & 3 deletions haystack/components/connectors/openapi_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,27 @@ class OpenAPIServiceConnector:
with tool calling capabilities. In the example below we use the tool call payload directly, but in a
real-world scenario, the tool calls would usually be generated by the Chat Generator component.

Usage example:
You need to define the `serper_token` variable with your Serper.dev API token for the example to work.
Can be through the `SERPERDEV_API_KEY` environment variable or by directly assigning the token string to the
variable in the code.

Usage example:
<!-- test-ignore -->
```python
import json
import requests

from haystack.components.connectors import OpenAPIServiceConnector
from haystack.dataclasses import ChatMessage, ToolCall

from haystack.utils import Secret

tool_call = ToolCall(
tool_name="search",
arguments={"q": "Why was Sam Altman ousted from OpenAI?"},
)
message = ChatMessage.from_assistant(tool_calls=[tool_call])

serper_token = "your_serper_dev_token"
serper_token = Secret.from_env_var("SERPERDEV_API_KEY").resolve_value()
serperdev_openapi_spec = json.loads(requests.get("https://bit.ly/serper_dev_spec").text)
service_connector = OpenAPIServiceConnector()
result = service_connector.run(
Expand Down
2 changes: 1 addition & 1 deletion haystack/components/converters/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AzureOCRDocumentConverter:
[Azure documentation](https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/quickstarts/get-started-sdks-rest-api).

### Usage example

<!-- test-ignore -->
```python
import os
from datetime import datetime
Expand Down
9 changes: 6 additions & 3 deletions haystack/components/converters/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ class CSVToDocument:
It can attach metadata to the resulting documents.

### Usage example

```python
from haystack.components.converters.csv import CSVToDocument
from datetime import datetime

converter = CSVToDocument()
results = converter.run(sources=["sample.csv"], meta={"date_added": datetime.now().isoformat()})
results = converter.run(
sources=["test/test_files/csv/sample_1.csv"], meta={"date_added": datetime.now().isoformat()}
)
documents = results["documents"]

print(documents[0].content)
# 'col1,col2\\nrow1,row1\\nrow2,row2\\n'
# >> 'col1,col2\\nrow1,row1\\nrow2,row2\\n'
```
"""

Expand Down
9 changes: 7 additions & 2 deletions haystack/components/converters/docx.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,19 @@ class DOCXToDocument:
This component does not preserve page breaks in the original document.

Usage example:

```python
from haystack.components.converters.docx import DOCXToDocument, DOCXTableFormat, DOCXLinkFormat
from datetime import datetime

converter = DOCXToDocument(table_format=DOCXTableFormat.CSV, link_format=DOCXLinkFormat.MARKDOWN)
results = converter.run(sources=["sample.docx"], meta={"date_added": datetime.now().isoformat()})
results = converter.run(
sources=["test/test_files/docx/sample_docx.docx"], meta={"date_added": datetime.now().isoformat()}
)
documents = results["documents"]

print(documents[0].content)
# 'This is a text from the DOCX file.'
# >> 'This is a text from the DOCX file.'
```
"""

Expand Down
1 change: 1 addition & 0 deletions haystack/components/converters/file_to_file_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FileToFileContent:
Converts files to FileContent objects to be included in ChatMessage objects.

### Usage example
<!-- test-ignore -->
```python
from haystack.components.converters import FileToFileContent

Expand Down
5 changes: 3 additions & 2 deletions haystack/components/converters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class HTMLToDocument:
from haystack.components.converters import HTMLToDocument

converter = HTMLToDocument()
results = converter.run(sources=["path/to/sample.html"])
results = converter.run(sources=["test/test_files/html/paul_graham_superlinear.html"])
documents = results["documents"]

print(documents[0].content)
# 'This is a text from the HTML file.'
# > 'This is a text from the HTML file.'
```
"""

Expand Down
Loading
Loading