diff --git a/docs-website/docusaurus.config.js b/docs-website/docusaurus.config.js index 8aecf2fcea..4c3cca6e94 100644 --- a/docs-website/docusaurus.config.js +++ b/docs-website/docusaurus.config.js @@ -38,6 +38,9 @@ const config = { }, markdown: { + mdx1Compat: { + comments: true, + }, hooks: { onBrokenMarkdownLinks: 'throw', }, diff --git a/docs-website/reference/haystack-api/audio_api.md b/docs-website/reference/haystack-api/audio_api.md index 6eeebb6543..fd7e95b104 100644 --- a/docs-website/reference/haystack-api/audio_api.md +++ b/docs-website/reference/haystack-api/audio_api.md @@ -18,7 +18,7 @@ For the supported audio formats, languages, and other parameters, see the ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.audio import LocalWhisperTranscriber diff --git a/docs-website/reference/haystack-api/connectors_api.md b/docs-website/reference/haystack-api/connectors_api.md index af9269b612..2544984122 100644 --- a/docs-website/reference/haystack-api/connectors_api.md +++ b/docs-website/reference/haystack-api/connectors_api.md @@ -19,7 +19,8 @@ arguments to it from a Haystack pipeline run method or by other components in a pass input arguments to this component. Example: -{/\* test-ignore \*/} + + ```python from haystack.utils import Secret @@ -165,7 +166,8 @@ Can be through the `SERPERDEV_API_KEY` environment variable or by directly assig variable in the code. Usage example: -{/\* test-ignore \*/} + + ```python import json diff --git a/docs-website/reference/haystack-api/converters_api.md b/docs-website/reference/haystack-api/converters_api.md index 0ec23e70c2..dd0f1a02cd 100644 --- a/docs-website/reference/haystack-api/converters_api.md +++ b/docs-website/reference/haystack-api/converters_api.md @@ -20,7 +20,7 @@ and a Document Intelligence or Cognitive Services resource. For help with settin ### Usage example -{/\* test-ignore \*/} + ```python import os @@ -379,7 +379,7 @@ Converts files to FileContent objects to be included in ChatMessage objects. ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.converters import FileToFileContent @@ -537,7 +537,7 @@ Documents are expected to have metadata containing: ### Usage example -{/\* test-ignore \*/} + ```python from haystack import Document @@ -1740,7 +1740,8 @@ For more options on running Tika, see the [official documentation](https://github.com/apache/tika-docker/blob/main/README.md#usage). Usage example: -{/\* test-ignore \*/} + + ```python from haystack.components.converters.tika import TikaDocumentConverter diff --git a/docs-website/reference/haystack-api/embedders_api.md b/docs-website/reference/haystack-api/embedders_api.md index 3cca13c9ae..9638aca1d0 100644 --- a/docs-website/reference/haystack-api/embedders_api.md +++ b/docs-website/reference/haystack-api/embedders_api.md @@ -16,7 +16,7 @@ Calculates document embeddings using OpenAI models deployed on Azure. ### Usage example -{/\* test-ignore \*/} + ```python from haystack import Document @@ -139,7 +139,7 @@ Embeds strings using OpenAI models deployed on Azure. ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.embedders import AzureOpenAITextEmbedder @@ -257,7 +257,7 @@ Use it with the following Hugging Face APIs: #### With free serverless inference API -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder @@ -278,7 +278,7 @@ print(result["documents"][0].embedding) #### With paid inference endpoints -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder @@ -299,7 +299,7 @@ print(result["documents"][0].embedding) #### With self-hosted text embeddings inference -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder @@ -443,7 +443,7 @@ Use it with the following Hugging Face APIs: #### With free serverless inference API -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder @@ -460,7 +460,7 @@ print(text_embedder.run("I love pizza!")) #### With paid inference endpoints -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder @@ -476,7 +476,7 @@ print(text_embedder.run("I love pizza!")) #### With self-hosted text embeddings inference -{/\* test-ignore \*/} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder @@ -600,7 +600,7 @@ The embedding of each Document is stored in the `embedding` field of the Documen ### Usage example -{/\* test-ignore \*/} + ```python from haystack import Document @@ -756,7 +756,7 @@ Computes document embeddings using OpenAI models. ### Usage example -{/\* test-ignore \*/} + ```python from haystack import Document @@ -902,7 +902,7 @@ You can use it to embed user query and send it to an embedding Retriever. ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.embedders import OpenAITextEmbedder @@ -1042,7 +1042,7 @@ and send them to DocumentWriter to write into a Document Store. ### Usage example: -{/\* test-ignore \*/} + ```python from haystack import Document @@ -1195,7 +1195,7 @@ and send them to DocumentWriter to write a into a Document Store. ### Usage example: -{/\* test-ignore \*/} + ```python from haystack import Document @@ -1327,7 +1327,8 @@ Embeds strings using sparse embedding models from Sentence Transformers. You can use it to embed user query and send it to a sparse embedding retriever. Usage example: -{/\* test-ignore \*/} + + ```python from haystack.components.embedders import SentenceTransformersSparseTextEmbedder @@ -1449,7 +1450,8 @@ Embeds strings using Sentence Transformers models. You can use it to embed user query and send it to an embedding retriever. Usage example: -{/\* test-ignore \*/} + + ```python from haystack.components.embedders import SentenceTransformersTextEmbedder diff --git a/docs-website/reference/haystack-api/extractors_api.md b/docs-website/reference/haystack-api/extractors_api.md index 012e426349..a18fbc5b17 100644 --- a/docs-website/reference/haystack-api/extractors_api.md +++ b/docs-website/reference/haystack-api/extractors_api.md @@ -466,7 +466,8 @@ that contains an NER component. Annotations are stored as metadata in the documents. Usage example: -{/\* test-ignore \*/} + + ```python from haystack import Document diff --git a/docs-website/reference/haystack-api/generators_api.md b/docs-website/reference/haystack-api/generators_api.md index 9b416795a3..48a137a450 100644 --- a/docs-website/reference/haystack-api/generators_api.md +++ b/docs-website/reference/haystack-api/generators_api.md @@ -27,7 +27,7 @@ For details on OpenAI API parameters, see ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.generators import AzureOpenAIGenerator @@ -170,7 +170,7 @@ For details on OpenAI API parameters, see ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import AzureOpenAIChatGenerator @@ -388,7 +388,7 @@ For details on OpenAI API parameters, see ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import AzureOpenAIResponsesChatGenerator @@ -701,7 +701,7 @@ format for input and output. Use it to generate text with Hugging Face APIs: #### With the serverless inference API (Inference Providers) - free tier available -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator @@ -727,7 +727,7 @@ print(result) #### With the serverless inference API (Inference Providers) and text+image input -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator @@ -756,7 +756,7 @@ print(result) #### With paid inference endpoints -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator @@ -776,7 +776,7 @@ print(result) #### With self-hosted text generation inference -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator @@ -955,7 +955,7 @@ LLMs running locally may need powerful hardware. ### Usage example -{/\* test-ignore \*/} + ```python from haystack.components.generators.chat import HuggingFaceLocalChatGenerator @@ -1876,7 +1876,7 @@ Use the `HuggingFaceAPIChatGenerator` component, which supports the `chat_comple #### With Hugging Face Inference Endpoints -{/\* test-ignore \*/} + ```python from haystack.components.generators import HuggingFaceAPIGenerator @@ -1892,7 +1892,7 @@ print(result) #### With self-hosted text generation inference -{/\* test-ignore \*/} + ```python from haystack.components.generators import HuggingFaceAPIGenerator @@ -1910,7 +1910,7 @@ Be aware that this example might not work as the Hugging Face Inference API no l `text_generation` endpoint. Use the `HuggingFaceAPIChatGenerator` for generative models through the `chat_completion` endpoint. -{/\* test-ignore \*/} + ```python from haystack.components.generators import HuggingFaceAPIGenerator diff --git a/docs-website/reference/haystack-api/image_converters_api.md b/docs-website/reference/haystack-api/image_converters_api.md index 17bef04682..eb4415f7c6 100644 --- a/docs-website/reference/haystack-api/image_converters_api.md +++ b/docs-website/reference/haystack-api/image_converters_api.md @@ -24,7 +24,7 @@ Documents are expected to have metadata containing: ### Usage example -{/\* test-ignore \*/} + ```python from haystack import Document diff --git a/docs-website/reference/haystack-api/rankers_api.md b/docs-website/reference/haystack-api/rankers_api.md index a63d2830c5..f656899d2f 100644 --- a/docs-website/reference/haystack-api/rankers_api.md +++ b/docs-website/reference/haystack-api/rankers_api.md @@ -28,7 +28,8 @@ It can be used with a Text Embeddings Inference (TEI) API endpoint: - [Hugging Face Inference Endpoints](https://huggingface.co/inference-endpoints) Usage example: -{/\* test-ignore \*/} + + ```python from haystack import Document diff --git a/docs-website/reference/haystack-api/routers_api.md b/docs-website/reference/haystack-api/routers_api.md index 480bf7636c..476c3668b8 100644 --- a/docs-website/reference/haystack-api/routers_api.md +++ b/docs-website/reference/haystack-api/routers_api.md @@ -867,7 +867,7 @@ The labels are specific to each model and can be found it its description on Hug ### Usage example -{/\* test-ignore \*/} + ```python from haystack.core.pipeline import Pipeline diff --git a/docs-website/reference/haystack-api/tools_api.md b/docs-website/reference/haystack-api/tools_api.md index ebb0615607..d71226ccfd 100644 --- a/docs-website/reference/haystack-api/tools_api.md +++ b/docs-website/reference/haystack-api/tools_api.md @@ -35,7 +35,7 @@ Below is an example of creating a ComponentTool from an existing SerperDevWebSea ## Usage Example: -{/\* test-ignore \*/} + ```python from haystack import component, Pipeline diff --git a/docs-website/reference/haystack-api/utils_api.md b/docs-website/reference/haystack-api/utils_api.md index 9f27f94db9..78d731d7bc 100644 --- a/docs-website/reference/haystack-api/utils_api.md +++ b/docs-website/reference/haystack-api/utils_api.md @@ -944,7 +944,8 @@ request_with_retry( Executes an HTTP request with a configurable exponential backoff retry on failures. Usage example: -{/\* test-ignore \*/} + + ```python from haystack.utils import request_with_retry diff --git a/docs-website/reference/haystack-api/websearch_api.md b/docs-website/reference/haystack-api/websearch_api.md index 0ac65e76cc..5aae72586b 100644 --- a/docs-website/reference/haystack-api/websearch_api.md +++ b/docs-website/reference/haystack-api/websearch_api.md @@ -13,7 +13,8 @@ slug: "/websearch-api" Uses [SearchApi](https://www.searchapi.io/) to search the web for relevant documents. Usage example: -{/\* test-ignore \*/} + + ```python from haystack.components.websearch import SearchApiWebSearch @@ -136,7 +137,8 @@ Uses [Serper](https://serper.dev/) to search the web for relevant documents. See the [Serper Dev website](https://serper.dev/) for more details. Usage example: -{/\* test-ignore \*/} + + ```python from haystack.components.websearch import SerperDevWebSearch diff --git a/docs-website/scripts/test_python_snippets.py b/docs-website/scripts/test_python_snippets.py index 0393ae5f6d..a7a9c534ad 100755 --- a/docs-website/scripts/test_python_snippets.py +++ b/docs-website/scripts/test_python_snippets.py @@ -9,11 +9,11 @@ Features: - Recursively scans specified directories for .md and .mdx files - Extracts triple-backtick fenced blocks labeled with "python" or "py" -- Skips blocks preceded by an immediate "{/* test-ignore */}" marker +- Skips blocks preceded by an immediate "" marker - Supports markers above a block: - - "{/* test-run */}" to force running even if heuristically considered a concept - - "{/* test-concept */}" to force skipping as illustrative - - "{/* test-require-files: path1 path2 */}" to require files to exist (skip if missing) + - "" to force running even if heuristically considered a concept + - "" to force skipping as illustrative + - "" to require files to exist (skip if missing) - Optionally skips blocks containing unsafe patterns - Executes each snippet in isolation via a temporary file using a Python subprocess - Times out long-running snippets @@ -31,13 +31,13 @@ python scripts/test_python_snippets.py docs/overview/intro.mdx docs/concepts/components.mdx # Force-run a snippet without imports via marker above the block - {/* test-run */} + ```python print("hello world") ``` # Mark an illustrative snippet to skip - {/* test-concept */} + ```python @dataclass class Foo: @@ -45,7 +45,7 @@ class Foo: ``` # Require fixtures; snippet will be skipped if files are missing - {/* test-require-files: assets/dog.jpg data/example.json */} + ```python from haystack.dataclasses import ByteStream image = ByteStream.from_file_path("assets/dog.jpg") @@ -68,10 +68,10 @@ class Foo: FENCE_START_RE = re.compile(r"^\s*```(?P[^\n\r]*)\s*$") FENCE_END_RE = re.compile(r"^\s*```\s*$") -TEST_IGNORE_MARK = "{/* test-ignore */}" -TEST_CONCEPT_MARK = "{/* test-concept */}" -TEST_RUN_MARK = "{/* test-run */}" -TEST_REQUIRE_FILES_PREFIX = "{/* test-require-files:" +TEST_IGNORE_MARK = "" +TEST_CONCEPT_MARK = "" +TEST_RUN_MARK = "" +TEST_REQUIRE_FILES_PREFIX = ""): markers.append(prev) j -= 1 continue @@ -186,7 +186,7 @@ def is_python_language_tag(tag: str) -> bool: if TEST_RUN_MARK in markers: pending_forced_run = True for marker in markers: - if marker.startswith(TEST_REQUIRE_FILES_PREFIX) and marker.endswith("*/}"): + if marker.startswith(TEST_REQUIRE_FILES_PREFIX) and marker.endswith("-->"): content = marker[len(TEST_REQUIRE_FILES_PREFIX) : -3].strip() if content: pending_requires_files.extend(content.split()) diff --git a/haystack/components/audio/whisper_local.py b/haystack/components/audio/whisper_local.py index 81c3e0ade2..c57583b11a 100644 --- a/haystack/components/audio/whisper_local.py +++ b/haystack/components/audio/whisper_local.py @@ -40,7 +40,7 @@ class LocalWhisperTranscriber: [GitHub repository](https://github.com/openai/whisper). ### Usage example - {/* test-ignore */} + ```python from haystack.components.audio import LocalWhisperTranscriber diff --git a/haystack/components/connectors/openapi.py b/haystack/components/connectors/openapi.py index 1747729767..1435946e9c 100644 --- a/haystack/components/connectors/openapi.py +++ b/haystack/components/connectors/openapi.py @@ -24,7 +24,7 @@ class OpenAPIConnector: pass input arguments to this component. Example: - {/* test-ignore */} + ```python from haystack.utils import Secret from haystack.components.connectors.openapi import OpenAPIConnector diff --git a/haystack/components/connectors/openapi_service.py b/haystack/components/connectors/openapi_service.py index 29227c4778..4970f84c41 100644 --- a/haystack/components/connectors/openapi_service.py +++ b/haystack/components/connectors/openapi_service.py @@ -171,7 +171,7 @@ class OpenAPIServiceConnector: variable in the code. Usage example: - {/* test-ignore */} + ```python import json import httpx diff --git a/haystack/components/converters/azure.py b/haystack/components/converters/azure.py index 24225721b9..7ff45d9365 100644 --- a/haystack/components/converters/azure.py +++ b/haystack/components/converters/azure.py @@ -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 diff --git a/haystack/components/converters/file_to_file_content.py b/haystack/components/converters/file_to_file_content.py index 88a4486a19..4de53e8da2 100644 --- a/haystack/components/converters/file_to_file_content.py +++ b/haystack/components/converters/file_to_file_content.py @@ -22,7 +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 diff --git a/haystack/components/converters/image/document_to_image.py b/haystack/components/converters/image/document_to_image.py index e0fdca480f..2fd82ef78d 100644 --- a/haystack/components/converters/image/document_to_image.py +++ b/haystack/components/converters/image/document_to_image.py @@ -34,7 +34,7 @@ class DocumentToImageContent: - For PDF files, a `page_number` key specifying which page to extract ### Usage example - {/* test-ignore */} + ```python from haystack import Document from haystack.components.converters.image.document_to_image import DocumentToImageContent diff --git a/haystack/components/converters/tika.py b/haystack/components/converters/tika.py index b158427069..a102549e5a 100644 --- a/haystack/components/converters/tika.py +++ b/haystack/components/converters/tika.py @@ -60,7 +60,7 @@ class TikaDocumentConverter: see the [official documentation](https://github.com/apache/tika-docker/blob/main/README.md#usage). Usage example: - {/* test-ignore */} + ```python from haystack.components.converters.tika import TikaDocumentConverter from datetime import datetime diff --git a/haystack/components/embedders/azure_document_embedder.py b/haystack/components/embedders/azure_document_embedder.py index f6bbdbe7b8..490a36710b 100644 --- a/haystack/components/embedders/azure_document_embedder.py +++ b/haystack/components/embedders/azure_document_embedder.py @@ -21,7 +21,7 @@ class AzureOpenAIDocumentEmbedder(OpenAIDocumentEmbedder): Calculates document embeddings using OpenAI models deployed on Azure. ### Usage example - {/* test-ignore */} + ```python from haystack import Document from haystack.components.embedders import AzureOpenAIDocumentEmbedder diff --git a/haystack/components/embedders/azure_text_embedder.py b/haystack/components/embedders/azure_text_embedder.py index b27a833a84..a17efcb33c 100644 --- a/haystack/components/embedders/azure_text_embedder.py +++ b/haystack/components/embedders/azure_text_embedder.py @@ -19,7 +19,7 @@ class AzureOpenAITextEmbedder(OpenAITextEmbedder): Embeds strings using OpenAI models deployed on Azure. ### Usage example - {/* test-ignore */} + ```python from haystack.components.embedders import AzureOpenAITextEmbedder diff --git a/haystack/components/embedders/hugging_face_api_document_embedder.py b/haystack/components/embedders/hugging_face_api_document_embedder.py index 7e22795f48..f572628d3f 100644 --- a/haystack/components/embedders/hugging_face_api_document_embedder.py +++ b/haystack/components/embedders/hugging_face_api_document_embedder.py @@ -36,7 +36,7 @@ class HuggingFaceAPIDocumentEmbedder: ### Usage examples #### With free serverless inference API - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder from haystack.utils import Secret @@ -55,7 +55,7 @@ class HuggingFaceAPIDocumentEmbedder: ``` #### With paid inference endpoints - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder from haystack.utils import Secret @@ -74,7 +74,7 @@ class HuggingFaceAPIDocumentEmbedder: ``` #### With self-hosted text embeddings inference - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPIDocumentEmbedder from haystack.dataclasses import Document diff --git a/haystack/components/embedders/hugging_face_api_text_embedder.py b/haystack/components/embedders/hugging_face_api_text_embedder.py index ca9e393861..5eb45a8c73 100644 --- a/haystack/components/embedders/hugging_face_api_text_embedder.py +++ b/haystack/components/embedders/hugging_face_api_text_embedder.py @@ -29,7 +29,7 @@ class HuggingFaceAPITextEmbedder: ### Usage examples #### With free serverless inference API - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder from haystack.utils import Secret @@ -44,7 +44,7 @@ class HuggingFaceAPITextEmbedder: ``` #### With paid inference endpoints - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder from haystack.utils import Secret @@ -58,7 +58,7 @@ class HuggingFaceAPITextEmbedder: ``` #### With self-hosted text embeddings inference - {/* test-ignore */} + ```python from haystack.components.embedders import HuggingFaceAPITextEmbedder from haystack.utils import Secret diff --git a/haystack/components/embedders/image/sentence_transformers_doc_image_embedder.py b/haystack/components/embedders/image/sentence_transformers_doc_image_embedder.py index 5a84f70195..f609a83971 100644 --- a/haystack/components/embedders/image/sentence_transformers_doc_image_embedder.py +++ b/haystack/components/embedders/image/sentence_transformers_doc_image_embedder.py @@ -32,7 +32,7 @@ class SentenceTransformersDocumentImageEmbedder: The embedding of each Document is stored in the `embedding` field of the Document. ### Usage example - {/* test-ignore */} + ```python from haystack import Document from haystack.components.embedders.image import SentenceTransformersDocumentImageEmbedder diff --git a/haystack/components/embedders/openai_document_embedder.py b/haystack/components/embedders/openai_document_embedder.py index 980ff70c4e..1d3626c3c2 100644 --- a/haystack/components/embedders/openai_document_embedder.py +++ b/haystack/components/embedders/openai_document_embedder.py @@ -24,7 +24,7 @@ class OpenAIDocumentEmbedder: Computes document embeddings using OpenAI models. ### Usage example - {/* test-ignore */} + ```python from haystack import Document from haystack.components.embedders import OpenAIDocumentEmbedder diff --git a/haystack/components/embedders/openai_text_embedder.py b/haystack/components/embedders/openai_text_embedder.py index fb276a315b..24672bb050 100644 --- a/haystack/components/embedders/openai_text_embedder.py +++ b/haystack/components/embedders/openai_text_embedder.py @@ -21,7 +21,7 @@ class OpenAITextEmbedder: You can use it to embed user query and send it to an embedding Retriever. ### Usage example - {/* test-ignore */} + ```python from haystack.components.embedders import OpenAITextEmbedder diff --git a/haystack/components/embedders/sentence_transformers_document_embedder.py b/haystack/components/embedders/sentence_transformers_document_embedder.py index 01091c8bf7..252111783b 100644 --- a/haystack/components/embedders/sentence_transformers_document_embedder.py +++ b/haystack/components/embedders/sentence_transformers_document_embedder.py @@ -25,7 +25,7 @@ class SentenceTransformersDocumentEmbedder: and send them to DocumentWriter to write into a Document Store. ### Usage example: - {/* test-ignore */} + ```python from haystack import Document from haystack.components.embedders import SentenceTransformersDocumentEmbedder diff --git a/haystack/components/embedders/sentence_transformers_sparse_document_embedder.py b/haystack/components/embedders/sentence_transformers_sparse_document_embedder.py index 7dc1e3f169..c269851f96 100644 --- a/haystack/components/embedders/sentence_transformers_sparse_document_embedder.py +++ b/haystack/components/embedders/sentence_transformers_sparse_document_embedder.py @@ -25,7 +25,7 @@ class SentenceTransformersSparseDocumentEmbedder: and send them to DocumentWriter to write a into a Document Store. ### Usage example: - {/* test-ignore */} + ```python from haystack import Document from haystack.components.embedders import SentenceTransformersSparseDocumentEmbedder diff --git a/haystack/components/embedders/sentence_transformers_sparse_text_embedder.py b/haystack/components/embedders/sentence_transformers_sparse_text_embedder.py index db3c486c5c..31154a8c07 100644 --- a/haystack/components/embedders/sentence_transformers_sparse_text_embedder.py +++ b/haystack/components/embedders/sentence_transformers_sparse_text_embedder.py @@ -22,7 +22,7 @@ class SentenceTransformersSparseTextEmbedder: You can use it to embed user query and send it to a sparse embedding retriever. Usage example: - {/* test-ignore */} + ```python from haystack.components.embedders import SentenceTransformersSparseTextEmbedder diff --git a/haystack/components/embedders/sentence_transformers_text_embedder.py b/haystack/components/embedders/sentence_transformers_text_embedder.py index 545d2e0e2c..3285fab5d0 100644 --- a/haystack/components/embedders/sentence_transformers_text_embedder.py +++ b/haystack/components/embedders/sentence_transformers_text_embedder.py @@ -21,7 +21,7 @@ class SentenceTransformersTextEmbedder: You can use it to embed user query and send it to an embedding retriever. Usage example: - {/* test-ignore */} + ```python from haystack.components.embedders import SentenceTransformersTextEmbedder diff --git a/haystack/components/extractors/named_entity_extractor.py b/haystack/components/extractors/named_entity_extractor.py index 31cbb23670..259d0855fc 100644 --- a/haystack/components/extractors/named_entity_extractor.py +++ b/haystack/components/extractors/named_entity_extractor.py @@ -88,7 +88,7 @@ class NamedEntityExtractor: in the documents. Usage example: - {/* test-ignore */} + ```python from haystack import Document from haystack.components.extractors.named_entity_extractor import NamedEntityExtractor diff --git a/haystack/components/generators/azure.py b/haystack/components/generators/azure.py index 602d9876da..acf088a600 100644 --- a/haystack/components/generators/azure.py +++ b/haystack/components/generators/azure.py @@ -33,7 +33,7 @@ class AzureOpenAIGenerator(OpenAIGenerator): ### Usage example - {/* test-ignore */} + ```python from haystack.components.generators import AzureOpenAIGenerator from haystack.utils import Secret diff --git a/haystack/components/generators/chat/azure.py b/haystack/components/generators/chat/azure.py index d1caca9cfe..ac3a0d0aeb 100644 --- a/haystack/components/generators/chat/azure.py +++ b/haystack/components/generators/chat/azure.py @@ -42,7 +42,7 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator): [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat). ### Usage example - {/* test-ignore */} + ```python from haystack.components.generators.chat import AzureOpenAIChatGenerator from haystack.dataclasses import ChatMessage diff --git a/haystack/components/generators/chat/azure_responses.py b/haystack/components/generators/chat/azure_responses.py index 662725b6ed..89a2cdae0b 100644 --- a/haystack/components/generators/chat/azure_responses.py +++ b/haystack/components/generators/chat/azure_responses.py @@ -34,7 +34,7 @@ class AzureOpenAIResponsesChatGenerator(OpenAIResponsesChatGenerator): [OpenAI documentation](https://platform.openai.com/docs/api-reference/responses). ### Usage example - {/* test-ignore */} + ```python from haystack.components.generators.chat import AzureOpenAIResponsesChatGenerator from haystack.dataclasses import ChatMessage diff --git a/haystack/components/generators/chat/hugging_face_api.py b/haystack/components/generators/chat/hugging_face_api.py index 6b40172e27..924238f7aa 100644 --- a/haystack/components/generators/chat/hugging_face_api.py +++ b/haystack/components/generators/chat/hugging_face_api.py @@ -263,7 +263,7 @@ class HuggingFaceAPIChatGenerator: ### Usage examples #### With the serverless inference API (Inference Providers) - free tier available - {/* test-ignore */} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator from haystack.dataclasses import ChatMessage @@ -287,7 +287,7 @@ class HuggingFaceAPIChatGenerator: ``` #### With the serverless inference API (Inference Providers) and text+image input - {/* test-ignore */} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator from haystack.dataclasses import ChatMessage, ImageContent @@ -314,7 +314,7 @@ class HuggingFaceAPIChatGenerator: ``` #### With paid inference endpoints - {/* test-ignore */} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator from haystack.dataclasses import ChatMessage @@ -332,7 +332,7 @@ class HuggingFaceAPIChatGenerator: ``` #### With self-hosted text generation inference - {/* test-ignore */} + ```python from haystack.components.generators.chat import HuggingFaceAPIChatGenerator from haystack.dataclasses import ChatMessage diff --git a/haystack/components/generators/chat/hugging_face_local.py b/haystack/components/generators/chat/hugging_face_local.py index f403e2911a..ad5edd75d9 100644 --- a/haystack/components/generators/chat/hugging_face_local.py +++ b/haystack/components/generators/chat/hugging_face_local.py @@ -95,7 +95,7 @@ class HuggingFaceLocalChatGenerator: LLMs running locally may need powerful hardware. ### Usage example - {/* test-ignore */} + ```python from haystack.components.generators.chat import HuggingFaceLocalChatGenerator from haystack.dataclasses import ChatMessage diff --git a/haystack/components/generators/hugging_face_api.py b/haystack/components/generators/hugging_face_api.py index 36d3b23c41..9b1bc3ad1b 100644 --- a/haystack/components/generators/hugging_face_api.py +++ b/haystack/components/generators/hugging_face_api.py @@ -50,7 +50,7 @@ class HuggingFaceAPIGenerator: ### Usage examples #### With Hugging Face Inference Endpoints - {/* test-ignore */} + ```python from haystack.components.generators import HuggingFaceAPIGenerator from haystack.utils import Secret @@ -64,7 +64,7 @@ class HuggingFaceAPIGenerator: ``` #### With self-hosted text generation inference - {/* test-ignore */} + ```python from haystack.components.generators import HuggingFaceAPIGenerator @@ -81,7 +81,7 @@ class HuggingFaceAPIGenerator: `text_generation` endpoint. Use the `HuggingFaceAPIChatGenerator` for generative models through the `chat_completion` endpoint. - {/* test-ignore */} + ```python from haystack.components.generators import HuggingFaceAPIGenerator from haystack.utils import Secret diff --git a/haystack/components/rankers/hugging_face_tei.py b/haystack/components/rankers/hugging_face_tei.py index db6e95b4e9..5e5957854f 100644 --- a/haystack/components/rankers/hugging_face_tei.py +++ b/haystack/components/rankers/hugging_face_tei.py @@ -38,7 +38,7 @@ class HuggingFaceTEIRanker: - [Hugging Face Inference Endpoints](https://huggingface.co/inference-endpoints) Usage example: - {/* test-ignore */} + ```python from haystack import Document from haystack.components.rankers import HuggingFaceTEIRanker diff --git a/haystack/components/routers/transformers_text_router.py b/haystack/components/routers/transformers_text_router.py index a304c94521..ff95c21b1c 100644 --- a/haystack/components/routers/transformers_text_router.py +++ b/haystack/components/routers/transformers_text_router.py @@ -22,7 +22,7 @@ class TransformersTextRouter: The labels are specific to each model and can be found it its description on Hugging Face. ### Usage example - {/* test-ignore */} + ```python from haystack.core.pipeline import Pipeline from haystack.components.routers import TransformersTextRouter diff --git a/haystack/components/websearch/searchapi.py b/haystack/components/websearch/searchapi.py index 806afdfcbe..88694d7501 100644 --- a/haystack/components/websearch/searchapi.py +++ b/haystack/components/websearch/searchapi.py @@ -24,7 +24,7 @@ class SearchApiWebSearch: Uses [SearchApi](https://www.searchapi.io/) to search the web for relevant documents. Usage example: - {/* test-ignore */} + ```python from haystack.components.websearch import SearchApiWebSearch from haystack.utils import Secret diff --git a/haystack/components/websearch/serper_dev.py b/haystack/components/websearch/serper_dev.py index 3dcb02683c..a3eacf181f 100644 --- a/haystack/components/websearch/serper_dev.py +++ b/haystack/components/websearch/serper_dev.py @@ -27,7 +27,7 @@ class SerperDevWebSearch: See the [Serper Dev website](https://serper.dev/) for more details. Usage example: - {/* test-ignore */} + ```python from haystack.components.websearch import SerperDevWebSearch from haystack.utils import Secret diff --git a/haystack/tools/component_tool.py b/haystack/tools/component_tool.py index 80c13e2deb..9441f3d5c5 100644 --- a/haystack/tools/component_tool.py +++ b/haystack/tools/component_tool.py @@ -59,7 +59,7 @@ class ComponentTool(Tool): Below is an example of creating a ComponentTool from an existing SerperDevWebSearch component. ## Usage Example: - {/* test-ignore */} + ```python from haystack import component, Pipeline from haystack.tools import ComponentTool diff --git a/haystack/utils/requests_utils.py b/haystack/utils/requests_utils.py index 477751d473..c5270cc055 100644 --- a/haystack/utils/requests_utils.py +++ b/haystack/utils/requests_utils.py @@ -18,7 +18,7 @@ def request_with_retry( Executes an HTTP request with a configurable exponential backoff retry on failures. Usage example: - {/* test-ignore */} + ```python from haystack.utils import request_with_retry