o
    h	                     @  sn   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ dd	lmZ dd
lmZ G dd dZdS )z9Minimal realtime session implementation for voice agents.    )annotations   )TContext   )RealtimeAgent)RealtimeRunConfig)RealtimeModelRealtimeModelConfig)OpenAIRealtimeWebSocketModel)RealtimeSessionc                   @  s4   e Zd ZdZddddddZddddddZdS )RealtimeRunnera  A `RealtimeRunner` is the equivalent of `Runner` for realtime agents. It automatically
    handles multiple turns by maintaining a persistent connection with the underlying model
    layer.

    The session manages the local history copy, executes tools, runs guardrails and facilitates
    handoffs between agents.

    Since this code runs on your server, it uses WebSockets by default. You can optionally create
    your own custom model layer by implementing the `RealtimeModel` interface.
    N)modelconfigstarting_agentr   r   RealtimeModel | Noner   RealtimeRunConfig | NonereturnNonec                C  s   || _ || _|p
t | _dS )aT  Initialize the realtime runner.

        Args:
            starting_agent: The agent to start the session with.
            context: The context to use for the session.
            model: The model to use. If not provided, will use a default OpenAI realtime model.
            config: Override parameters to use for the entire run.
        N)_starting_agent_configr
   _model)selfr   r   r    r   W/var/www/html/openai_agents/venv/lib/python3.10/site-packages/agents/realtime/runner.py__init__   s   zRealtimeRunner.__init__)contextmodel_configr   TContext | Noner   RealtimeModelConfig | Noner   c                  s   t | j| j||| jd}|S )a  Start and returns a realtime session.

        Returns:
            RealtimeSession: A session object that allows bidirectional communication with the
            realtime model.

        Example:
            ```python
            runner = RealtimeRunner(agent)
            async with await runner.run() as session:
                await session.send_message("Hello")
                async for event in session:
                    print(event)
            ```
        )r   agentr   r   
run_config)r   r   r   r   )r   r   r   sessionr   r   r   run1   s   zRealtimeRunner.run)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )__name__
__module____qualname____doc__r   r"   r   r   r   r   r      s    r   N)r&   
__future__r   run_contextr   r   r   r   r   r   r   r	   openai_realtimer
   r!   r   r   r   r   r   r   <module>   s    