Skip to content

Commit cfa776f

Browse files
HaystackBotsjrl
andauthored
docs: sync Haystack API reference on Docusaurus (#11302)
Co-authored-by: sjrl <10526848+sjrl@users.noreply.github.com>
1 parent 9a196a8 commit cfa776f

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ __init__(
12211221
*,
12221222
chat_generator: ChatGenerator,
12231223
system_prompt: str | None = None,
1224-
user_prompt: str,
1224+
user_prompt: str | None = None,
12251225
required_variables: list[str] | Literal["*"] = "*",
12261226
streaming_callback: StreamingCallbackT | None = None
12271227
) -> None
@@ -1233,17 +1233,19 @@ Initialize the LLM component.
12331233

12341234
- **chat_generator** (<code>ChatGenerator</code>) – An instance of the chat generator that the LLM should use.
12351235
- **system_prompt** (<code>str | None</code>) – System prompt for the LLM.
1236-
- **user_prompt** (<code>str</code>) – User prompt for the LLM. Must contain at least one Jinja2 template variable
1237-
(e.g., `{{ variable_name }}`). This prompt is appended to the messages provided at runtime.
1236+
- **user_prompt** (<code>str | None</code>) – User prompt for the LLM. This prompt is appended to the messages provided at
1237+
runtime. If it contains Jinja2 template variables (e.g., `{{ variable_name }}`), they become
1238+
inputs to the component. If omitted or if there are no template variables, `messages` must be
1239+
provided at runtime instead.
12381240
- **required_variables** (<code>list\[str\] | Literal['\*']</code>) – Variables that must be provided as input to user_prompt.
12391241
If a variable listed as required is not provided, an exception is raised.
12401242
If set to `"*"`, all variables found in the prompt are required. Defaults to `"*"`.
1243+
Only relevant when `user_prompt` contains template variables.
12411244
- **streaming_callback** (<code>StreamingCallbackT | None</code>) – A callback that will be invoked when a response is streamed from the LLM.
12421245

12431246
**Raises:**
12441247

1245-
- <code>ValueError</code> – If user_prompt contains no template variables.
1246-
- <code>ValueError</code> – If required_variables is an empty list.
1248+
- <code>ValueError</code> – If user_prompt contains template variables but required_variables is an empty list.
12471249

12481250
#### to_dict
12491251

@@ -1277,9 +1279,8 @@ Deserialize the LLM from a dictionary.
12771279

12781280
```python
12791281
run(
1280-
messages: list[ChatMessage] | None = None,
1281-
streaming_callback: StreamingCallbackT | None = None,
12821282
*,
1283+
streaming_callback: StreamingCallbackT | None = None,
12831284
generation_kwargs: dict[str, Any] | None = None,
12841285
system_prompt: str | None = None,
12851286
user_prompt: str | None = None,
@@ -1291,7 +1292,9 @@ Process messages and generate a response from the language model.
12911292

12921293
**Parameters:**
12931294

1294-
- **messages** (<code>list\[ChatMessage\] | None</code>) – List of Haystack ChatMessage objects to process.
1295+
- **messages** – Optional list of ChatMessage objects to prepend to the conversation. Whether this is
1296+
required or optional depends on the `user_prompt` configuration: if `user_prompt` has no template
1297+
variables, `messages` must be provided. Passed via `**kwargs`.
12951298
- **streaming_callback** (<code>StreamingCallbackT | None</code>) – A callback that will be invoked when a response is streamed from the LLM.
12961299
- **generation_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional keyword arguments for the underlying chat generator. These parameters
12971300
will override the parameters passed during component initialization.
@@ -1311,9 +1314,8 @@ Process messages and generate a response from the language model.
13111314

13121315
```python
13131316
run_async(
1314-
messages: list[ChatMessage] | None = None,
1315-
streaming_callback: StreamingCallbackT | None = None,
13161317
*,
1318+
streaming_callback: StreamingCallbackT | None = None,
13171319
generation_kwargs: dict[str, Any] | None = None,
13181320
system_prompt: str | None = None,
13191321
user_prompt: str | None = None,
@@ -1325,7 +1327,9 @@ Asynchronously process messages and generate a response from the language model.
13251327

13261328
**Parameters:**
13271329

1328-
- **messages** (<code>list\[ChatMessage\] | None</code>) – List of Haystack ChatMessage objects to process.
1330+
- **messages** – Optional list of ChatMessage objects to prepend to the conversation. Whether this is
1331+
required or optional depends on the `user_prompt` configuration: if `user_prompt` has no template
1332+
variables, `messages` must be provided. Passed via `**kwargs`.
13291333
- **streaming_callback** (<code>StreamingCallbackT | None</code>) – An asynchronous callback that will be invoked when a response is streamed
13301334
from the LLM.
13311335
- **generation_kwargs** (<code>dict\[str, Any\] | None</code>) – Additional keyword arguments for the underlying chat generator. These parameters

0 commit comments

Comments
 (0)