Closed MarkEdmondson1234 closed 22 hours ago
use of user_stream= True did not work for me. Can you help?
Yes, it’s a suggestion :) not implemented
In CF 0.9 we have a new handler protocol that will let you intercept all of the backend events and do whatever you want with them. I will document and expose it more easily for .run() calls. It will look something like this:
If you look at the base Handler object you'll see methods for all of the major event types that CF produces at this time.
import controlflow as cf
from controlflow.orchestration import Handler
class MyHandler(Handler):
def on_event(self, event):
# do whatever you want with the event
def on_agent_message_delta(self, event):
# do whatever you want with the agent message delta
def on_...
cf.run("Say hello", handlers=[MyHandler()])
So you could write a handler for AgentMessage
or AgentMessageDelta
events that parses the event and ships it to wherever you need. Hopefully this is a useful way to access the backend -- if you end up with a solid implementation of a particular use case, we could include it as a built-in handler and make sure it stays up to date via tests!
@MarkEdmondson1234 v0.9.2 was just released with Handlers
exposed in the public API, and documentation added here
Looks like a great solution, thanks will check it out
Enhancement Description
I can see the agents/tasks writing to console, but I'd like to be able to output those streams to the user if relevant, perhaps with a user_stream=True parameter
Use Case
The user can them see whats happening via other places other than console, such as if wrapped in a HTTP endpoint and choice steps are returned so they know what is happening
Proposed Implementation