---
sidebar:
  label: roboto.ai.summary
  order: 6
title: roboto.ai.summary
---
## Module Contents

### AISummary

```python
class roboto.ai.summary.AISummary(/, **data: Any)
```

`from roboto import AISummary`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L33-L52)

Bases: `pydantic.BaseModel`

Data record of an AI summary of a dataset or a session, as the Roboto API returns it.

An AI summary is a description of a dataset or a session that Roboto's AI writes, or that a user sets with [`set_summary()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.set_summary). A dataset or session has at most one, which each new generation or `set_summary` call replaces; starting a generation clears its text. `StreamingAISummary` holds this record as its `current` snapshot.

**Parameters**

- **data** (`Any`)

**Attributes**

- **AISummary.created** (`datetime.datetime`): Time the summary was last written: when its generation started, completed or failed, or when a user set it.
- **AISummary.status** (`AISummaryStatus`): Status of the summary's generation.
- **AISummary.summary_id** (`str`): Unique ID of the summary, beginning with `sm_`. It stays the same when the summary is regenerated or set.
- **AISummary.text** (`str`): Text of the summary, rendered as Markdown. Empty or partial while `status` is `Pending`.

### AISummaryStatus

```python
class roboto.ai.summary.AISummaryStatus
```

`from roboto.ai.summary import AISummaryStatus`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L20-L30)

Bases: `roboto.compat.StrEnum`

Status of an AI summary's generation: whether Roboto is still writing it, finished, or failed.

**Attributes**

- **AISummaryStatus.Complete** = `'complete'`: Roboto finished generating the summary, or a user set its text.
- **AISummaryStatus.Failed** = `'failed'`: Generation failed; the text is whatever Roboto wrote before the failure, which may be empty.
- **AISummaryStatus.Pending** = `'pending'`: Roboto is still generating the summary; its text may be empty or partial.

### PollingStreamingAISummary

```python
class roboto.ai.summary.PollingStreamingAISummary(
    poll_fn: Callable[[], AISummary],
    poll_on_init: bool = True,
    initial_summary: Optional[AISummary] = None,
)
```

`from roboto.ai.summary import PollingStreamingAISummary`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L125-L202)

Bases: [`StreamingAISummary`](/docs/reference/python-sdk/roboto/ai/summary#roboto.ai.summary.StreamingAISummary)

Streaming AI summary that fetches the summary from Roboto at a fixed interval until its generation finishes.

The SDK's own code uses it; to generate or fetch a summary, use [`generate_summary()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.generate_summary) or [`get_summary()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.get_summary) instead.

**Parameters**

- **poll_fn** (`Callable[[], AISummary]`): Function that fetches the summary's current state from Roboto. `text_stream` assumes each call's text begins with the previous call's text, and yields only the characters past it.
- **poll_on_init** (`bool`): Whether to fetch the summary when the object is built. If `False`, the first fetch happens in `await_completion` or `text_stream`.
- **initial_summary** (`Optional[AISummary]`): Snapshot to start from, which a fetch on build replaces. With neither a snapshot nor a fetch on build, `current` is `None` and `await_completion` raises [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException).

**Properties**

- **PollingStreamingAISummary.complete_text** (`str`): Full text of the summary, once Roboto finishes generating it.

  Reading it waits, with no time limit, until generation finishes, and raises [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException) if a fetch finds that generation failed. To wait with a time limit, call `await_completion`.

- **PollingStreamingAISummary.current** (`AISummary | None`): Latest snapshot of the summary, or `None` if none has been fetched yet.

  Reading it neither waits nor fetches; `await_completion` and `text_stream` update it as they fetch.

  Return type: `Optional[AISummary]`

#### PollingStreamingAISummary.await_completion()

```python
def await_completion(
    timeout_s: Optional[float] = None,
    poll_interval_s: float = 2,
) -> AISummary
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L162-L169)

Wait until Roboto finishes generating the summary, and return it.

Returns at once, without fetching, if the summary is already complete or failed; a summary that had already failed is returned, not raised.

**Parameters**

- **timeout_s** (`Optional[float]`): Maximum time to wait, in seconds. It is checked after each fetch, so the wait can run past it by about one poll interval. `None` waits with no limit.
- **poll_interval_s** (`float`): Time to wait between fetches of the summary, in seconds.

**Raises**

- [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException): A fetch finds that generation of the summary failed.
- `TimeoutError`: The summary is still not complete after `timeout_s` seconds.

**Returns**

- `AISummary`

#### PollingStreamingAISummary.text_stream()

```python
def text_stream(
    timeout_s: Optional[float] = None,
    poll_interval_s: float = 2,
) -> Generator[str, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L171-L202)

Yield the summary's text as Roboto generates it.

The first chunk is all the text fetched so far. Each later chunk is the text added since the previous fetch, and is empty when nothing was added. Each call starts again from the beginning of the text. If the summary is already complete or failed, the generator yields its whole text once, without fetching or raising.

**Parameters**

- **timeout_s** (`Optional[float]`): Maximum time to wait for generation to finish, in seconds. It is checked after each fetch, so the wait can run past it by about one poll interval. `None` waits with no limit.
- **poll_interval_s** (`float`): Time to wait between fetches of the summary, in seconds.

**Yields**

- Chunks of the summary's text, which together make up the full text.

**Raises**

- [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException): A fetch finds that generation of the summary failed. It surfaces during iteration, when that fetch returns.
- `TimeoutError`: The summary is still not complete after `timeout_s` seconds. It surfaces during iteration, when the first fetch to return after `timeout_s` seconds finds the summary still pending.

**Returns**

- `Generator[str, None, None]`

### StreamingAISummary

```python
class roboto.ai.summary.StreamingAISummary
```

`from roboto.ai.summary import StreamingAISummary`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L55-L122)

