Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions docs-website/reference/haystack-api/agents_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,19 @@ print(result["messages"][-1].text)
#### Agent.\_\_init\_\_

```python
def __init__(*,
chat_generator: ChatGenerator,
tools: ToolsType | None = None,
system_prompt: str | None = None,
exit_conditions: list[str] | None = None,
state_schema: dict[str, Any] | None = None,
max_agent_steps: int = 100,
streaming_callback: StreamingCallbackT | None = None,
raise_on_tool_invocation_failure: bool = False,
tool_invoker_kwargs: dict[str, Any] | None = None) -> None
def __init__(
*,
chat_generator: ChatGenerator,
tools: ToolsType | None = None,
system_prompt: str | None = None,
exit_conditions: list[str] | None = None,
state_schema: dict[str, Any] | None = None,
max_agent_steps: int = 100,
streaming_callback: StreamingCallbackT | None = None,
raise_on_tool_invocation_failure: bool = False,
tool_invoker_kwargs: dict[str, Any] | None = None,
confirmation_strategies: dict[str, ConfirmationStrategy] | None = None
) -> None
```

Initialize the agent component.
Expand All @@ -124,6 +127,7 @@ The same callback can be configured to emit tool results when a tool is called.
- `raise_on_tool_invocation_failure`: Should the agent raise an exception when a tool invocation fails?
If set to False, the exception will be turned into a chat message and passed to the LLM.
- `tool_invoker_kwargs`: Additional keyword arguments to pass to the ToolInvoker.
- `confirmation_strategies`: A dictionary mapping tool names to ConfirmationStrategy instances.

**Raises**:

Expand Down Expand Up @@ -187,6 +191,7 @@ def run(messages: list[ChatMessage],
system_prompt: str | None = None,
tools: ToolsType | list[str] | None = None,
snapshot_callback: SnapshotCallback | None = None,
confirmation_strategy_context: dict[str, Any] | None = None,
**kwargs: Any) -> dict[str, Any]
```

Expand All @@ -209,6 +214,10 @@ When passing tool names, tools are selected from the Agent's originally configur
- `snapshot_callback`: Optional callback function that is invoked when a pipeline snapshot is created.
The callback receives a `PipelineSnapshot` object and can return an optional string.
If provided, the callback is used instead of the default file-saving behavior.
- `confirmation_strategy_context`: Optional dictionary for passing request-scoped resources
to confirmation strategies. Useful in web/server environments to provide per-request
objects (e.g., WebSocket connections, async queues, Redis pub/sub clients) that strategies
can use for non-blocking user interaction.
- `kwargs`: Additional data to pass to the State schema used by the Agent.
The keys must match the schema defined in the Agent's `state_schema`.

Expand Down Expand Up @@ -237,6 +246,8 @@ async def run_async(messages: list[ChatMessage],
system_prompt: str | None = None,
tools: ToolsType | list[str] | None = None,
snapshot_callback: SnapshotCallback | None = None,
confirmation_strategy_context: dict[str, Any]
| None = None,
**kwargs: Any) -> dict[str, Any]
```

Expand Down Expand Up @@ -264,6 +275,10 @@ The callback receives a `PipelineSnapshot` object and can return an optional str
If provided, the callback is used instead of the default file-saving behavior.
- `kwargs`: Additional data to pass to the State schema used by the Agent.
The keys must match the schema defined in the Agent's `state_schema`.
- `confirmation_strategy_context`: Optional dictionary for passing request-scoped resources
to confirmation strategies. Useful in web/server environments to provide per-request
objects (e.g., WebSocket connections, async queues, Redis pub/sub clients) that strategies
can use for non-blocking user interaction.

**Raises**:

Expand Down
281 changes: 281 additions & 0 deletions docs-website/reference/haystack-api/data_classes_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,287 @@ Deserialize the object from a dictionary.

Deserialized object.

<a id="breakpoints"></a>

## Module breakpoints

<a id="breakpoints.Breakpoint"></a>

### Breakpoint

A dataclass to hold a breakpoint for a component.

**Arguments**:

- `component_name`: The name of the component where the breakpoint is set.
- `visit_count`: The number of times the component must be visited before the breakpoint is triggered.
- `snapshot_file_path`: Optional path to store a snapshot of the pipeline when the breakpoint is hit.
This is useful for debugging purposes, allowing you to inspect the state of the pipeline at the time of the
breakpoint and to resume execution from that point.

<a id="breakpoints.Breakpoint.to_dict"></a>

#### Breakpoint.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the Breakpoint to a dictionary representation.

**Returns**:

A dictionary containing the component name, visit count, and debug path.

<a id="breakpoints.Breakpoint.from_dict"></a>

