Iterate over the stream as ``key, value`` pairs. Examples: .. sourcecode:: python @app.agent(topic) async def mytask(stream): async for key, value in stream.items(): print(key, value)
(self)
| 277 | return new_stream |
| 278 | |
| 279 | async def items(self) -> AsyncIterator[Tuple[K, T_co]]: |
| 280 | """Iterate over the stream as ``key, value`` pairs. |
| 281 | |
| 282 | Examples: |
| 283 | .. sourcecode:: python |
| 284 | |
| 285 | @app.agent(topic) |
| 286 | async def mytask(stream): |
| 287 | async for key, value in stream.items(): |
| 288 | print(key, value) |
| 289 | """ |
| 290 | async for event in self.events(): |
| 291 | yield event.key, cast(T_co, event.value) |
| 292 | |
| 293 | async def events(self) -> AsyncIterable[EventT]: |
| 294 | """Iterate over the stream as events exclusively. |