FunctionObserver

class FunctionObserver(RealtimeObserver)

Observer for handling function calls from the OpenAI Realtime API.

__init__

def __init__(agent: "RealtimeAgent") -> None

Observer for handling function calls from the OpenAI Realtime API.

Arguments:

  • agent RealtimeAgent - The realtime agent attached to the observer.

update

async def update(response: dict[str, Any]) -> None

Handle function call events from the OpenAI Realtime API.

Arguments:

  • response dict[str, Any] - The response from the OpenAI Realtime API.

call_function

async def call_function(call_id: str, name: str, kwargs: dict[str,
                                                              Any]) -> None

Call a function registered with the agent.

Arguments:

  • call_id str - The ID of the function call.
  • name str - The name of the function to call.
  • kwargs Any[str, Any] - The arguments to pass to the function.

run

async def run() -> None

Run the observer.

Initialize the session with the OpenAI Realtime API.

initialize_session

async def initialize_session() -> None

Add registered tools to OpenAI with a session update.