docs: Sync Haystack API reference on Docusaurus (#10842)

Co-authored-by: julian-risch <[email protected]>
This commit is contained in:
Haystack Bot
2026-03-16 18:37:44 +01:00
committed by GitHub
co-authored by julian-risch
parent 1794405984
commit e6e3f239b4
30 changed files with 292 additions and 250 deletions
@@ -382,7 +382,7 @@ my_state = State(
#### __init__
```python
__init__(schema: dict[str, Any], data: dict[str, Any] | None = None)
__init__(schema: dict[str, Any], data: dict[str, Any] | None = None) -> None
```
Initialize a State object with a schema and optional data.
@@ -439,7 +439,7 @@ Value is merged or overwritten according to these rules:
#### data
```python
data
data: dict[str, Any]
```
All current data of the state.
@@ -463,7 +463,7 @@ Check if a key exists in the state.
#### to_dict
```python
to_dict()
to_dict() -> dict[str, Any]
```
Convert the State object to a dictionary.
@@ -471,7 +471,7 @@ Convert the State object to a dictionary.
#### from_dict
```python
from_dict(data: dict[str, Any])
from_dict(data: dict[str, Any]) -> State
```
Convert a dictionary back to a State object.
@@ -32,7 +32,7 @@ __init__(
model: WhisperLocalModel = "large",
device: ComponentDevice | None = None,
whisper_params: dict[str, Any] | None = None,
)
) -> None
```
Creates an instance of the LocalWhisperTranscriber component.
@@ -87,7 +87,7 @@ Deserializes the component from a dictionary.
run(
sources: list[str | Path | ByteStream],
whisper_params: dict[str, Any] | None = None,
)
) -> dict[str, Any]
```
Transcribes a list of audio files into a list of documents.
@@ -101,7 +101,7 @@ Transcribes a list of audio files into a list of documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of documents where each document is a transcribed audio file. The content of
the document is the transcription text, and the document's metadata contains the values returned by
the Whisper model, such as the alignment data and the path to the audio file used
@@ -159,8 +159,8 @@ __init__(
api_base_url: str | None = None,
organization: str | None = None,
http_client_kwargs: dict[str, Any] | None = None,
**kwargs: dict[str, Any] | None
)
**kwargs: Any
) -> None
```
Creates an instance of the RemoteWhisperTranscriber component.
@@ -177,7 +177,7 @@ Creates an instance of the RemoteWhisperTranscriber component.
OpenAI [documentation](https://platform.openai.com/docs/api-reference/audio).
- **http_client_kwargs** (<code>dict\[str, Any\] | None</code>) – A dictionary of keyword arguments to configure a custom `httpx.Client`or `httpx.AsyncClient`.
For more information, see the [HTTPX documentation](https://www.python-httpx.org/api/#client).
- **kwargs** – Other optional parameters for the model. These are sent directly to the OpenAI
- **kwargs** (<code>Any</code>) – Other optional parameters for the model. These are sent directly to the OpenAI
endpoint. See OpenAI [documentation](https://platform.openai.com/docs/api-reference/audio) for more details.
Some of the supported parameters are:
- `language`: The language of the input audio.
@@ -226,7 +226,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(sources: list[str | Path | ByteStream])
run(sources: list[str | Path | ByteStream]) -> dict[str, Any]
```
Transcribes the list of audio files into a list of documents.
@@ -237,6 +237,6 @@ Transcribes the list of audio files into a list of documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of documents, one document for each file.
The content of each document is the transcribed text.
@@ -70,7 +70,7 @@ __init__(
last_message_only: bool = False,
*,
return_only_referenced_documents: bool = True
)
) -> None
```
Creates an instance of the AnswerBuilder component.
@@ -107,7 +107,7 @@ run(
documents: list[Document] | None = None,
pattern: str | None = None,
reference_pattern: str | None = None,
)
) -> dict[str, Any]
```
Turns the output of a Generator into `GeneratedAnswer` objects using regular expressions.
@@ -140,7 +140,7 @@ Turns the output of a Generator into `GeneratedAnswer` objects using regular exp
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `answers`: The answers received from the output of the Generator.
## chat_prompt_builder
@@ -259,7 +259,7 @@ __init__(
template: list[ChatMessage] | str | None = None,
required_variables: list[str] | Literal["*"] | None = None,
variables: list[str] | None = None,
)
) -> None
```
Constructs a ChatPromptBuilder component.
@@ -473,7 +473,7 @@ __init__(
template: str,
required_variables: list[str] | Literal["*"] | None = None,
variables: list[str] | None = None,
)
) -> None
```
Constructs a PromptBuilder component.
@@ -511,8 +511,8 @@ Returns a dictionary representation of the component.
run(
template: str | None = None,
template_variables: dict[str, Any] | None = None,
**kwargs: dict[str, Any] | None
)
**kwargs: Any
) -> dict[str, Any]
```
Renders the prompt template with the provided variables.
@@ -526,11 +526,11 @@ In order to overwrite pipeline kwargs, you can set the `template_variables` para
- **template** (<code>str | None</code>) – An optional string template to overwrite PromptBuilder's default template. If None, the default template
provided at initialization is used.
- **template_variables** (<code>dict\[str, Any\] | None</code>) – An optional dictionary of template variables to overwrite the pipeline variables.
- **kwargs** – Pipeline variables used for rendering the prompt.
- **kwargs** (<code>Any</code>) – Pipeline variables used for rendering the prompt.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `prompt`: The updated prompt text after rendering the prompt template.
**Raises:**
@@ -38,7 +38,7 @@ assert results == {"hits": [documents[0], documents[2]], "misses": ["https://exa
#### __init__
```python
__init__(document_store: DocumentStore, cache_field: str)
__init__(document_store: DocumentStore, cache_field: str) -> None
```
Creates a CacheChecker component.
@@ -80,7 +80,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(items: list[Any])
run(items: list[Any]) -> dict[str, Any]
```
Checks if any document associated with the specified cache field is already present in the store.
@@ -91,6 +91,6 @@ Checks if any document associated with the specified cache field is already pres
**Returns:**
- – A dictionary with two keys:
- <code>dict\[str, Any\]</code> – A dictionary with two keys:
- `hits` - Documents that matched with at least one of the items.
- `misses` - Items that were not present in any documents.
@@ -56,7 +56,7 @@ assert written_docs[0] == Document(id="1", content="This is an English document"
#### __init__
```python
__init__(languages: list[str] | None = None)
__init__(languages: list[str] | None = None) -> None
```
Initializes the DocumentLanguageClassifier component.
@@ -70,7 +70,7 @@ Initializes the DocumentLanguageClassifier component.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Classifies the language of each document and adds it to its metadata.
@@ -84,7 +84,7 @@ sets the metadata value to "unmatched".
**Returns:**
- – A dictionary with the following key:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following key:
- `documents`: A list of documents with an added `language` metadata field.
**Raises:**
@@ -161,7 +161,7 @@ __init__(
["HF_API_TOKEN", "HF_TOKEN"], strict=False
),
huggingface_pipeline_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Initializes the TransformersZeroShotDocumentClassifier.
@@ -191,7 +191,7 @@ for the full list of zero-shot classification models (NLI) models.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -227,7 +227,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(documents: list[Document], batch_size: int = 1)
run(documents: list[Document], batch_size: int = 1) -> dict[str, Any]
```
Classifies the documents based on the provided labels and adds them to their metadata.
@@ -243,5 +243,5 @@ the `details` key within the `classification` dictionary.
**Returns:**
- – A dictionary with the following key:
- <code>dict\[str, Any\]</code> – A dictionary with the following key:
- `documents`: A list of documents with an added metadata field called `classification`.
@@ -47,7 +47,7 @@ __init__(
openapi_spec: str,
credentials: Secret | None = None,
service_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Initialize the OpenAPIConnector with a specification and optional credentials.
@@ -185,7 +185,7 @@ print(result)
#### __init__
```python
__init__(ssl_verify: bool | str | None = None)
__init__(ssl_verify: bool | str | None = None) -> None
```
Initializes the OpenAPIServiceConnector instance
@@ -52,7 +52,7 @@ __init__(
page_layout: Literal["natural", "single_column"] = "natural",
threshold_y: float | None = 0.05,
store_full_path: bool = False,
)
) -> None
```
Creates an AzureOCRDocumentConverter component.
@@ -85,7 +85,7 @@ Creates an AzureOCRDocumentConverter component.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Convert a list of files to Documents using Azure's Document Intelligence service.
@@ -101,7 +101,7 @@ Convert a list of files to Documents using Azure's Document Intelligence service
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: List of created Documents
- `raw_azure_response`: List of raw Azure responses used to create the Documents
@@ -164,7 +164,7 @@ __init__(
conversion_mode: Literal["file", "row"] = "file",
delimiter: str = ",",
quotechar: str = '"'
)
) -> None
```
Creates a CSVToDocument component.
@@ -189,7 +189,7 @@ run(
*,
content_column: str | None = None,
meta: dict[str, Any] | list[dict[str, Any]] | None = None
)
) -> dict[str, Any]
```
Converts CSV files to a Document (file mode) or to one Document per row (row mode).
@@ -209,7 +209,7 @@ Converts CSV files to a Document (file mode) or to one Document per row (row mod
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Created documents
## docx
@@ -290,7 +290,7 @@ __init__(
table_format: str | DOCXTableFormat = DOCXTableFormat.CSV,
link_format: str | DOCXLinkFormat = DOCXLinkFormat.NONE,
store_full_path: bool = False,
)
) -> None
```
Create a DOCXToDocument component.
@@ -340,7 +340,7 @@ Deserializes the component from a dictionary.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Converts DOCX files to Documents.
@@ -357,7 +357,7 @@ Converts DOCX files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Created Documents
## file_to_file_content
@@ -436,7 +436,7 @@ print(documents[0].content)
__init__(
extraction_kwargs: dict[str, Any] | None = None,
store_full_path: bool = False,
)
) -> None
```
Create an HTMLToDocument component.
@@ -484,7 +484,7 @@ run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
extraction_kwargs: dict[str, Any] | None = None,
)
) -> dict[str, Any]
```
Converts a list of HTML files to Documents.
@@ -502,7 +502,7 @@ Converts a list of HTML files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Created Documents
## image/document_to_image
@@ -561,7 +561,7 @@ __init__(
root_path: str | None = None,
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None
)
) -> None
```
Initialize the DocumentToImageContent component.
@@ -638,7 +638,7 @@ print(documents)
#### __init__
```python
__init__(*, store_full_path: bool = False)
__init__(*, store_full_path: bool = False) -> None
```
Initialize the ImageFileToDocument component.
@@ -710,7 +710,7 @@ __init__(
*,
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None
)
) -> None
```
Create the ImageFileToImageContent component.
@@ -791,7 +791,7 @@ __init__(
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None,
page_range: list[str | int] | None = None
)
) -> None
```
Create the PDFToImageContent component.
@@ -929,7 +929,7 @@ __init__(
content_key: str | None = None,
extra_meta_fields: set[str] | Literal["*"] | None = None,
store_full_path: bool = False,
)
) -> None
```
Creates a JSONConverter component.
@@ -1002,7 +1002,7 @@ Deserializes the component from a dictionary.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Converts a list of JSON files to documents.
@@ -1018,7 +1018,7 @@ Converts a list of JSON files to documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of created documents.
## markdown
@@ -1047,7 +1047,7 @@ __init__(
table_to_single_line: bool = False,
progress_bar: bool = True,
store_full_path: bool = False,
)
) -> None
```
Create a MarkdownToDocument component.
@@ -1065,7 +1065,7 @@ Create a MarkdownToDocument component.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Converts a list of Markdown files to Documents.
@@ -1082,7 +1082,7 @@ Converts a list of Markdown files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: List of created Documents
## msg
@@ -1217,7 +1217,7 @@ assert result["functions"]
#### __init__
```python
__init__()
__init__() -> None
```
Create an OpenAPIServiceToFunctions component.
@@ -1304,18 +1304,18 @@ The Component input will be `documents`.
#### run
```python
run(**kwargs)
run(**kwargs: Any) -> dict[str, Any]
```
Renders the Jinja template with the provided inputs.
**Parameters:**
- **kwargs** – Must contain all variables used in the `template` string.
- **kwargs** (<code>Any</code>) – Must contain all variables used in the `template` string.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `output`: Rendered Jinja template.
**Raises:**
@@ -1445,7 +1445,7 @@ see: https://pdfminersix.readthedocs.io/en/latest/faq.html#why-are-there-cid-x-v
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Converts PDF files to Documents.
@@ -1462,7 +1462,7 @@ Converts PDF files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Created Documents
## pptx
@@ -1489,7 +1489,7 @@ print(documents[0].content)
__init__(
store_full_path: bool = False,
link_format: Literal["markdown", "plain", "none"] = "none",
)
) -> None
```
Create a PPTXToDocument component.
@@ -1521,7 +1521,7 @@ Serializes the component to a dictionary.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, Any]
```
Converts PPTX files to Documents.
@@ -1538,7 +1538,7 @@ Converts PPTX files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Created Documents
## pypdf
@@ -1589,7 +1589,7 @@ __init__(
layout_mode_strip_rotated: bool = True,
layout_mode_font_height_weight: float = 1.0,
store_full_path: bool = False
)
) -> None
```
Create an PyPDFToDocument component.
@@ -1617,30 +1617,30 @@ Create an PyPDFToDocument component.
#### to_dict
```python
to_dict()
to_dict() -> dict[str, Any]
```
Serializes the component to a dictionary.
**Returns:**
- – Dictionary with serialized data.
- <code>dict\[str, Any\]</code> – Dictionary with serialized data.
#### from_dict
```python
from_dict(data)
from_dict(data: dict[str, Any]) -> PyPDFToDocument
```
Deserializes the component from a dictionary.
**Parameters:**
- **data** – Dictionary with serialized data.
- **data** (<code>dict\[str, Any\]</code>) – Dictionary with serialized data.
**Returns:**
- – Deserialized component.
- <code>PyPDFToDocument</code> – Deserialized component.
#### run
@@ -1648,7 +1648,7 @@ Deserializes the component from a dictionary.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, list[Document]]
```
Converts PDF files to documents.
@@ -1664,7 +1664,7 @@ Converts PDF files to documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- `documents`: A list of converted documents.
## tika
@@ -1678,7 +1678,7 @@ Custom parser to extract pages from Tika XHTML content.
#### handle_starttag
```python
handle_starttag(tag: str, attrs: list[tuple])
handle_starttag(tag: str, attrs: list[tuple[str, str | None]]) -> None
```
Identify the start of a page div.
@@ -1686,7 +1686,7 @@ Identify the start of a page div.
#### handle_endtag
```python
handle_endtag(tag: str)
handle_endtag(tag: str) -> None
```
Identify the end of a page div.
@@ -1694,7 +1694,7 @@ Identify the end of a page div.
#### handle_data
```python
handle_data(data: str)
handle_data(data: str) -> None
```
Populate the page content.
@@ -1728,7 +1728,7 @@ print(documents[0].content)
```python
__init__(
tika_url: str = "http://localhost:9998/tika", store_full_path: bool = False
)
) -> None
```
Create a TikaDocumentConverter component.
@@ -1745,7 +1745,7 @@ Create a TikaDocumentConverter component.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, list[Document]]
```
Converts files to Documents.
@@ -1762,7 +1762,7 @@ Converts files to Documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- `documents`: Created Documents
## txt
@@ -1790,7 +1790,7 @@ print(documents[0].content)
#### __init__
```python
__init__(encoding: str = 'utf-8', store_full_path: bool = False)
__init__(encoding: str = 'utf-8', store_full_path: bool = False) -> None
```
Creates a TextFileToDocument component.
@@ -1809,7 +1809,7 @@ Creates a TextFileToDocument component.
run(
sources: list[str | Path | ByteStream],
meta: dict[str, Any] | list[dict[str, Any]] | None = None,
)
) -> dict[str, list[Document]]
```
Converts text files to documents.
@@ -1825,7 +1825,7 @@ Converts text files to documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- `documents`: A list of converted documents.
## xlsx
@@ -1866,7 +1866,7 @@ __init__(
*,
link_format: Literal["markdown", "plain", "none"] = "none",
store_full_path: bool = False
)
) -> None
```
Creates a XLSXToDocument component.
@@ -10,6 +10,8 @@ slug: "/data-classes-api"
### ExtractedAnswer
Holds an answer extracted by an extractive Reader (query, score, text, and optional document/context).
#### to_dict
```python
@@ -40,6 +42,8 @@ Deserialize the object from a dictionary.
### GeneratedAnswer
Holds a generated answer from a Generator (answer text, query, referenced documents, and metadata).
#### to_dict
```python
@@ -171,6 +175,8 @@ Populate the AgentBreakpoint from a dictionary representation.
### AgentSnapshot
Snapshot of an Agent's state at a breakpoint (component inputs, visit counts, and breakpoint).
#### to_dict
```python
@@ -922,7 +928,7 @@ The `blob` field is converted to its original type.
#### content_type
```python
content_type
content_type: str
```
Returns the type of the content for the document.
@@ -34,7 +34,7 @@ __init__(
index: str | None = None,
async_executor: ThreadPoolExecutor | None = None,
return_embedding: bool = True,
)
) -> None
```
Initializes the DocumentStore.
@@ -58,7 +58,7 @@ Initializes the DocumentStore.
#### shutdown
```python
shutdown()
shutdown() -> None
```
Explicitly shutdown the executor if we own it.
@@ -32,7 +32,7 @@ writer.run(docs)
__init__(
document_store: DocumentStore,
policy: DuplicatePolicy = DuplicatePolicy.NONE,
)
) -> None
```
Create a DocumentWriter component.
@@ -58,7 +58,7 @@ __init__(
azure_ad_token_provider: AzureADTokenProvider | None = None,
http_client_kwargs: dict[str, Any] | None = None,
raise_on_failure: bool = False
)
) -> None
```
Creates an AzureOpenAIDocumentEmbedder component.
@@ -175,7 +175,7 @@ __init__(
default_headers: dict[str, str] | None = None,
azure_ad_token_provider: AzureADTokenProvider | None = None,
http_client_kwargs: dict[str, Any] | None = None
)
) -> None
```
Creates an AzureOpenAITextEmbedder component.
@@ -489,7 +489,7 @@ __init__(
suffix: str = "",
truncate: bool | None = True,
normalize: bool | None = False,
)
) -> None
```
Creates a HuggingFaceAPITextEmbedder component.
@@ -545,7 +545,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(text: str)
run(text: str) -> dict[str, Any]
```
Embeds a single string.
@@ -556,13 +556,13 @@ Embeds a single string.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `embedding`: The embedding of the input text.
#### run_async
```python
run_async(text: str)
run_async(text: str) -> dict[str, Any]
```
Embeds a single string asynchronously.
@@ -573,7 +573,7 @@ Embeds a single string asynchronously.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `embedding`: The embedding of the input text.
## image/sentence_transformers_doc_image_embedder
@@ -774,7 +774,7 @@ __init__(
http_client_kwargs: dict[str, Any] | None = None,
*,
raise_on_failure: bool = False
)
) -> None
```
Creates an OpenAIDocumentEmbedder component.
@@ -842,7 +842,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, Any]
```
Embeds a list of documents.
@@ -853,14 +853,14 @@ Embeds a list of documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of documents with embeddings.
- `meta`: Information about the usage of the model.
#### run_async
```python
run_async(documents: list[Document])
run_async(documents: list[Document]) -> dict[str, Any]
```
Embeds a list of documents asynchronously.
@@ -871,7 +871,7 @@ Embeds a list of documents asynchronously.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of documents with embeddings.
- `meta`: Information about the usage of the model.
@@ -913,7 +913,7 @@ __init__(
timeout: float | None = None,
max_retries: int | None = None,
http_client_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Creates an OpenAITextEmbedder component.
@@ -975,7 +975,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(text: str)
run(text: str) -> dict[str, Any]
```
Embeds a single string.
@@ -986,14 +986,14 @@ Embeds a single string.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `embedding`: The embedding of the input text.
- `meta`: Information about the usage of the model.
#### run_async
```python
run_async(text: str)
run_async(text: str) -> dict[str, Any]
```
Asynchronously embed a single string.
@@ -1007,7 +1007,7 @@ but can be used with `await` in async code.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `embedding`: The embedding of the input text.
- `meta`: Information about the usage of the model.
@@ -1064,7 +1064,7 @@ __init__(
encode_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
revision: str | None = None,
)
) -> None
```
Creates a SentenceTransformersDocumentEmbedder component.
@@ -1140,7 +1140,7 @@ Deserializes the component from a dictionary.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1148,7 +1148,7 @@ Initializes the component.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Embed a list of documents.
@@ -1159,7 +1159,7 @@ Embed a list of documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- `documents`: Documents with embeddings.
## sentence_transformers_sparse_document_embedder
@@ -1211,7 +1211,7 @@ __init__(
config_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
revision: str | None = None
)
) -> None
```
Creates a SentenceTransformersSparseDocumentEmbedder component.
@@ -1274,7 +1274,7 @@ Deserializes the component from a dictionary.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1282,7 +1282,7 @@ Initializes the component.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Embed a list of documents.
@@ -1293,7 +1293,7 @@ Embed a list of documents.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- `documents`: Documents with sparse embeddings under the `sparse_embedding` field.
## sentence_transformers_sparse_text_embedder
@@ -1337,7 +1337,7 @@ __init__(
config_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
revision: str | None = None
)
) -> None
```
Create a SentenceTransformersSparseTextEmbedder component.
@@ -1395,7 +1395,7 @@ Deserializes the component from a dictionary.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1403,7 +1403,7 @@ Initializes the component.
#### run
```python
run(text: str)
run(text: str) -> dict[str, Any]
```
Embed a single string.
@@ -1414,7 +1414,7 @@ Embed a single string.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `sparse_embedding`: The sparse embedding of the input text.
## sentence_transformers_text_embedder
@@ -1465,7 +1465,7 @@ __init__(
encode_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
revision: str | None = None,
)
) -> None
```
Create a SentenceTransformersTextEmbedder component.
@@ -1539,7 +1539,7 @@ Deserializes the component from a dictionary.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1547,7 +1547,7 @@ Initializes the component.
#### run
```python
run(text: str)
run(text: str) -> dict[str, Any]
```
Embed a single string.
@@ -1558,5 +1558,5 @@ Embed a single string.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `embedding`: The embedding of the input text.
@@ -19,7 +19,7 @@ __init__(
run_name: str,
inputs: dict[str, list[Any]],
results: dict[str, dict[str, Any]],
)
) -> None
```
Initialize a new evaluation run result.
@@ -129,7 +129,7 @@ __init__(
progress_bar: bool = True,
raise_on_failure: bool = True,
chat_generator: ChatGenerator | None = None,
)
) -> None
```
Creates an instance of ContextRelevanceEvaluator.
@@ -250,7 +250,7 @@ print(result["score"])
#### __init__
```python
__init__(document_comparison_field: str = 'content')
__init__(document_comparison_field: str = 'content') -> None
```
Create a DocumentMAPEvaluator component.
@@ -339,7 +339,7 @@ print(result["score"])
#### __init__
```python
__init__(document_comparison_field: str = 'content')
__init__(document_comparison_field: str = 'content') -> None
```
Create a DocumentMRREvaluator component.
@@ -445,7 +445,9 @@ The list items within `ground_truth_documents` and `retrieved_documents` can dif
#### validate_inputs
```python
validate_inputs(gt_docs: list[list[Document]], ret_docs: list[list[Document]])
validate_inputs(
gt_docs: list[list[Document]], ret_docs: list[list[Document]]
) -> None
```
Validate the input parameters.
@@ -547,7 +549,7 @@ print(result["score"])
__init__(
mode: str | RecallMode = RecallMode.SINGLE_HIT,
document_comparison_field: str = "content",
)
) -> None
```
Create a DocumentRecallEvaluator component.
@@ -644,7 +646,7 @@ __init__(
progress_bar: bool = True,
raise_on_failure: bool = True,
chat_generator: ChatGenerator | None = None,
)
) -> None
```
Creates an instance of FaithfulnessEvaluator.
@@ -774,7 +776,7 @@ __init__(
*,
raise_on_failure: bool = True,
chat_generator: ChatGenerator | None = None
)
) -> None
```
Creates an instance of LLMEvaluator.
@@ -802,7 +804,7 @@ If no LLM is specified using the `chat_generator` parameter, the component will
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the component by warming up the underlying chat generator.
@@ -814,7 +816,7 @@ validate_init_parameters(
inputs: list[tuple[str, type[list]]],
outputs: list[str],
examples: list[dict[str, Any]],
)
) -> None
```
Validate the init parameters.
@@ -87,7 +87,7 @@ __init__(
size: tuple[int, int] | None = None,
raise_on_failure: bool = False,
max_workers: int = 3
)
) -> None
```
Initialize the LLMDocumentContentExtractor component.
@@ -108,7 +108,7 @@ Initialize the LLMDocumentContentExtractor component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the ChatGenerator if it has a warm_up method.
@@ -292,7 +292,7 @@ __init__(
page_range: list[str | int] | None = None,
raise_on_failure: bool = False,
max_workers: int = 3,
)
) -> None
```
Initializes the LLMMetadataExtractor.
@@ -316,7 +316,7 @@ Initializes the LLMMetadataExtractor.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the LLM provider component.
@@ -352,7 +352,9 @@ Deserializes the component from a dictionary.
#### run
```python
run(documents: list[Document], page_range: list[str | int] | None = None)
run(
documents: list[Document], page_range: list[str | int] | None = None
) -> dict[str, Any]
```
Extract metadata from documents using a Large Language Model.
@@ -375,7 +377,7 @@ The original documents will be returned updated with the extracted metadata.
**Returns:**
- – A dictionary with the keys:
- <code>dict\[str, Any\]</code> – A dictionary with the keys:
- "documents": A list of documents that were successfully updated with the extracted metadata.
- "failed_documents": A list of documents that failed to extract metadata. These documents will have
"metadata_extraction_error" and "metadata_extraction_response" in their metadata. These documents can be
@@ -469,7 +471,7 @@ Create a Named Entity extractor component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initialize the component.
@@ -582,7 +584,7 @@ result = parser.run(text_or_messages=messages)
#### __init__
```python
__init__(regex_pattern: str)
__init__(regex_pattern: str) -> None
```
Creates an instance of the RegexTextExtractor component.
@@ -56,7 +56,7 @@ __init__(
http2: bool = False,
client_kwargs: dict | None = None,
request_headers: dict[str, str] | None = None,
)
) -> None
```
Initializes the component.
@@ -77,7 +77,7 @@ Initializes the component.
#### run
```python
run(urls: list[str])
run(urls: list[str]) -> dict[str, Any]
```
Fetches content from a list of URLs and returns a list of extracted content streams.
@@ -93,7 +93,7 @@ the key "content_type". The URL of the fetched content is stored under the key "
**Returns:**
- – `ByteStream` objects representing the extracted content.
- <code>dict\[str, Any\]</code> – `ByteStream` objects representing the extracted content.
**Raises:**
@@ -105,7 +105,7 @@ the key "content_type". The URL of the fetched content is stored under the key "
#### run_async
```python
run_async(urls: list[str])
run_async(urls: list[str]) -> dict[str, Any]
```
Asynchronously fetches content from a list of URLs and returns a list of extracted content streams.
@@ -118,4 +118,4 @@ This is the asynchronous version of the `run` method with the same parameters an
**Returns:**
- – `ByteStream` objects representing the extracted content.
- <code>dict\[str, Any\]</code> – `ByteStream` objects representing the extracted content.
@@ -69,7 +69,7 @@ __init__(
default_headers: dict[str, str] | None = None,
*,
azure_ad_token_provider: AzureADTokenProvider | None = None
)
) -> None
```
Initialize the Azure OpenAI Generator.
@@ -282,7 +282,7 @@ Initialize the Azure OpenAI Chat Generator component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the Azure OpenAI chat generator.
@@ -414,7 +414,7 @@ __init__(
tools: ToolsType | None = None,
tools_strict: bool = False,
http_client_kwargs: dict[str, Any] | None = None
)
) -> None
```
Initialize the AzureOpenAIResponsesChatGenerator component.
@@ -746,7 +746,7 @@ __init__(
stop_words: list[str] | None = None,
streaming_callback: StreamingCallbackT | None = None,
tools: ToolsType | None = None,
)
) -> None
```
Initialize the HuggingFaceAPIChatGenerator instance.
@@ -779,7 +779,7 @@ Initialize the HuggingFaceAPIChatGenerator instance.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the Hugging Face API chat generator.
@@ -1359,7 +1359,7 @@ __init__(
tools: ToolsType | None = None,
tools_strict: bool = False,
http_client_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Creates an instance of OpenAIChatGenerator. Unless specified otherwise in `model`, uses OpenAI's gpt-5-mini
@@ -1423,7 +1423,7 @@ in the OpenAI client.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the OpenAI chat generator.
@@ -1576,7 +1576,7 @@ __init__(
tools: ToolsType | list[dict] | None = None,
tools_strict: bool = False,
http_client_kwargs: dict[str, Any] | None = None
)
) -> None
```
Creates an instance of OpenAIResponsesChatGenerator. Uses OpenAI's gpt-5-mini by default.
@@ -1646,7 +1646,7 @@ in the OpenAI client.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the OpenAI responses chat generator.
@@ -1834,7 +1834,7 @@ __init__(
generation_kwargs: dict[str, Any] | None = None,
stop_words: list[str] | None = None,
streaming_callback: StreamingCallbackT | None = None,
)
) -> None
```
Initialize the HuggingFaceAPIGenerator instance.
@@ -1888,7 +1888,7 @@ run(
prompt: str,
streaming_callback: StreamingCallbackT | None = None,
generation_kwargs: dict[str, Any] | None = None,
)
) -> dict[str, Any]
```
Invoke the text generation inference for the given prompt and generation parameters.
@@ -1901,7 +1901,7 @@ Invoke the text generation inference for the given prompt and generation paramet
**Returns:**
- – A dictionary with the generated replies and metadata. Both are lists of length n.
- <code>dict\[str, Any\]</code> – A dictionary with the generated replies and metadata. Both are lists of length n.
- replies: A list of strings representing the generated replies.
## hugging_face_local
@@ -1941,7 +1941,7 @@ __init__(
huggingface_pipeline_kwargs: dict[str, Any] | None = None,
stop_words: list[str] | None = None,
streaming_callback: StreamingCallbackT | None = None,
)
) -> None
```
Creates an instance of a HuggingFaceLocalGenerator.
@@ -1980,7 +1980,7 @@ Creates an instance of a HuggingFaceLocalGenerator.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -2020,7 +2020,7 @@ run(
prompt: str,
streaming_callback: StreamingCallbackT | None = None,
generation_kwargs: dict[str, Any] | None = None,
)
) -> dict[str, Any]
```
Run the text generation model on the given prompt.
@@ -2033,7 +2033,7 @@ Run the text generation model on the given prompt.
**Returns:**
- – A dictionary containing the generated replies.
- <code>dict\[str, Any\]</code> – A dictionary containing the generated replies.
- replies: A list of strings representing the generated replies.
## openai
@@ -2082,7 +2082,7 @@ __init__(
timeout: float | None = None,
max_retries: int | None = None,
http_client_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Creates an instance of OpenAIGenerator. Unless specified otherwise in `model`, uses OpenAI's gpt-5-mini
@@ -2217,7 +2217,7 @@ __init__(
timeout: float | None = None,
max_retries: int | None = None,
http_client_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Creates an instance of DALLEImageGenerator. Unless specified otherwise in `model`, uses OpenAI's dall-e-3.
@@ -2259,7 +2259,7 @@ run(
) = None,
quality: Literal["standard", "hd"] | None = None,
response_format: Literal["url", "b64_json"] | None = None,
)
) -> dict[str, Any]
```
Invokes the image generation inference based on the provided prompt and generation parameters.
@@ -2273,7 +2273,7 @@ Invokes the image generation inference based on the provided prompt and generati
**Returns:**
- – A dictionary containing the generated list of images and the revised prompt.
- <code>dict\[str, Any\]</code> – A dictionary containing the generated list of images and the revised prompt.
Depending on the `response_format` parameter, the list of images can be URLs or base64 encoded JSON strings.
The revised prompt is the prompt that was used to generate the image, if there was any revision
to the prompt made by OpenAI.
@@ -124,6 +124,14 @@ Bases: <code>ConfirmationPolicy</code>
Ask only once per tool with specific parameters.
#### __init__
```python
__init__() -> None
```
Creates an instance of AskOncePolicy.
#### should_ask
```python
@@ -291,6 +299,14 @@ Bases: <code>ConfirmationUI</code>
Rich console interface for user interaction.
#### __init__
```python
__init__(console: Console | None = None) -> None
```
Creates an instance of RichConsoleUI.
#### get_user_confirmation
```python
@@ -62,7 +62,7 @@ __init__(
root_path: str | None = None,
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None
)
) -> None
```
Initialize the DocumentToImageContent component.
@@ -139,7 +139,7 @@ print(documents)
#### __init__
```python
__init__(*, store_full_path: bool = False)
__init__(*, store_full_path: bool = False) -> None
```
Initialize the ImageFileToDocument component.
@@ -211,7 +211,7 @@ __init__(
*,
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None
)
) -> None
```
Create the ImageFileToImageContent component.
@@ -292,7 +292,7 @@ __init__(
detail: Literal["auto", "high", "low"] | None = None,
size: tuple[int, int] | None = None,
page_range: list[str | int] | None = None
)
) -> None
```
Create the PDFToImageContent component.
@@ -73,7 +73,7 @@ __init__(
join_mode: str | JoinMode = JoinMode.CONCATENATE,
top_k: int | None = None,
sort_by_score: bool = False,
)
) -> None
```
Creates an AnswerJoiner component.
@@ -89,7 +89,9 @@ Creates an AnswerJoiner component.
#### run
```python
run(answers: Variadic[list[AnswerType]], top_k: int | None = None)
run(
answers: Variadic[list[AnswerType]], top_k: int | None = None
) -> dict[str, Any]
```
Joins multiple lists of Answers into a single list depending on the `join_mode` parameter.
@@ -101,7 +103,7 @@ Joins multiple lists of Answers into a single list depending on the `join_mode`
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `answers`: Merged list of Answers
#### to_dict
@@ -213,7 +215,7 @@ have more than one downstream component.
#### __init__
```python
__init__(type_: type)
__init__(type_: type) -> None
```
Creates a `BranchJoiner` component.
@@ -332,7 +334,7 @@ __init__(
weights: list[float] | None = None,
top_k: int | None = None,
sort_by_score: bool = True,
)
) -> None
```
Creates a DocumentJoiner component.
@@ -356,7 +358,9 @@ Creates a DocumentJoiner component.
#### run
```python
run(documents: Variadic[list[Document]], top_k: int | None = None)
run(
documents: Variadic[list[Document]], top_k: int | None = None
) -> dict[str, Any]
```
Joins multiple lists of Documents into a single list depending on the `join_mode` parameter.
@@ -368,7 +372,7 @@ Joins multiple lists of Documents into a single list depending on the `join_mode
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: Merged list of Documents
#### to_dict
@@ -457,7 +461,7 @@ print(ans["list_joiner"]["values"])
#### __init__
```python
__init__(list_type_: type | None = None)
__init__(list_type_: type | None = None) -> None
```
Creates a ListJoiner component.
@@ -182,7 +182,7 @@ __init__(
ascii_only: bool = False,
strip_whitespaces: bool = False,
replace_regexes: dict[str, str] | None = None,
)
) -> None
```
Initialize DocumentCleaner.
@@ -213,7 +213,7 @@ Initialize DocumentCleaner.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Cleans up the documents.
@@ -224,7 +224,7 @@ Cleans up the documents.
**Returns:**
- – A dictionary with the following key:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following key:
- `documents`: List of cleaned Documents.
**Raises:**
@@ -388,7 +388,7 @@ __init__(
extend_abbreviations: bool = True,
*,
skip_empty_documents: bool = True
)
) -> None
```
Initialize DocumentSplitter.
@@ -422,7 +422,7 @@ Initialize DocumentSplitter.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the DocumentSplitter by loading the sentence tokenizer.
@@ -430,7 +430,7 @@ Warm up the DocumentSplitter by loading the sentence tokenizer.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Split documents into smaller parts.
@@ -444,7 +444,7 @@ and an overlap of `split_overlap`.
**Returns:**
- – A dictionary with the following key:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following key:
- `documents`: List of documents with the split texts. Each document includes:
- A metadata field `source_id` to track the original document.
- A metadata field `page_number` to track the original page number.
@@ -676,7 +676,7 @@ __init__(
block_sizes: set[int],
split_overlap: int = 0,
split_by: Literal["word", "sentence", "page", "passage"] = "word",
)
) -> None
```
Initialize HierarchicalDocumentSplitter.
@@ -690,7 +690,7 @@ Initialize HierarchicalDocumentSplitter.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Builds a hierarchical document structure for each document in a list of documents.
@@ -701,7 +701,7 @@ Builds a hierarchical document structure for each document in a list of document
**Returns:**
- – List of HierarchicalDocument
- <code>dict\[str, list\[Document\]\]</code> – List of HierarchicalDocument
#### build_hierarchy_from_doc
@@ -775,7 +775,7 @@ __init__(
split_overlap: int = 0,
split_threshold: int = 0,
skip_empty_documents: bool = True
)
) -> None
```
Initialize the MarkdownHeaderSplitter.
@@ -798,7 +798,7 @@ Initialize the MarkdownHeaderSplitter.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the MarkdownHeaderSplitter.
@@ -879,7 +879,7 @@ __init__(
split_unit: Literal["word", "char", "token"] = "word",
separators: list[str] | None = None,
sentence_splitter_params: dict[str, Any] | None = None
)
) -> None
```
Initializes a RecursiveDocumentSplitter.
@@ -958,7 +958,7 @@ __init__(
convert_to_lowercase: bool = False,
remove_punctuation: bool = False,
remove_numbers: bool = False,
)
) -> None
```
Initializes the TextCleaner component.
@@ -123,7 +123,7 @@ The language of the original query is preserved in the expanded queries.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the LLM provider component.
@@ -243,7 +243,7 @@ __init__(
prompt: str = DEFAULT_PROMPT_TEMPLATE,
top_k: int = 10,
raise_on_failure: bool = False
)
) -> None
```
Initialize the LLMRanker component.
@@ -261,7 +261,7 @@ Initialize the LLMRanker component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the underlying chat generator.
@@ -350,7 +350,9 @@ for doc in result["documents"]:
#### __init__
```python
__init__(word_count_threshold: int | None = None, top_k: int | None = None)
__init__(
word_count_threshold: int | None = None, top_k: int | None = None
) -> None
```
Initialize the LostInTheMiddleRanker.
@@ -434,7 +436,7 @@ __init__(
sort_order: Literal["ascending", "descending"] = "descending",
missing_meta: Literal["drop", "top", "bottom"] = "bottom",
meta_value_type: Literal["float", "int", "date"] | None = None,
)
) -> None
```
Creates an instance of MetaFieldRanker.
@@ -483,7 +485,7 @@ run(
sort_order: Literal["ascending", "descending"] | None = None,
missing_meta: Literal["drop", "top", "bottom"] | None = None,
meta_value_type: Literal["float", "int", "date"] | None = None,
)
) -> dict[str, Any]
```
Ranks a list of Documents based on the selected meta field by:
@@ -533,7 +535,7 @@ if a score is present.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: List of Documents sorted by the specified meta field.
**Raises:**
@@ -599,7 +601,7 @@ __init__(
group_by: str,
subgroup_by: str | None = None,
sort_docs_by: str | None = None,
)
) -> None
```
Creates an instance of MetaFieldGroupingRanker.
@@ -616,7 +618,7 @@ Creates an instance of MetaFieldGroupingRanker.
#### run
```python
run(documents: list[Document]) -> dict[str, Any]
run(documents: list[Document]) -> dict[str, list[Document]]
```
Groups the provided list of documents based on the `group_by` parameter and optionally the `subgroup_by`.
@@ -632,7 +634,7 @@ The output is a list of documents reordered based on how they were grouped.
**Returns:**
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- <code>dict\[str, list\[Document\]\]</code> – A dictionary with the following keys:
- documents: The list of documents ordered by the `group_by` and `subgroup_by` metadata values.
## sentence_transformers_diversity
@@ -729,7 +731,7 @@ __init__(
tokenizer_kwargs: dict[str, Any] | None = None,
config_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
)
) -> None
```
Initialize a SentenceTransformersDiversityRanker.
@@ -770,7 +772,7 @@ Initialize a SentenceTransformersDiversityRanker.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -880,7 +882,7 @@ __init__(
config_kwargs: dict[str, Any] | None = None,
backend: Literal["torch", "onnx", "openvino"] = "torch",
batch_size: int = 16
)
) -> None
```
Creates an instance of SentenceTransformersSimilarityRanker.
@@ -1043,7 +1045,7 @@ __init__(
model_kwargs: dict[str, Any] | None = None,
tokenizer_kwargs: dict[str, Any] | None = None,
batch_size: int = 16,
)
) -> None
```
Creates an instance of TransformersSimilarityRanker.
@@ -1080,7 +1082,7 @@ Creates an instance of TransformersSimilarityRanker.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1123,7 +1125,7 @@ run(
scale_score: bool | None = None,
calibration_factor: float | None = None,
score_threshold: float | None = None,
)
) -> dict[str, Any]
```
Returns a list of documents ranked by their similarity to the given query.
@@ -1144,7 +1146,7 @@ if a score is present.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `documents`: A list of documents closest to the query, sorted from most similar to least similar.
**Raises:**
@@ -117,7 +117,7 @@ Deserializes the component from a dictionary.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -163,7 +163,7 @@ run(
answers_per_seq: int | None = None,
no_answer: bool | None = None,
overlap_threshold: float | None = None,
)
) -> dict[str, Any]
```
Locates and extracts answers from the given Documents using the given query.
@@ -190,4 +190,4 @@ Locates and extracts answers from the given Documents using the given query.
**Returns:**
- – List of answers sorted by (desc.) answer score.
- <code>dict\[str, Any\]</code> – List of answers sorted by (desc.) answer score.
@@ -64,7 +64,7 @@ print(retrieved_docs["documents"])
#### __init__
```python
__init__(document_store: DocumentStore, threshold: float = 0.5)
__init__(document_store: DocumentStore, threshold: float = 0.5) -> None
```
Initialize the AutoMergingRetriever.
@@ -105,7 +105,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(documents: list[Document])
run(documents: list[Document]) -> dict[str, list[Document]]
```
Run the AutoMergingRetriever.
@@ -119,12 +119,12 @@ continuing up the hierarchy until no more merges are possible.
**Returns:**
- – List of documents (could be a mix of different hierarchy levels)
- <code>dict\[str, list\[Document\]\]</code> – List of documents (could be a mix of different hierarchy levels)
#### run_async
```python
run_async(documents: list[Document])
run_async(documents: list[Document]) -> dict[str, list[Document]]
```
Asynchronously run the AutoMergingRetriever.
@@ -138,7 +138,7 @@ continuing up the hierarchy until no more merges are possible.
**Returns:**
- – List of documents (could be a mix of different hierarchy levels)
- <code>dict\[str, list\[Document\]\]</code> – List of documents (could be a mix of different hierarchy levels)
## filter_retriever
@@ -171,7 +171,9 @@ print(result["documents"])
#### __init__
```python
__init__(document_store: DocumentStore, filters: dict[str, Any] | None = None)
__init__(
document_store: DocumentStore, filters: dict[str, Any] | None = None
) -> None
```
Create the FilterRetriever component.
@@ -212,7 +214,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(filters: dict[str, Any] | None = None)
run(filters: dict[str, Any] | None = None) -> dict[str, Any]
```
Run the FilterRetriever on the given input data.
@@ -224,12 +226,12 @@ Run the FilterRetriever on the given input data.
**Returns:**
- – A list of retrieved documents.
- <code>dict\[str, Any\]</code> – A list of retrieved documents.
#### run_async
```python
run_async(filters: dict[str, Any] | None = None)
run_async(filters: dict[str, Any] | None = None) -> dict[str, Any]
```
Asynchronously run the FilterRetriever on the given input data.
@@ -241,7 +243,7 @@ Asynchronously run the FilterRetriever on the given input data.
**Returns:**
- – A list of retrieved documents.
- <code>dict\[str, Any\]</code> – A list of retrieved documents.
## in_memory/bm25_retriever
@@ -281,7 +283,7 @@ __init__(
top_k: int = 10,
scale_score: bool = False,
filter_policy: FilterPolicy = FilterPolicy.REPLACE,
)
) -> None
```
Create the InMemoryBM25Retriever component.
@@ -440,7 +442,7 @@ __init__(
scale_score: bool = False,
return_embedding: bool = False,
filter_policy: FilterPolicy = FilterPolicy.REPLACE,
)
) -> None
```
Create the InMemoryEmbeddingRetriever component.
@@ -890,7 +892,7 @@ __init__(
source_id_meta_field: str | list[str] = "source_id",
split_id_meta_field: str = "split_id",
raise_on_missing_meta_fields: bool = True
)
) -> None
```
Creates a new SentenceWindowRetriever component.
@@ -950,7 +952,9 @@ Deserializes the component from a dictionary.
#### run
```python
run(retrieved_documents: list[Document], window_size: int | None = None)
run(
retrieved_documents: list[Document], window_size: int | None = None
) -> dict[str, Any]
```
Based on the `source_id` and on the `doc.meta['split_id']` get surrounding documents from the document store.
@@ -966,7 +970,7 @@ document from the document store.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `context_windows`: A list of strings, where each string represents the concatenated text from the
context window of the corresponding document in `retrieved_documents`.
- `context_documents`: A list `Document` objects, containing the retrieved documents plus the context
@@ -976,7 +980,9 @@ document from the document store.
#### run_async
```python
run_async(retrieved_documents: list[Document], window_size: int | None = None)
run_async(
retrieved_documents: list[Document], window_size: int | None = None
) -> dict[str, Any]
```
Based on the `source_id` and on the `doc.meta['split_id']` get surrounding documents from the document store.
@@ -992,7 +998,7 @@ document from the document store.
**Returns:**
- – A dictionary with the following keys:
- <code>dict\[str, Any\]</code> – A dictionary with the following keys:
- `context_windows`: A list of strings, where each string represents the concatenated text from the
context window of the corresponding document in `retrieved_documents`.
- `context_documents`: A list `Document` objects, containing the retrieved documents plus the context
@@ -111,7 +111,7 @@ __init__(
unsafe: bool = False,
validate_output_type: bool = False,
optional_variables: list[str] | None = None,
)
) -> None
```
Initializes the `ConditionalRouter` with a list of routes detailing the conditions for routing.
@@ -210,7 +210,7 @@ Deserializes the component from a dictionary.
#### run
```python
run(**kwargs)
run(**kwargs: Any) -> dict[str, Any]
```
Executes the routing logic.
@@ -221,12 +221,12 @@ order they are listed. The method directs the flow of data to the output specifi
**Parameters:**
- **kwargs** – All variables used in the `condition` expressed in the routes. When the component is used in a
- **kwargs** (<code>Any</code>) – All variables used in the `condition` expressed in the routes. When the component is used in a
pipeline, these variables are passed from the previous component's output.
**Returns:**
- – A dictionary where the key is the `output_name` of the selected route and the value is the `output`
- <code>dict\[str, Any\]</code> – A dictionary where the key is the `output_name` of the selected route and the value is the `output`
of the selected route.
**Raises:**
@@ -439,7 +439,7 @@ __init__(
mime_types: list[str],
additional_mimetypes: dict[str, str] | None = None,
raise_on_failure: bool = False,
)
) -> None
```
Initialize the FileTypeRouter component.
@@ -564,7 +564,7 @@ __init__(
output_names: list[str],
output_patterns: list[str],
system_prompt: str | None = None,
)
) -> None
```
Initialize the LLMMessagesRouter component.
@@ -587,7 +587,7 @@ Initialize the LLMMessagesRouter component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the underlying LLM.
@@ -743,7 +743,9 @@ Initializes the MetadataRouter component.
#### run
```python
run(documents: list[Document] | list[ByteStream])
run(
documents: list[Document] | list[ByteStream],
) -> dict[str, list[Document] | list[ByteStream]]
```
Routes documents or byte streams to different connections based on their metadata fields.
@@ -756,7 +758,7 @@ If a document or byte stream does not match any of the rules, it's routed to a c
**Returns:**
- – A dictionary where the keys are the names of the output connections (including `"unmatched"`)
- <code>dict\[str, list\[Document\] | list\[ByteStream\]\]</code> – A dictionary where the keys are the names of the output connections (including `"unmatched"`)
and the values are lists of `Document` or `ByteStream` objects that matched the corresponding rules.
#### to_dict
@@ -824,7 +826,7 @@ assert result["text_language_router"]["unmatched"] == "ένα ελληνικό
#### __init__
```python
__init__(languages: list[str] | None = None)
__init__(languages: list[str] | None = None) -> None
```
Initialize the TextLanguageRouter component.
@@ -920,7 +922,7 @@ __init__(
["HF_API_TOKEN", "HF_TOKEN"], strict=False
),
huggingface_pipeline_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Initializes the TransformersTextRouter component.
@@ -942,7 +944,7 @@ Initializes the TransformersTextRouter component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -1078,7 +1080,7 @@ __init__(
["HF_API_TOKEN", "HF_TOKEN"], strict=False
),
huggingface_pipeline_kwargs: dict[str, Any] | None = None,
)
) -> None
```
Initializes the TransformersZeroShotTextRouter component.
@@ -1103,7 +1105,7 @@ Initializes the TransformersZeroShotTextRouter component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Initializes the component.
@@ -41,7 +41,7 @@ __init__(
top_p: float = 1.0,
score_field: str | None = None,
min_top_k: int | None = None,
)
) -> None
```
Creates an instance of TopPSampler.
@@ -58,7 +58,7 @@ Creates an instance of TopPSampler.
#### run
```python
run(documents: list[Document], top_p: float | None = None)
run(documents: list[Document], top_p: float | None = None) -> dict[str, Any]
```
Filters documents using top-p sampling based on their scores.
@@ -73,7 +73,7 @@ method returns the document with the highest score.
**Returns:**
- – A dictionary with the following key:
- <code>dict\[str, Any\]</code> – A dictionary with the following key:
- `documents`: List of Document objects that have been selected based on the top-p sampling.
**Raises:**
@@ -160,7 +160,7 @@ __init__(
*,
enable_streaming_callback_passthrough: bool = False,
max_workers: int = 4
)
) -> None
````
Initialize the ToolInvoker component.
@@ -191,7 +191,7 @@ Initialize the ToolInvoker component.
#### warm_up
```python
warm_up()
warm_up() -> None
```
Warm up the tool invoker.
@@ -156,7 +156,7 @@ Example:
#### warm_up
```python
warm_up()
warm_up() -> None
```
Prepare the ComponentTool for use.
@@ -685,7 +685,7 @@ __init__(
search_tool_name: str = "search_tools",
search_tool_description: str | None = None,
search_tool_parameters_description: dict[str, str] | None = None
)
) -> None
```
Initialize the SearchableToolset.
@@ -979,7 +979,7 @@ Toolset serves two main purposes:
class CalculatorToolset(Toolset):
'''A toolset for calculator operations.'''
def __init__(self):
def __init__(self) -> None:
tools = self._create_tools()
super().__init__(tools)
@@ -30,6 +30,8 @@ Returns if the given callable is usable inside a component's `run_async` method.
Bases: <code>Enum</code>
Type of secret: token (API key) or environment variable.
#### from_str
```python
@@ -372,7 +374,7 @@ A generic representation of a device.
#### __init__
```python
__init__(type: DeviceType, id: int | None = None)
__init__(type: DeviceType, id: int | None = None) -> None
```
Create a generic device.
@@ -862,7 +864,7 @@ A Jinja2 extension for formatting dates and times.
#### __init__
```python
__init__(environment: Environment)
__init__(environment: Environment) -> None
```
Initializes the JinjaTimeExtension object.
@@ -88,7 +88,7 @@ _name=None, _meta={'model': 'gpt-4-1106-preview', 'index': 0,
```python
__init__(
json_schema: dict[str, Any] | None = None, error_template: str | None = None
)
) -> None
```
Initialize the JsonSchemaValidator component.