Skip to content

Commit 1de9441

Browse files
Sync Haystack API reference on Docusaurus (#9898)
Co-authored-by: vblagoje <[email protected]>
1 parent 8098e9c commit 1de9441

File tree

5 files changed

+529
-539
lines changed

5 files changed

+529
-539
lines changed

docs-website/reference/haystack-api/agents_api.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ assert "messages" in result # Contains conversation history
5151
```python
5252
def __init__(*,
5353
chat_generator: ChatGenerator,
54-
tools: Optional[Union[list[Tool], Toolset]] = None,
54+
tools: Optional[ToolsType] = None,
5555
system_prompt: Optional[str] = None,
5656
exit_conditions: Optional[list[str]] = None,
5757
state_schema: Optional[dict[str, Any]] = None,
@@ -66,7 +66,7 @@ Initialize the agent component.
6666
**Arguments**:
6767

6868
- `chat_generator`: An instance of the chat generator that your agent should use. It must support tools.
69-
- `tools`: List of Tool objects or a Toolset that the agent can use.
69+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset that the agent can use.
7070
- `system_prompt`: System prompt for the agent.
7171
- `exit_conditions`: List of conditions that will cause the agent to return.
7272
Can include "text" if the agent should return when it generates a message without tool calls,
@@ -139,7 +139,7 @@ def run(messages: list[ChatMessage],
139139
break_point: Optional[AgentBreakpoint] = None,
140140
snapshot: Optional[AgentSnapshot] = None,
141141
system_prompt: Optional[str] = None,
142-
tools: Optional[Union[list[Tool], Toolset, list[str]]] = None,
142+
tools: Optional[Union[ToolsType, list[str]]] = None,
143143
**kwargs: Any) -> dict[str, Any]
144144
```
145145

@@ -183,8 +183,7 @@ async def run_async(messages: list[ChatMessage],
183183
break_point: Optional[AgentBreakpoint] = None,
184184
snapshot: Optional[AgentSnapshot] = None,
185185
system_prompt: Optional[str] = None,
186-
tools: Optional[Union[list[Tool], Toolset,
187-
list[str]]] = None,
186+
tools: Optional[Union[ToolsType, list[str]]] = None,
188187
**kwargs: Any) -> dict[str, Any]
189188
```
190189

docs-website/reference/haystack-api/extractors_api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Creates an instance of the RegexTextExtractor component.
623623

624624
- `regex_pattern`: The regular expression pattern used to extract text.
625625
The pattern should include a capture group to extract the desired text.
626-
Example: '<issue url="(.+)">' captures 'github.com/hahahaha' from '<issue url="github.com/hahahaha">'.
626+
Example: `'<issue url="(.+)">'` captures `'github.com/hahahaha'` from `'<issue url="github.com/hahahaha">'`.
627627

628628
<a id="regex_text_extractor.RegexTextExtractor.run"></a>
629629

@@ -646,6 +646,6 @@ Extracts text from input using the configured regex pattern.
646646

647647
**Returns**:
648648

649-
- If match found: {"captured_text": "matched text"}
650-
- If no match and return_empty_on_no_match=True: {}
649+
- If match found: `{"captured_text": "matched text"}`
650+
- If no match and `return_empty_on_no_match=True`: `{}`
651651

docs-website/reference/haystack-api/generators_api.md

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def __init__(azure_endpoint: Optional[str] = None,
835835
max_retries: Optional[int] = None,
836836
generation_kwargs: Optional[dict[str, Any]] = None,
837837
default_headers: Optional[dict[str, str]] = None,
838-
tools: Optional[Union[list[Tool], Toolset]] = None,
838+
tools: Optional[ToolsType] = None,
839839
tools_strict: bool = False,
840840
*,
841841
azure_ad_token_provider: Optional[Union[
@@ -891,8 +891,7 @@ Some of the supported parameters:
891891
- For structured outputs with streaming,
892892
the `response_format` must be a JSON schema and not a Pydantic model.
893893
- `default_headers`: Default headers to use for the AzureOpenAI client.
894-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a
895-
list of `Tool` objects or a `Toolset` instance.
894+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
896895
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
897896
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
898897
- `azure_ad_token_provider`: A function that returns an Azure Active Directory token, will be invoked on
@@ -943,7 +942,7 @@ def run(messages: list[ChatMessage],
943942
streaming_callback: Optional[StreamingCallbackT] = None,
944943
generation_kwargs: Optional[dict[str, Any]] = None,
945944
*,
946-
tools: Optional[Union[list[Tool], Toolset]] = None,
945+
tools: Optional[ToolsType] = None,
947946
tools_strict: Optional[bool] = None)
948947
```
949948

@@ -956,9 +955,8 @@ Invokes chat completion based on the provided messages and generation parameters
956955
- `generation_kwargs`: Additional keyword arguments for text generation. These parameters will
957956
override the parameters passed during component initialization.
958957
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
959-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
960-
`tools` parameter set during component initialization. This parameter can accept either a list of
961-
`Tool` objects or a `Toolset` instance.
958+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
959+
If set, it will override the `tools` parameter provided during initialization.
962960
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
963961
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
964962
If set, it will override the `tools_strict` parameter set during component initialization.
@@ -978,7 +976,7 @@ async def run_async(messages: list[ChatMessage],
978976
streaming_callback: Optional[StreamingCallbackT] = None,
979977
generation_kwargs: Optional[dict[str, Any]] = None,
980978
*,
981-
tools: Optional[Union[list[Tool], Toolset]] = None,
979+
tools: Optional[ToolsType] = None,
982980
tools_strict: Optional[bool] = None)
983981
```
984982

@@ -995,9 +993,8 @@ Must be a coroutine.
995993
- `generation_kwargs`: Additional keyword arguments for text generation. These parameters will
996994
override the parameters passed during component initialization.
997995
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
998-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
999-
`tools` parameter set during component initialization. This parameter can accept either a list of
1000-
`Tool` objects or a `Toolset` instance.
996+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
997+
If set, it will override the `tools` parameter provided during initialization.
1001998
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
1002999
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
10031000
If set, it will override the `tools_strict` parameter set during component initialization.
@@ -1085,7 +1082,7 @@ def __init__(model: str = "HuggingFaceH4/zephyr-7b-beta",
10851082
huggingface_pipeline_kwargs: Optional[dict[str, Any]] = None,
10861083
stop_words: Optional[list[str]] = None,
10871084
streaming_callback: Optional[StreamingCallbackT] = None,
1088-
tools: Optional[Union[list[Tool], Toolset]] = None,
1085+
tools: Optional[ToolsType] = None,
10891086
tool_parsing_function: Optional[Callable[
10901087
[str], Optional[list[ToolCall]]]] = None,
10911088
async_executor: Optional[ThreadPoolExecutor] = None) -> None
@@ -1129,8 +1126,7 @@ If you provide this parameter, don't specify the `stopping_criteria` in `generat
11291126
For some chat models, the output includes both the new text and the original prompt.
11301127
In these cases, make sure your prompt has no stop words.
11311128
- `streaming_callback`: An optional callable for handling streaming responses.
1132-
- `tools`: A list of tools or a Toolset for which the model can prepare calls.
1133-
This parameter can accept either a list of `Tool` objects or a `Toolset` instance.
1129+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
11341130
- `tool_parsing_function`: A callable that takes a string and returns a list of ToolCall objects or None.
11351131
If None, the default_tool_parser will be used which extracts tool calls using a predefined pattern.
11361132
- `async_executor`: Optional ThreadPoolExecutor to use for async calls. If not provided, a single-threaded executor will be
@@ -1205,12 +1201,10 @@ The deserialized component.
12051201

12061202
```python
12071203
@component.output_types(replies=list[ChatMessage])
1208-
def run(
1209-
messages: list[ChatMessage],
1210-
generation_kwargs: Optional[dict[str, Any]] = None,
1211-
streaming_callback: Optional[StreamingCallbackT] = None,
1212-
tools: Optional[Union[list[Tool], Toolset]] = None
1213-
) -> dict[str, list[ChatMessage]]
1204+
def run(messages: list[ChatMessage],
1205+
generation_kwargs: Optional[dict[str, Any]] = None,
1206+
streaming_callback: Optional[StreamingCallbackT] = None,
1207+
tools: Optional[ToolsType] = None) -> dict[str, list[ChatMessage]]
12141208
```
12151209

12161210
Invoke text generation inference based on the provided messages and generation parameters.
@@ -1220,9 +1214,8 @@ Invoke text generation inference based on the provided messages and generation p
12201214
- `messages`: A list of ChatMessage objects representing the input messages.
12211215
- `generation_kwargs`: Additional keyword arguments for text generation.
12221216
- `streaming_callback`: An optional callable for handling streaming responses.
1223-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override
1224-
the `tools` parameter provided during initialization. This parameter can accept either a list
1225-
of `Tool` objects or a `Toolset` instance.
1217+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
1218+
If set, it will override the `tools` parameter provided during initialization.
12261219

12271220
**Returns**:
12281221

@@ -1265,11 +1258,10 @@ A ChatMessage instance.
12651258
```python
12661259
@component.output_types(replies=list[ChatMessage])
12671260
async def run_async(
1268-
messages: list[ChatMessage],
1269-
generation_kwargs: Optional[dict[str, Any]] = None,
1270-
streaming_callback: Optional[StreamingCallbackT] = None,
1271-
tools: Optional[Union[list[Tool], Toolset]] = None
1272-
) -> dict[str, list[ChatMessage]]
1261+
messages: list[ChatMessage],
1262+
generation_kwargs: Optional[dict[str, Any]] = None,
1263+
streaming_callback: Optional[StreamingCallbackT] = None,
1264+
tools: Optional[ToolsType] = None) -> dict[str, list[ChatMessage]]
12731265
```
12741266

12751267
Asynchronously invokes text generation inference based on the provided messages and generation parameters.
@@ -1282,8 +1274,8 @@ and return values but can be used with `await` in an async code.
12821274
- `messages`: A list of ChatMessage objects representing the input messages.
12831275
- `generation_kwargs`: Additional keyword arguments for text generation.
12841276
- `streaming_callback`: An optional callable for handling streaming responses.
1285-
- `tools`: A list of tools or a Toolset for which the model can prepare calls.
1286-
This parameter can accept either a list of `Tool` objects or a `Toolset` instance.
1277+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
1278+
If set, it will override the `tools` parameter provided during initialization.
12871279

12881280
**Returns**:
12891281

@@ -1404,7 +1396,7 @@ def __init__(api_type: Union[HFGenerationAPIType, str],
14041396
generation_kwargs: Optional[dict[str, Any]] = None,
14051397
stop_words: Optional[list[str]] = None,
14061398
streaming_callback: Optional[StreamingCallbackT] = None,
1407-
tools: Optional[Union[list[Tool], Toolset]] = None)
1399+
tools: Optional[ToolsType] = None)
14081400
```
14091401

14101402
Initialize the HuggingFaceAPIChatGenerator instance.
@@ -1429,10 +1421,10 @@ Some examples: `max_tokens`, `temperature`, `top_p`.
14291421
For details, see [Hugging Face chat_completion documentation](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.chat_completion).
14301422
- `stop_words`: An optional list of strings representing the stop words.
14311423
- `streaming_callback`: An optional callable for handling streaming responses.
1432-
- `tools`: A list of tools or a Toolset for which the model can prepare calls.
1424+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
14331425
The chosen model should support tool/function calling, according to the model card.
14341426
Support for tools in the Hugging Face API and TGI is not yet fully refined and you may experience
1435-
unexpected behavior. This parameter can accept either a list of `Tool` objects or a `Toolset` instance.
1427+
unexpected behavior.
14361428

14371429
<a id="chat/hugging_face_api.HuggingFaceAPIChatGenerator.to_dict"></a>
14381430

@@ -1467,7 +1459,7 @@ Deserialize this component from a dictionary.
14671459
@component.output_types(replies=list[ChatMessage])
14681460
def run(messages: list[ChatMessage],
14691461
generation_kwargs: Optional[dict[str, Any]] = None,
1470-
tools: Optional[Union[list[Tool], Toolset]] = None,
1462+
tools: Optional[ToolsType] = None,
14711463
streaming_callback: Optional[StreamingCallbackT] = None)
14721464
```
14731465