Bases: `Protocol`

Interface to an AI summary that Roboto may still be generating, read as snapshots or as streamed text.

[`generate_summary()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.generate_summary) and [`get_summary()`](/docs/reference/python-sdk/roboto/domain/datasets/dataset#roboto.domain.datasets.dataset.Dataset.get_summary) return one, as do the methods of the same names on [`Session`](/docs/reference/python-sdk/roboto/experimental/sessions/session#roboto.experimental.sessions.session.Session). `current` returns the latest snapshot without waiting; `complete_text`, `await_completion` and `text_stream` fetch the summary from Roboto until its generation finishes.

**Properties**

- **StreamingAISummary.complete_text** (`str`): Full text of the summary, once Roboto finishes generating it.

  Reading it waits, with no time limit, until generation finishes, and raises [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException) if a fetch finds that generation failed. To wait with a time limit, call `await_completion`.

- **StreamingAISummary.current** (`AISummary | None`): Latest snapshot of the summary, or `None` if none has been fetched yet.

  Reading it neither waits nor fetches; `await_completion` and `text_stream` update it as they fetch.

  Return type: `Optional[AISummary]`

#### StreamingAISummary.await_completion()

```python
def await_completion(
    timeout_s: Optional[float] = None,
    poll_interval_s: float = 2,
) -> AISummary
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L82-L97)

Wait until Roboto finishes generating the summary, and return it.

Returns at once, without fetching, if the summary is already complete or failed; a summary that had already failed is returned, not raised.

**Parameters**

- **timeout_s** (`Optional[float]`): Maximum time to wait, in seconds. It is checked after each fetch, so the wait can run past it by about one poll interval. `None` waits with no limit.
- **poll_interval_s** (`float`): Time to wait between fetches of the summary, in seconds.

**Raises**

- [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException): A fetch finds that generation of the summary failed.
- `TimeoutError`: The summary is still not complete after `timeout_s` seconds.

**Returns**

- `AISummary`

#### StreamingAISummary.text_stream()

```python
def text_stream(
    timeout_s: Optional[float] = None,
    poll_interval_s: float = 2,
) -> Generator[str, None, None]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/ai/summary.py#L99-L122)

Yield the summary's text as Roboto generates it.

The first chunk is all the text fetched so far. Each later chunk is the text added since the previous fetch, and is empty when nothing was added. Each call starts again from the beginning of the text. If the summary is already complete or failed, the generator yields its whole text once, without fetching or raising.

**Parameters**

- **timeout_s** (`Optional[float]`): Maximum time to wait for generation to finish, in seconds. It is checked after each fetch, so the wait can run past it by about one poll interval. `None` waits with no limit.
- **poll_interval_s** (`float`): Time to wait between fetches of the summary, in seconds.

**Yields**

- Chunks of the summary's text, which together make up the full text.

**Raises**

- [`RobotoFailedToGenerateException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoFailedToGenerateException): A fetch finds that generation of the summary failed. It surfaces during iteration, when that fetch returns.
- `TimeoutError`: The summary is still not complete after `timeout_s` seconds. It surfaces during iteration, when the first fetch to return after `timeout_s` seconds finds the summary still pending.

**Returns**

- `Generator[str, None, None]`
