-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Description
What feature would you like to be added?
I think run_stream in BaseGroupChat is a little bit awkward to use, because it streams both messages and the task result in the end. This leads to code like this for example:
async for message in self.run_stream(
task=task,
cancellation_token=cancellation_token,
):
if isinstance(message, BaseMessage) and message.models_usage is not None:
usages.append(message.models_usage)
if isinstance(message, TaskResult):
result = message
So you basically have to check the types of the messages, find the task result in the message and such stuff. This is partially also an issue with Python, because typings do not allow to specify that TaskResult will always be the last message.
I wonder if it would be better to separate concerns here and have one method for the actual messages and one method for the task result or something like this?
Why is this needed?
Make code easier to use.
Reactions are currently unavailable