@@ -1496,7 +1488,7 @@ A dictionary with the following keys:
14961488
@component.output_types(replies=list[ChatMessage])
14971489
async def run_async(messages: list[ChatMessage],
14981490
generation_kwargs: Optional[dict[str, Any]] = None,
1499-
tools: Optional[Union[list[Tool], Toolset]] = None,
1491+
tools: Optional[ToolsType] = None,
15001492
streaming_callback: Optional[StreamingCallbackT] = None)
15011493
```
15021494

@@ -1581,7 +1573,7 @@ def __init__(api_key: Secret = Secret.from_env_var("OPENAI_API_KEY"),
15811573
generation_kwargs: Optional[dict[str, Any]] = None,
15821574
timeout: Optional[float] = None,
15831575
max_retries: Optional[int] = None,
1584-
tools: Optional[Union[list[Tool], Toolset]] = None,
1576+
tools: Optional[ToolsType] = None,
15851577
tools_strict: bool = False,
15861578
http_client_kwargs: Optional[dict[str, Any]] = None)
15871579
```
@@ -1638,8 +1630,7 @@ Some of the supported parameters:
16381630
`OPENAI_TIMEOUT` environment variable, or 30 seconds.
16391631
- `max_retries`: Maximum number of retries to contact OpenAI after an internal error.
16401632
If not set, it defaults to either the `OPENAI_MAX_RETRIES` environment variable, or set to 5.
1641-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. This parameter can accept either a
1642-
list of `Tool` objects or a `Toolset` instance.
1633+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
16431634
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
16441635
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
16451636
- `http_client_kwargs`: A dictionary of keyword arguments to configure a custom `httpx.Client`or `httpx.AsyncClient`.
@@ -1688,7 +1679,7 @@ def run(messages: list[ChatMessage],
16881679
streaming_callback: Optional[StreamingCallbackT] = None,
16891680
generation_kwargs: Optional[dict[str, Any]] = None,
16901681
*,
1691-
tools: Optional[Union[list[Tool], Toolset]] = None,
1682+
tools: Optional[ToolsType] = None,
16921683
tools_strict: Optional[bool] = None)
16931684
```
16941685

@@ -1701,9 +1692,8 @@ Invokes chat completion based on the provided messages and generation parameters
17011692
- `generation_kwargs`: Additional keyword arguments for text generation. These parameters will
17021693
override the parameters passed during component initialization.
17031694
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
1704-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
1705-
`tools` parameter set during component initialization. This parameter can accept either a list of
1706-
`Tool` objects or a `Toolset` instance.
1695+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
1696+
If set, it will override the `tools` parameter provided during initialization.
17071697
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
17081698
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
17091699
If set, it will override the `tools_strict` parameter set during component initialization.
@@ -1723,7 +1713,7 @@ async def run_async(messages: list[ChatMessage],
17231713
streaming_callback: Optional[StreamingCallbackT] = None,
17241714
generation_kwargs: Optional[dict[str, Any]] = None,
17251715
*,
1726-
tools: Optional[Union[list[Tool], Toolset]] = None,
1716+
tools: Optional[ToolsType] = None,
17271717
tools_strict: Optional[bool] = None)
17281718
```
17291719

