Runs the agent in live mode (experimental feature). The `run_live` method yields a stream of `Event` objects, but not all yielded events are saved to the session. Here's a breakdown: **Events Yielded to Callers:** * **Live Model Audio Events with Inline Data:** Events containing
(
self,
*,
user_id: Optional[str] = None,
session_id: Optional[str] = None,
live_request_queue: LiveRequestQueue,
run_config: Optional[RunConfig] = None,
session: Optional[Session] = None,
)
| 1487 | ) |
| 1488 | |
| 1489 | async def run_live( |
| 1490 | self, |
| 1491 | *, |
| 1492 | user_id: Optional[str] = None, |
| 1493 | session_id: Optional[str] = None, |
| 1494 | live_request_queue: LiveRequestQueue, |
| 1495 | run_config: Optional[RunConfig] = None, |
| 1496 | session: Optional[Session] = None, |
| 1497 | ) -> AsyncGenerator[Event, None]: |
| 1498 | """Runs the agent in live mode (experimental feature). |
| 1499 | |
| 1500 | The `run_live` method yields a stream of `Event` objects, but not all |
| 1501 | yielded events are saved to the session. Here's a breakdown: |
| 1502 | |
| 1503 | **Events Yielded to Callers:** |
| 1504 | * **Live Model Audio Events with Inline Data:** Events containing raw |
| 1505 | audio `Blob` data(`inline_data`). |
| 1506 | * **Live Model Audio Events with File Data:** Both input and output audio |
| 1507 | data are aggregated into an audio file saved into artifacts. The |
| 1508 | reference to the file is saved in the event as `file_data`. |
| 1509 | * **Usage Metadata:** Events containing token usage. |
| 1510 | * **Transcription Events:** Both partial and non-partial transcription |
| 1511 | events are yielded. |
| 1512 | * **Function Call and Response Events:** Always saved. |
| 1513 | * **Other Control Events:** Most control events are saved. |
| 1514 | |
| 1515 | **Events Saved to the Session:** |
| 1516 | * **Live Model Audio Events with File Data:** Both input and ouput audio |
| 1517 | data are aggregated into an audio file saved into artifacts. The |
| 1518 | reference to the file is saved as event in the `file_data` to session |
| 1519 | if RunConfig.save_live_model_audio_to_session is True. |
| 1520 | * **Usage Metadata Events:** Saved to the session. |
| 1521 | * **Non-Partial Transcription Events:** Non-partial transcription events |
| 1522 | are saved. |
| 1523 | * **Function Call and Response Events:** Always saved. |
| 1524 | * **Other Control Events:** Most control events are saved. |
| 1525 | |
| 1526 | **Events Not Saved to the Session:** |
| 1527 | * **Live Model Audio Events with Inline Data:** Events containing raw |
| 1528 | audio `Blob` data are **not** saved to the session. |
| 1529 | |
| 1530 | Args: |
| 1531 | user_id: The user ID for the session. Required if `session` is None. |
| 1532 | session_id: The session ID for the session. Required if `session` is |
| 1533 | None. |
| 1534 | live_request_queue: The queue for live requests. |
| 1535 | run_config: The run config for the agent. |
| 1536 | session: The session to use. This parameter is deprecated, please use |
| 1537 | `user_id` and `session_id` instead. |
| 1538 | |
| 1539 | Yields: |
| 1540 | AsyncGenerator[Event, None]: An asynchronous generator that yields |
| 1541 | `Event` |
| 1542 | objects as they are produced by the agent during its live execution. |
| 1543 | |
| 1544 | .. warning:: |
| 1545 | This feature is **experimental** and its API or behavior may change |
| 1546 | in future releases. |