You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The API is now "stable" so we can't change it for v0.4.*. However, run_stream is admittedly quite "low-level" such that it requires something like Console to help work with it.
Instead of changing run_stream we can add other sink functions similar to Console to make it easier to consume the messages? Ideas?
One pattern I have seen is an event handler class, such as the OpenAI Assistant's EventHandler class.
Maybe just two new methods run_message_stream and get_result and the old run_stream could be implemented with these two methods internally to avoid duplication.
What feature would you like to be added?
I think
run_stream
inBaseGroupChat
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: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.
The text was updated successfully, but these errors were encountered: