roboto.ai.summary#
Module Contents#
- class roboto.ai.summary.AISummary(/, **data)#
Bases:
pydantic.BaseModel
A wire-transmissible representation of an AI summary
- Parameters:
data (Any)
- created: datetime.datetime#
The time at which the summary was created.
- status: AISummaryStatus#
The status of the summary.
- summary_id: str#
The ID of the summary.
- text: str#
The text of the summary.
- class roboto.ai.summary.AISummaryStatus#
Bases:
str
,enum.Enum
Status of an AI summary.
- Complete = 'complete'#
The summary has been generated.
- Failed = 'failed'#
The summary failed to generate.
- 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.
- class roboto.ai.summary.PollingStreamingAISummary(poll_fn, poll_on_init=True, initial_summary=None)#
Bases:
StreamingAISummary
An implementation of StreamingAISummary which polls for updates.
- Parameters:
- await_completion(timeout_s=None, poll_interval_s=2)#
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:
RobotoFailedToGenerateException – If the summary fails to generate.
TimeoutError – If the timeout is reached before the summary completes.
- Return type:
- property complete_text: str#
The complete text of the summary.
This method will block until the summary is complete.
- Raises:
RobotoFailedToGenerateException – If the summary fails to generate,
- Return type:
str
- property current: AISummary | None#
The current state of the summary.
This may be None if no summary has been generated yet.
- Return type:
Optional[AISummary]
- text_stream(timeout_s=None, poll_interval_s=2)#
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:
RobotoFailedToGenerateException – If the summary fails to generate.
TimeoutError – If the timeout is reached before the summary completes.
- Return type:
Generator[str, None, None]
- class roboto.ai.summary.StreamingAISummary#
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.
- await_completion(timeout_s=None, poll_interval_s=2)#
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:
RobotoFailedToGenerateException – If the summary fails to generate.
TimeoutError – If the timeout is reached before the summary completes.
- Return type:
- property complete_text: str#
The complete text of the summary.
This method will block until the summary is complete.
- Raises:
RobotoFailedToGenerateException – If the summary fails to generate,
- Return type:
str
- property current: AISummary | None#
The current state of the summary.
This may be None if no summary has been generated yet.
- Return type:
Optional[AISummary]
- text_stream(timeout_s=None, poll_interval_s=2)#
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:
RobotoFailedToGenerateException – If the summary fails to generate.
TimeoutError – If the timeout is reached before the summary completes.
- Return type:
Generator[str, None, None]