Flo-AI
  • 🚀Welcome to FloAI
  • Getting Started
    • Quickstart
    • Core Concepts
  • Basics
    • Agents
    • Tools
    • Routers
    • Teams
    • Flo-AI RAGs
    • Composability
    • YAML Configuration
  • Advanced
    • Multi-model Agents
    • Listeners
    • Logging
  • Guides
    • Jupyter Notebooks
    • Blogs
Powered by GitBook
On this page

Was this helpful?

  1. Advanced

Listeners

Listen carefully

FloAI has now callbacks that you can listen to. There are three types of callbacks we support right now:

  1. Agent Callback: For agent related events (use decorator @flo_agent_callback)

  2. ToolCallback: For tool related events (@flo_tool_callback)

  3. RouterCallback: For router related events (@flo_router_callback)

  4. Global Callback: For all the above events (@flo_call_back)

You can import them from flo_ai.callbacks

Example of using a callback

Define your callback

from flo_ai.callbacks import flo_agent_callback

@flo_agent_callback
def agent_callback(response: FloCallbackResponse):
    print('------------- START AGENT CALLBACK -----------')
    print(response)
    print('------------- END AGENT CALLBACK -----------')

Register the callback to the session

session.register_callback(agent_callback)

And thats it !

All callbacks use the following output format

@dataclass
class FloCallbackResponse:
    type: str
    name: Optional[str] = None
    model_name: Optional[str] = None
    input: Optional[str] = None
    output: Optional[str] = None
    error: Union[Exception, KeyboardInterrupt, None] = None
    args: Dict = field(default_factory=dict)

PreviousMulti-model AgentsNextLogging

Last updated 5 months ago

Was this helpful?