Skip to content

Add StreamProcessor class for handling message streams produced by run_stream and on_messages_stream. #6182

Closed
@ekzhu

Description

@ekzhu

Confirmation

  • I confirm that I am a maintainer and so can use this template. If I am not, I understand this issue will be closed and I will be asked to use a different template.

Issue body

Consider this design:

processor = StreamProcessor()
processor.add_handler(TextMessage, ...) # register a handler for `TextMessage` type.
processor.add_handler(HandoffMessage, ...) # register ad handler for the `HandoffMessage` type

stream = team.run_stream()
result = processor(stream)

We can then rewrite Console to subclass StreamProcessor to provide handlers for all the built-in message types and default handler for unknown message types.

Now you can customize Console to override handling of specific message types.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions