Ë
    ïÏji  ã                  óÐ   — d dl mZ d dlmZmZmZ d dlmZmZ ddl	m
Z
mZmZmZmZ ddlmZ ddlmZmZ d	d
lmZmZ ddlmZ  G d„ dee   ee
   «      Z G d„ dee   ee
   «      Zy)é    )Úannotations)ÚGenericÚIteratorÚAsyncIterator)ÚSelfÚoverrideé   )ÚOutputTÚAgentTurnResultÚAgentTurnResultErrorÚAgentOutputParseErrorÚAgentTurnResultCollectioné   )Úcached_property)ÚStreamÚAsyncStreamé   )ÚToolDispatcherÚAsyncToolDispatcher)ÚAgentSessionEventc                  ó`   ‡ — e Zd ZU dZdZded<   ed	d„«       Zed
ˆ fd„«       Z	dd„Z
dd„Zˆ xZS )ÚAgentSessionEventStreama6  Beta: a creation event stream that can collect its initial turn's result.

    Event iteration and response access behave like ``Stream``. Registered tool
    handlers execute during iteration, after their call event is yielded.
    Supply initial input when creating a session to collect its turn result.
    NzToolDispatcher | NoneÚ_dispatcherc                ó   — t        «       S ©N©r   ©Úselfs    ú[/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/openai/lib/beta/agents/_stream.pyÚ_collectionz#AgentSessionEventStream._collection   ó   € ä(Ó*Ð*ó    c              #  óð  •K  — 	 t         ‰| �  «       D ]Œ  }| j                  j                  |«       | j                  �| j                  j                  |«      nd }|–— |€ŒN| j                  €Œ[| j                  j                  rŒr| j                  j                  |«       ŒŽ 	 | j                  «        y # t        $ r!}| j                  j                  |«       ‚ d }~ww xY w# | j                  «        w xY w­wr   ©ÚsuperÚ
__stream__r    Úacceptr   ÚprepareÚresponseÚ	is_closedÚdispatchÚ	ExceptionÚrecord_errorÚclose©r   ÚeventÚpendingÚerrorÚ	__class__s       €r   r&   z"AgentSessionEventStream.__stream__   sÎ   øè ø€ ð	Ü™Ñ+Ö-�Ø× Ñ ×'Ñ'¨Ô.Ø=A×=MÑ=MÐ=Y˜$×*Ñ*×2Ñ2°5Ô9Ð_c�Ø’ØÑ&¨4×+;Ñ+;Ñ+GÐPT×P]ÑP]×PgÓPgØ×$Ñ$×-Ñ-¨gÕ6ñ .ð �J‰J�Løô	 ò 	Ø×Ñ×)Ñ)¨%Ô0Øûð	ûð �J‰J�LüsG   ƒC6…AB4 Á!B4 Á.B4 ÂB4 Â#C6Â4	CÂ=CÃCÃC! Ã!C3Ã3C6c                ó:   — | j                   j                  «        | S ©zGBeta: retain final messages for a result; call before consuming events.©r    Úenabler   s    r   Úwith_result_collectionz.AgentSessionEventStream.with_result_collection*   ó   € à×Ñ×ÑÔ!Øˆr"   c                óF  — | j                   j                  «       }	 |j                  | j                  �| j                  j                  nd«       |j                  «       sL| D ]G  }|j                  | j                  �| j                  j                  nd«       |j                  «       sŒG n | j                   j                  «       | j                  «        S # t        t        f$ r ‚ t        $ r}||_        |j                  d«      |‚d}~ww xY w# | j                  «        w xY w)a{  Consume remaining events and return the successful initial turn result.

        Raises AgentTurnResultError for an unsuccessful or unobserved outcome.
        Collection starts automatically on a fresh stream. To iterate first, call
        with_result_collection() before consuming events. Repeated calls return
        the cached result without consuming more events.
        N© Úobservation_failed©r    r7   Úcheck_outcomer   ÚhandlersÚis_doneÚresultr.   r   r   r,   Úcauser2   ©r   Ú	collectorÚ_r2   s       r   Úget_final_resultz(AgentSessionEventStream.get_final_result/   sû   € ð ×$Ñ$×+Ñ+Ó-ˆ	ð	Ø×#Ñ#À×AQÑAQÐA] D×$4Ñ$4×$=Ò$=ÐceÔfØ×$Ñ$Ô&Û�AØ×+Ñ+È×IYÑIYÐIe¨D×,<Ñ,<×,EÒ,EÐkmÔnØ ×(Ñ(Õ*Ùð ð ×#Ñ#×*Ñ*Ó,ð �J‰J�Løô %Ô&;Ð<ò 	ØÜò 	CØ#ˆIŒOØ—/‘/Ð"6Ó7¸UÐBûð	Cûð �J‰J�Lús*   œBC Â(C ÃDÃ-DÄDÄD ÄD ©Úreturnz"AgentTurnResultCollection[OutputT])rH   zIterator[AgentSessionEvent]©rH   r   ©rH   zAgentTurnResult[OutputT]©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r    r   r&   r8   rF   Ú__classcell__©r3   s   @r   r   r      sE   ø… ñð *.€KÐ&Ó-àò+ó ð+ð ôó ðó÷
r"   r   c                  ó`   ‡ — e Zd ZU dZdZded<   ed	d„«       Zed
ˆ fd„«       Z	dd„Z
dd„Zˆ xZS )ÚAsyncAgentSessionEventStreamz:Beta: asynchronous counterpart of AgentSessionEventStream.NzAsyncToolDispatcher | Noner   c                ó   — t        «       S r   r   r   s    r   r    z(AsyncAgentSessionEventStream._collectionN   r!   r"   c               ó<  •K  — 	 t         ‰| �  «       2 3 d {  –—† }| j                  j                  |«       | j                  �| j                  j                  |«      nd }|­–— |€ŒU| j                  €Œb| j                  j                  rŒy| j                  j                  |«      ƒ d {  –—†  Œ�7 Œ˜7 Œ6 n-# t        $ r!}| j                  j                  |«       ‚ d }~ww xY w	 | j                  «       ƒ d {  –—†7   y # | j                  «       ƒ d {  –—†7   w xY w­wr   r$   r/   s       €r   r&   z'AsyncAgentSessionEventStream.__stream__R   sô   øè ø€ ð	Ü$™wÑ1Ô3÷ =�eØ× Ñ ×'Ñ'¨Ô.Ø=A×=MÑ=MÐ=Y˜$×*Ñ*×2Ñ2°5Ô9Ð_c�Ø“ØÑ&¨4×+;Ñ+;Ñ+GÐPT×P]ÑP]×PgÓPgØ×*Ñ*×3Ñ3°GÓ<×<Ñ<ð=øð
 =øñ  4øô ò 	Ø×Ñ×)Ñ)¨%Ô0Øûð	úð  4ð —*‘*“,×Òø�$—*‘*“,×Òüs—   ƒD…B6 “B4—B0˜B4›AB6 Á(B6 Á5B6 ÂB6 Â*B2Â+B6 Â0B4Â2B6 Â4B6 Â5C> Â6	C Â?CÃC Ã C> Ã$DÃ7C:Ã8DÃ>DÄDÄDÄDc                ó:   — | j                   j                  «        | S r5   r6   r   s    r   r8   z3AsyncAgentSessionEventStream.with_result_collectiona   r9   r"   c              ƒ  ó„  K  — | j                   j                  «       }	 |j                  | j                  �| j                  j                  nd«       |j                  «       sP| 2 3 d{  –—† }|j                  | j                  �| j                  j                  nd«       |j                  «       sŒM | j                   j                  «       | j                  «       ƒ d{  –—†  S 7 Œ{6 Œ67 Œ	# t        t        f$ r ‚ t        $ r}||_        |j                  d«      |‚d}~ww xY w# | j                  «       ƒ d{  –—†7   w xY w­w)zÐConsume remaining events and return the successful initial turn result.

        Enables collection on a fresh stream. To iterate first, call
        with_result_collection() before consuming events.
        Nr;   r<   r=   rC   s       r   rF   z-AsyncAgentSessionEventStream.get_final_resultf   s  è ø€ ð ×$Ñ$×+Ñ+Ó-ˆ	ð	Ø×#Ñ#À×AQÑAQÐA] D×$4Ñ$4×$=Ò$=ÐceÔfØ×$Ñ$Ô&Ù#÷ ˜!Ø×+Ñ+È×IYÑIYÐIe¨D×,<Ñ,<×,EÒ,EÐkmÔnØ ×(Ñ(Õ*ØØ×#Ñ#×*Ñ*Ó,ð —*‘*“,×Ñðø˜tøð ùô %Ô&;Ð<ò 	ØÜò 	CØ#ˆIŒOØ—/‘/Ð"6Ó7¸UÐBûð	Cûð —*‘*“,×Òüs~   ‚E žAC) Á#C%Á'C#Á(C%Á+AC) Â0C) Ã
E ÃC'ÃE Ã#C%Ã%C) Ã'E Ã)DÄDÄDÄD" Ä"D=Ä6D9Ä7D=Ä=E rG   )rH   z AsyncIterator[AgentSessionEvent]rI   rJ   rK   rR   s   @r   rT   rT   I   sA   ø… ÙDà.2€KÐ+Ó2àò+ó ð+ð ôó ðó÷
r"   rT   N)Ú
__future__r   Útypingr   r   r   Útyping_extensionsr   r   Ú_resultr
   r   r   r   r   Ú_compatr   Ú
_streamingr   r   Ústreaming.agents._dispatchr   r   Útypes.beta.agent_session_eventr   r   rT   r;   r"   r   Ú<module>ra      sV   ðÝ "ç 3Ñ 3ß ,ç uÕ uÝ 'ß .ß MÝ @ô9˜fÐ%6Ñ7¸ÀÑ9Iô 9ôx2 ;Ð/@Ñ#AÀ7È7ÑCSõ 2r"   