FunctionObserver

FunctionObserver(*, logger: ForwardRef('Logger') | None = None)

Observer for handling function calls from the OpenAI Realtime API.

Observer for handling function calls from the OpenAI Realtime API.

Parameters:
NameDescription
loggerType: ForwardRef('Logger') | None

Default: None

Instance Methods

call_function

call_function(
    self,
    call_id: str,
    name: str,
    kwargs: dict[str, typing.Any]
) -> None

Call a function registered with the agent.

Parameters:
NameDescription
call_idThe ID of the function call.

Type: str
nameThe name of the function to call.

Type: str
kwargsThe arguments to pass to the function.

Type: dict[str, typing.Any]

initialize_session

initialize_session(self) -> None

Add registered tools to OpenAI with a session update.


on_event

on_event(self, event: autogen.agentchat.realtime.experimental.realtime_events.RealtimeEvent) -> None

Handle function call events from the OpenAI Realtime API.

Parameters:
NameDescription
eventThe event from the OpenAI Realtime API.

Type: autogen.agentchat.realtime.experimental.realtime_events.RealtimeEvent

run_loop

run_loop(self) -> None

Run the observer loop.