#### Breakpoint.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "Breakpoint"
```

Populate the Breakpoint from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the component name, visit count, and debug path.

**Returns**:

An instance of Breakpoint.

<a id="breakpoints.ToolBreakpoint"></a>

### ToolBreakpoint

A dataclass representing a breakpoint specific to tools used within an Agent component.

Inherits from Breakpoint and adds the ability to target individual tools. If `tool_name` is None,
the breakpoint applies to all tools within the Agent component.

**Arguments**:

- `tool_name`: The name of the tool to target within the Agent component. If None, applies to all tools.

<a id="breakpoints.ToolBreakpoint.to_dict"></a>

#### ToolBreakpoint.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the Breakpoint to a dictionary representation.

**Returns**:

A dictionary containing the component name, visit count, and debug path.

<a id="breakpoints.ToolBreakpoint.from_dict"></a>

#### ToolBreakpoint.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "Breakpoint"
```

Populate the Breakpoint from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the component name, visit count, and debug path.

**Returns**:

An instance of Breakpoint.

<a id="breakpoints.AgentBreakpoint"></a>

### AgentBreakpoint

A dataclass representing a breakpoint tied to an Agent’s execution.

This allows for debugging either a specific component (e.g., the chat generator) or a tool used by the agent.
It enforces constraints on which component names are valid for each breakpoint type.

**Arguments**:

- `agent_name`: The name of the agent component in a pipeline where the breakpoint is set.
- `break_point`: An instance of Breakpoint or ToolBreakpoint indicating where to break execution.

**Raises**:

- `ValueError`: If the component_name is invalid for the given breakpoint type:
- Breakpoint must have component_name='chat_generator'.
- ToolBreakpoint must have component_name='tool_invoker'.

<a id="breakpoints.AgentBreakpoint.to_dict"></a>

#### AgentBreakpoint.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the AgentBreakpoint to a dictionary representation.

**Returns**:

A dictionary containing the agent name and the breakpoint details.

<a id="breakpoints.AgentBreakpoint.from_dict"></a>

#### AgentBreakpoint.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "AgentBreakpoint"
```

Populate the AgentBreakpoint from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the agent name and the breakpoint details.

**Returns**:

An instance of AgentBreakpoint.

<a id="breakpoints.AgentSnapshot"></a>

### AgentSnapshot

<a id="breakpoints.AgentSnapshot.to_dict"></a>

#### AgentSnapshot.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the AgentSnapshot to a dictionary representation.

**Returns**:

A dictionary containing the agent state, timestamp, and breakpoint.

<a id="breakpoints.AgentSnapshot.from_dict"></a>

#### AgentSnapshot.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "AgentSnapshot"
```

Populate the AgentSnapshot from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the agent state, timestamp, and breakpoint.

**Returns**:

An instance of AgentSnapshot.

<a id="breakpoints.PipelineState"></a>

### PipelineState

A dataclass to hold the state of the pipeline at a specific point in time.

**Arguments**:

- `component_visits`: A dictionary mapping component names to their visit counts.
- `inputs`: The inputs processed by the pipeline at the time of the snapshot.
- `pipeline_outputs`: Dictionary containing the final outputs of the pipeline up to the breakpoint.

<a id="breakpoints.PipelineState.to_dict"></a>

#### PipelineState.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the PipelineState to a dictionary representation.

**Returns**:

A dictionary containing the inputs, component visits,
and pipeline outputs.

<a id="breakpoints.PipelineState.from_dict"></a>

#### PipelineState.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "PipelineState"
```

Populate the PipelineState from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the inputs, component visits,
and pipeline outputs.

**Returns**:

An instance of PipelineState.

<a id="breakpoints.PipelineSnapshot"></a>

### PipelineSnapshot

A dataclass to hold a snapshot of the pipeline at a specific point in time.

**Arguments**:

- `original_input_data`: The original input data provided to the pipeline.
- `ordered_component_names`: A list of component names in the order they were visited.
- `pipeline_state`: The state of the pipeline at the time of the snapshot.
- `break_point`: The breakpoint that triggered the snapshot.
- `agent_snapshot`: Optional agent snapshot if the breakpoint is an agent breakpoint.
- `timestamp`: A timestamp indicating when the snapshot was taken.
- `include_outputs_from`: Set of component names whose outputs should be included in the pipeline results.

<a id="breakpoints.PipelineSnapshot.to_dict"></a>

#### PipelineSnapshot.to\_dict

```python
def to_dict() -> dict[str, Any]
```

Convert the PipelineSnapshot to a dictionary representation.

**Returns**:

A dictionary containing the pipeline state, timestamp, breakpoint, agent snapshot, original input data,
ordered component names, include_outputs_from, and pipeline outputs.

<a id="breakpoints.PipelineSnapshot.from_dict"></a>

#### PipelineSnapshot.from\_dict

```python
@classmethod
def from_dict(cls, data: dict) -> "PipelineSnapshot"
```

Populate the PipelineSnapshot from a dictionary representation.

**Arguments**:

- `data`: A dictionary containing the pipeline state, timestamp, breakpoint, agent snapshot, original input
data, ordered component names, include_outputs_from, and pipeline outputs.

<a id="byte_stream"></a>

## Module byte\_stream
Expand Down
Loading