@@ -1740,9 +1730,8 @@ Must be a coroutine.
17401730
- `generation_kwargs`: Additional keyword arguments for text generation. These parameters will
17411731
override the parameters passed during component initialization.
17421732
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
1743-
- `tools`: A list of tools or a Toolset for which the model can prepare calls. If set, it will override the
1744-
`tools` parameter set during component initialization. This parameter can accept either a list of
1745-
`Tool` objects or a `Toolset` instance.
1733+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
1734+
If set, it will override the `tools` parameter provided during initialization.
17461735
- `tools_strict`: Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
17471736
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
17481737
If set, it will override the `tools_strict` parameter set during component initialization.
@@ -1831,7 +1820,7 @@ Rebuild the component from a serialized representation, restoring nested chat ge
18311820
def run(
18321821
messages: list[ChatMessage],
18331822
generation_kwargs: Union[dict[str, Any], None] = None,
1834-
tools: Union[list[Tool], Toolset, None] = None,
1823+
tools: Optional[ToolsType] = None,
18351824
streaming_callback: Union[StreamingCallbackT,
18361825
None] = None) -> dict[str, Any]
18371826
```
@@ -1842,7 +1831,7 @@ Execute chat generators sequentially until one succeeds.
18421831

18431832
- `messages`: The conversation history as a list of ChatMessage instances.
18441833
- `generation_kwargs`: Optional parameters for the chat generator (e.g., temperature, max_tokens).
1845-
- `tools`: Optional Tool instances or Toolset for function calling capabilities.
1834+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for function calling capabilities.
18461835
- `streaming_callback`: Optional callable for handling streaming responses.
18471836

18481837
**Raises**:
@@ -1865,7 +1854,7 @@ A dictionary with:
18651854
async def run_async(
18661855
messages: list[ChatMessage],
18671856
generation_kwargs: Union[dict[str, Any], None] = None,
1868-
tools: Union[list[Tool], Toolset, None] = None,
1857+
tools: Optional[ToolsType] = None,
18691858
streaming_callback: Union[StreamingCallbackT,
18701859
None] = None) -> dict[str, Any]
18711860
```
@@ -1876,7 +1865,7 @@ Asynchronously execute chat generators sequentially until one succeeds.
18761865

18771866
- `messages`: The conversation history as a list of ChatMessage instances.
18781867
- `generation_kwargs`: Optional parameters for the chat generator (e.g., temperature, max_tokens).
1879-
- `tools`: Optional Tool instances or Toolset for function calling capabilities.
1868+
- `tools`: A list of Tool and/or Toolset objects, or a single Toolset for function calling capabilities.
18801869
- `streaming_callback`: Optional callable for handling streaming responses.
18811870

18821871
**Raises**:

0 commit comments

Comments
 (0)