Why handlers have no async support? :exploding_hea...
# marvin-ai
c
Why handlers have no async support? 🤯 what's the workaround when say
on_agent_message_delta
writes the stream's chunks to display using an
async display()
?
j
Handlers are relatively new, first time it's been requested. We can have that out shortly though
Merged here and will go out in the next release: https://github.com/PrefectHQ/ControlFlow/pull/364
c
Awesome, impressed with the speed at which you shipped that through 🚀
j
🙌
c
It's weird how this was not a thing - coming from openai completions you would normally do something like:
Copy code
async for chunk in await openai.chat.completions.create(**kwargs):
  ...
Which, with controlflow, would look like this:
Copy code
async for delta in agent._run_model_async(
    stream=True,
    messages=messages[::-1],
    tools=[],
):
    if isinstance(delta, AgentMessageDelta):
        await on_agent_message_delta(delta
But this essentially locks us up from using actual flows, as all we're doing is "Call the LLM" So, to use of flows, the async handler is essential ...Unless I'm wrong