Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/llama_stack_client/lib/agents/event_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.

from typing import Any, Iterator, Optional, Tuple
from typing import Any, AsyncIterator, Iterator, Optional, Tuple

from termcolor import cprint

Expand Down Expand Up @@ -163,3 +163,11 @@ def log(self, event_generator: Iterator[Any]) -> Iterator[TurnStreamPrintableEve
printer = TurnStreamEventPrinter()
for chunk in event_generator:
yield from printer.yield_printable_events(chunk)


class AsyncEventLogger:
async def log(self, event_generator: AsyncIterator[Any]) -> AsyncIterator[TurnStreamPrintableEvent]:
printer = TurnStreamEventPrinter()
async for chunk in event_generator:
for printable_event in printer.yield_printable_events(chunk):
yield printable_event