Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.ai.summary

Module Contents

AISummary

class roboto.ai.summary.AISummary(/, **data)#View Source

Bases: pydantic.BaseModel

A wire-transmissible representation of an AI summary

Parameters

data Any

Attributes

AISummary.created

created datetime.datetime #

The time at which the summary was created.

AISummary.status

The status of the summary.

AISummary.summary_id

summary_id str #

The ID of the summary.

AISummary.text

text str #

The text of the summary.

AISummaryStatus

class roboto.ai.summary.AISummaryStatus#View Source

Bases: roboto.compat.StrEnum

Status of an AI summary.

Attributes

AISummaryStatus.Complete

Complete = 'complete' #

The summary has been generated.

AISummaryStatus.Failed

Failed = 'failed' #

The summary failed to generate.

AISummaryStatus.Pending

Pending = 'pending' #

The summary is being generated. Its text may be the empty string, or may be a partial result. If you continually poll for the summary while it is in the pending state, you will eventually get the complete summary.

PollingStreamingAISummary

class roboto.ai.summary.PollingStreamingAISummary(poll_fn, poll_on_init=True, initial_summary=None)#View Source

Bases: StreamingAISummary

An implementation of StreamingAISummary which polls for updates.

Parameters

poll_fn Callable[[], AISummary]
poll_on_init bool
initial_summary Optional[AISummary]

PollingStreamingAISummary.await_completion()

await_completion(timeout_s=None, poll_interval_s=2)#View Source

Wait for the summary to complete.

This will return instantly if the summary is already complete.

Parameters

timeout_s Optional[float]

Optional timeout, in seconds, to wait for the summary to complete.

poll_interval_s float

Polling interval, in seconds, to use when waiting for the summary.

Returns

The completed summary.

Raises

If the summary fails to generate.

TimeoutError

If the timeout is reached before the summary completes.

Properties

PollingStreamingAISummary.complete_text

complete_text str #

The complete text of the summary.

This method will block until the summary is complete.

Raises

If the summary fails to generate,

Return type

str

PollingStreamingAISummary.current

current AISummary | None #

The current state of the summary.

This may be None if no summary has been generated yet.

Return type: Optional[AISummary]

PollingStreamingAISummary.text_stream()

text_stream(timeout_s=None, poll_interval_s=2)#View Source

Stream the text of the summary as it is generated.

This will yield the entire summary instantly if the summary is already complete. If the summary is not complete, this will yield the text as it is generated.

Parameters

timeout_s Optional[float]

Optional timeout, in seconds, to wait for the summary to complete.

poll_interval_s float

Polling interval, in seconds, to use when waiting for the summary.

Yields

The text of the summary as it is generated.

Raises

If the summary fails to generate.

TimeoutError

If the timeout is reached before the summary completes.

Return type

Generator[str, None, None]

StreamingAISummary

class roboto.ai.summary.StreamingAISummary#View Source

Bases: Protocol

A streaming interface for an AI summary.

Roboto AI summaries are typically generated asynchronously, and can be viewed as either a point-in-time partially (or fully) complete snapshot, or as a stream of characters. This class provides a single interface for accessing the summary in both ways.

StreamingAISummary.await_completion()

await_completion(timeout_s=None, poll_interval_s=2)#View Source

Wait for the summary to complete.

This will return instantly if the summary is already complete.

Parameters

timeout_s Optional[float]

Optional timeout, in seconds, to wait for the summary to complete.

poll_interval_s float

Polling interval, in seconds, to use when waiting for the summary.

Returns

The completed summary.

Raises

If the summary fails to generate.

TimeoutError

If the timeout is reached before the summary completes.

Properties

StreamingAISummary.complete_text

complete_text str #

The complete text of the summary.

This method will block until the summary is complete.

Raises

If the summary fails to generate,

Return type

str

StreamingAISummary.current

current AISummary | None #

The current state of the summary.

This may be None if no summary has been generated yet.

Return type: Optional[AISummary]

StreamingAISummary.text_stream()

text_stream(timeout_s=None, poll_interval_s=2)#View Source

Stream the text of the summary as it is generated.

This will yield the entire summary instantly if the summary is already complete. If the summary is not complete, this will yield the text as it is generated.

Parameters

timeout_s Optional[float]

Optional timeout, in seconds, to wait for the summary to complete.

poll_interval_s float

Polling interval, in seconds, to use when waiting for the summary.

Yields

The text of the summary as it is generated.

Raises

If the summary fails to generate.

TimeoutError

If the timeout is reached before the summary completes.

Return type

Generator[str, None, None]

Was this page helpful?