
    Agi              	       
   d Z ddl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	 ddl
mZ ej                  j                  ej                  j                  j                  ej                   fej                  j"                  ej                  j                  j$                  ej&                  fej                  j(                  ej                  j                  j*                  ej,                  fej                  j.                  ej                  j                  j0                  ej2                  fiZd	 Zd
 Zd Zd Z G d dej>                        Z  G d de	jB                  ejD                        Z#d Z$d Z%d Z&d Z'd Z(d Z) G d dejT                        Z+ G d dejX                        Z- G d dej\                        Z/ G d dej`                        Z1 G d d ejd                        Z3 G d! d"ejh                        Z5d# Z6d$ Z7y)%zCTranslates gRPC's client-side API into gRPC's client-side Beta API.    N)_common)	_metadata)
interfaces)cardinality)future)facec                 &    | dn| }||S  ||      S )N r
   )metadatametadata_transformernon_none_metadatas      R/var/www/openai/venv/lib/python3.12/site-packages/grpc/beta/_client_adaptations.py_effective_metadatar   .   s'    &.H#  #$566    c                 "    | d S | j                   S N)credentials)grpc_call_optionss    r   _credentialsr   6   s    $,4O2C2O2OOr   c                 (   | j                         }t        j                  |      }|$t        j                  j
                  j                  n|d   }t        j                  || j                         | j                         || j                               S )Nr   )
code6_STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASSgetr   AbortionKindLOCAL_FAILUREinitial_metadatatrailing_metadatadetails)rpc_error_callr   pair
error_kinds       r   	_abortionr#   :   sz     DAEEdKD59\##11tAwJ=='')((*  r   c                     | j                         }t        j                  |      }|t        j                  n|d   } || j                         | j                         || j                               S )N   )r   r   r   r   AbortionErrorr   r   r   )r    r   r!   exception_classs       r   _abortion_errorr(   G   si     DAEEdKD,0Ld((d1gO'')((* 	 r   c                       e Zd Zd Zy)_InvocationProtocolContextc                      y r   r
   selfs    r    disable_next_request_compressionz;_InvocationProtocolContext.disable_next_request_compressionT   s    r   N)__name__
__module____qualname__r.   r
   r   r   r*   r*   S   s    r   r*   c                       e Zd Zd Zd Zd Zd Zd ZddZddZ	dd	Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)_Rendezvousc                 .    || _         || _        || _        y r   )_future	_iterator_call)r-   response_futureresponse_iteratorcalls       r   __init__z_Rendezvous.__init__Y   s    &*
r   c                 6    | j                   j                         S r   )r7   cancelr,   s    r   r=   z_Rendezvous.cancel^   s    zz  ""r   c                 6    | j                   j                         S r   )r5   	cancelledr,   s    r   r?   z_Rendezvous.cancelleda   s    ||%%''r   c                 6    | j                   j                         S r   )r5   runningr,   s    r   rA   z_Rendezvous.runningd   s    ||##%%r   c                 6    | j                   j                         S r   )r5   doner,   s    r   rC   z_Rendezvous.doneg   s    ||  ""r   Nc                     	 | j                   j                  |      S # t        j                  $ r}t	        |      d }~wt        j
                  $ r t        j                         t        j                  $ r t        j                         w xY wN)timeout)
r5   resultgrpcRpcErrorr(   FutureTimeoutErrorr   TimeoutErrorFutureCancelledErrorCancelledErrorr-   rF   r    s      r   rG   z_Rendezvous.resultj   sx    	*<<&&w&77}} 	2!.11&& 	(%%''(( 	*''))	*s    B<ABc                     	 | j                   j                  |      }|y t        |      S # t        j                  $ r t        j                         t        j                  $ r t        j                         w xY wrE   )	r5   	exceptionr(   rH   rJ   r   rK   rL   rM   rN   s      r   rP   z_Rendezvous.exceptiont   ss    		*!\\33G3DN%&~66&& 	(%%''(( 	*''))	*s   , 
, AA:c                     	 | j                   j                  |      S # t        j                  $ r t	        j
                         t        j                  $ r t	        j                         w xY wrE   )r5   	tracebackrH   rJ   r   rK   rL   rM   )r-   rF   s     r   rR   z_Rendezvous.traceback   s`    	*<<))')::&& 	(%%''(( 	*''))	*s
    AA,c                 F      j                   j                   fd       y )Nc                            S r   r
   )ignored_callbackfnr-   s    r   <lambda>z/_Rendezvous.add_done_callback.<locals>.<lambda>   s	    4r   )r5   add_done_callback)r-   rV   s   ``r   rX   z_Rendezvous.add_done_callback   s    &&'HIr   c                     | S r   r
   r,   s    r   __iter__z_Rendezvous.__iter__       r   c                 z    	 t        | j                        S # t        j                  $ r}t	        |      d }~ww xY wr   )nextr6   rH   rI   r(   )r-   r    s     r   _nextz_Rendezvous._next   s5    	2''}} 	2!.11	2s    :5:c                 "    | j                         S r   r^   r,   s    r   __next__z_Rendezvous.__next__       zz|r   c                 "    | j                         S r   r`   r,   s    r   r]   z_Rendezvous.next   rb   r   c                 6    | j                   j                         S r   )r7   	is_activer,   s    r   re   z_Rendezvous.is_active   s    zz##%%r   c                 6    | j                   j                         S r   )r7   time_remainingr,   s    r   rg   z_Rendezvous.time_remaining   s    zz((**r   c                 ^      fd} j                   j                  |      }|rd S  |       S )Nc                      j                         t        j                  j                  ur  t	        j
                               y y r   )r   rH   
StatusCodeOKr#   r7   )abortion_callbackr-   s   r   done_callbackz8_Rendezvous.add_abortion_callback.<locals>.done_callback   s1    yy{$//"4"44!)DJJ"78 5r   )r7   add_callback)r-   rl   rm   
registereds   ``  r   add_abortion_callbackz!_Rendezvous.add_abortion_callback   s-    	9 ZZ,,];
!t6}6r   c                     t               S r   )r*   r,   s    r   protocol_contextz_Rendezvous.protocol_context   s    )++r   c                 \    t        j                  | j                  j                               S r   )r   betar7   r   r,   s    r   r   z_Rendezvous.initial_metadata   s    ~~djj99;<<r   c                 \    t        j                  | j                  j                               S r   )r   rt   r7   terminal_metadatar,   s    r   rv   z_Rendezvous.terminal_metadata   s    ~~djj::<==r   c                 6    | j                   j                         S r   )r7   r   r,   s    r   r   z_Rendezvous.code   s    zz  r   c                 6    | j                   j                         S r   )r7   r   r,   s    r   r   z_Rendezvous.details   s    zz!!##r   r   )r/   r0   r1   r;   r=   r?   rA   rC   rG   rP   rR   rX   rZ   r^   ra   r]   re   rg   rp   rr   r   rv   r   r   r
   r   r   r3   r3   X   sl    
#(&#*
**J2&+7,=>!$r   r3   c                    	 | j                  t        j                  ||      |	|
      }t        ||      }|rC|j	                  ||t        j                  |      t        |            \  }}|t        d d |      fS  |||t        j                  |      t        |            S # t        j                  $ r}t        |      d }~ww xY wN)request_serializerresponse_deserializer)rF   r   r   )unary_unaryr   fully_qualified_methodr   	with_callr   unbetar   r3   rH   rI   r(   )channelgroupmethodrF   r   protocol_optionsr   r   requestr{   r|   multi_callableeffective_metadataresponser:   r    s                   r   _blocking_unary_unaryr      s    . ,,**5&91"7 - 

 1;OP+55"))*<=()9:	 6 NHd [tT:::!"))*<=()9:	  == .n--.   A8B# ;'B# #C6CCc
                     | j                  t        j                  ||      ||	      }
t        ||      }|
j	                  ||t        j                  |      t        |            }t        |d |      S rz   )	r}   r   r~   r   r   r   r   r   r3   )r   r   r   rF   r   r   r   r   r{   r|   r   r   r8   s                r   _future_unary_unaryr      s     ((&&uf5-3 ) N
 -X7KL$++!!"45 !12	 , O o>>r   c
                     | j                  t        j                  ||      ||	      }
t        ||      } |
||t	        j
                  |      t        |            }t        d ||      S rz   )unary_streamr   r~   r   r   r   r   r3   )r   r   r   rF   r   r   r   r   r{   r|   r   r   r9   s                r   _unary_streamr      s{     ))&&uf5-3 * N
 -X7KL&!!"45 !12	 t.0ABBr   c                    	 | j                  t        j                  ||      |	|
      }t        ||      }|rC|j	                  ||t        j                  |      t        |            \  }}|t        d d |      fS  |||t        j                  |      t        |            S # t        j                  $ r}t        |      d }~ww xY wrz   )stream_unaryr   r~   r   r   r   r   r   r3   rH   rI   r(   )r   r   r   rF   r   r   r   r   request_iteratorr{   r|   r   r   r   r:   r    s                   r   _blocking_stream_unaryr     s    . --**5&91"7 . 

 1;OP+55 "))*<=()9:	 6 NHd [tT:::! "))*<=()9:	  == .n--.r   c
                     | j                  t        j                  ||      ||	      }
t        ||      }|
j	                  ||t        j                  |      t        |            }t        |d |      S rz   )	r   r   r~   r   r   r   r   r   r3   )r   r   r   rF   r   r   r   r   r{   r|   r   r   r8   s                r   _future_stream_unaryr   <  s     ))&&uf5-3 * N
 -X7KL$++!!"45 !12	 , O o>>r   c
                     | j                  t        j                  ||      ||	      }
t        ||      } |
||t	        j
                  |      t        |            }t        d ||      S rz   )stream_streamr   r~   r   r   r   r   r3   )r   r   r   rF   r   r   r   r   r{   r|   r   r   r9   s                r   _stream_streamr   W  s{     **&&uf5-3 + N
 -X7KL&!!"45 !12	 t.0ABBr   c                   4    e Zd Zd Z	 	 	 ddZddZ	 	 ddZy)_UnaryUnaryMultiCallablec                 X    || _         || _        || _        || _        || _        || _        y r   _channel_group_method_metadata_transformer_request_serializer_response_deserializerr-   r   r   r   r   r{   r|   s          r   r;   z!_UnaryUnaryMultiCallable.__init__s  1      %9"#5 &;#r   Nc                     t        | j                  | j                  | j                  ||||| j                  || j
                  | j                        S r   )r   r   r   r   r   r   r   )r-   r   rF   r   r   r   s         r   __call__z!_UnaryUnaryMultiCallable.__call__  sP     %MMKKLL&&$$''
 	
r   c                     t        | j                  | j                  | j                  |||| j                  || j
                  | j                  
      S r   )r   r   r   r   r   r   r   r-   r   rF   r   r   s        r   r   z_UnaryUnaryMultiCallable.future  sK    "MMKKLL&&$$''
 	
r   c                     t               r   NotImplementedErrorr-   r   receiverrl   rF   r   r   s          r   eventz_UnaryUnaryMultiCallable.event       "##r   NFNNNr/   r0   r1   r;   r   r   r   r
   r   r   r   r   r  s)    <( 
,
( 	$r   r   c                   &    e Zd Zd ZddZ	 	 ddZy)_UnaryStreamMultiCallablec                 X    || _         || _        || _        || _        || _        || _        y r   r   r   s          r   r;   z"_UnaryStreamMultiCallable.__init__  r   r   Nc                     t        | j                  | j                  | j                  |||| j                  || j
                  | j                  
      S r   )r   r   r   r   r   r   r   r   s        r   r   z"_UnaryStreamMultiCallable.__call__  sK    MMKKLL&&$$''
 	
r   c                     t               r   r   r   s          r   r   z_UnaryStreamMultiCallable.event  r   r   r   r/   r0   r1   r;   r   r   r
   r   r   r   r     s    < 
( 	$r   r   c                   6    e Zd Zd Z	 	 	 ddZ	 ddZ	 	 ddZy)_StreamUnaryMultiCallablec                 X    || _         || _        || _        || _        || _        || _        y r   r   r   s          r   r;   z"_StreamUnaryMultiCallable.__init__  r   r   Nc                     t        | j                  | j                  | j                  ||||| j                  || j
                  | j                        S r   )r   r   r   r   r   r   r   )r-   r   rF   r   r   r   s         r   r   z"_StreamUnaryMultiCallable.__call__  sP     &MMKKLL&&$$''
 	
r   c                     t        | j                  | j                  | j                  |||| j                  || j
                  | j                  
      S r   )r   r   r   r   r   r   r   r-   r   rF   r   r   s        r   r   z _StreamUnaryMultiCallable.future  sM     $MMKKLL&&$$''
 	
r   c                     t               r   r   r-   r   rl   rF   r   r   s         r   r   z_StreamUnaryMultiCallable.event       "##r   r   r   r   r
   r   r   r   r     s0    <( 
. JN
* $r   r   c                   (    e Zd Zd Z	 ddZ	 	 ddZy)_StreamStreamMultiCallablec                 X    || _         || _        || _        || _        || _        || _        y r   r   r   s          r   r;   z#_StreamStreamMultiCallable.__init__!  r   r   Nc                     t        | j                  | j                  | j                  |||| j                  || j
                  | j                  
      S r   )r   r   r   r   r   r   r   r   s        r   r   z#_StreamStreamMultiCallable.__call__1  sM     MMKKLL&&$$''
 	
r   c                     t               r   r   r   s         r   r   z _StreamStreamMultiCallable.eventA  r   r   r   r   r
   r   r   r   r      s     <" JN
* $r   r   c                       e Zd Zd Z	 	 	 ddZ	 	 ddZ	 	 ddZ	 	 	 ddZ	 	 ddZ	 	 ddZ		 	 dd	Z
	 	 dd
Z	 	 ddZ	 	 ddZd Zd Zd Zd Zd Zd Zy)_GenericStubc                 L    || _         || _        |xs i | _        |xs i | _        y r   )r   r   _request_serializers_response_deserializers)r-   r   r   request_serializersresponse_deserializerss        r   r;   z_GenericStub.__init__M  s-      %9"$7$=2!'='C$r   Nc                     | j                   j                  ||f      }| j                  j                  ||f      }	t        | j                  ||||||| j
                  |||	      S r   )r   r   r   r   r   r   )
r-   r   r   r   rF   r   r   r   r{   r|   s
             r   blocking_unary_unaryz!_GenericStub.blocking_unary_unaryY  s     "66::
 !% < < @ @!
 %MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  |||||| j
                  |||
      S r   )r   r   r   r   r   r   	r-   r   r   r   rF   r   r   r{   r|   s	            r   future_unary_unaryz_GenericStub.future_unary_unary}  s     "66::
 !% < < @ @!
 #MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  |||||| j
                  |||
      S r   )r   r   r   r   r   r   r   s	            r   inline_unary_streamz _GenericStub.inline_unary_stream  s     "66::
 !% < < @ @!
 MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }	t        | j                  ||||||| j
                  |||	      S r   )r   r   r   r   r   r   )
r-   r   r   r   rF   r   r   r   r{   r|   s
             r   blocking_stream_unaryz"_GenericStub.blocking_stream_unary  s     "66::
 !% < < @ @!
 &MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  |||||| j
                  |||
      S r   )r   r   r   r   r   r   	r-   r   r   r   rF   r   r   r{   r|   s	            r   future_stream_unaryz _GenericStub.future_stream_unary  s     "66::
 !% < < @ @!
 $MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  |||||| j
                  |||
      S r   )r   r   r   r   r   r   r   s	            r   inline_stream_streamz!_GenericStub.inline_stream_stream  s     "66::
 !% < < @ @!
 MM&&!
 	
r   c	                     t               r   r   	r-   r   r   r   r   rl   rF   r   r   s	            r   event_unary_unaryz_GenericStub.event_unary_unary)       "##r   c	                     t               r   r   r   s	            r   event_unary_streamz_GenericStub.event_unary_stream6  r   r   c                     t               r   r   r-   r   r   r   rl   rF   r   r   s           r   event_stream_unaryz_GenericStub.event_stream_unaryC       "##r   c                     t               r   r   r   s           r   event_stream_streamz _GenericStub.event_stream_streamO  r   r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  ||| j
                  ||      S r   )r   r   r   r   r   r   r-   r   r   r{   r|   s        r   r}   z_GenericStub.unary_unary[  ss    !66::
 !% < < @ @!
 (MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  ||| j
                  ||      S r   )r   r   r   r   r   r   r   s        r   r   z_GenericStub.unary_streamq  s    !66::
 !% < < @ @!
 )MM&&!
 	
r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  ||| j
                  ||      S r   )r   r   r   r   r   r   r   s        r   r   z_GenericStub.stream_unary  r   r   c                     | j                   j                  ||f      }| j                  j                  ||f      }t        | j                  ||| j
                  ||      S r   )r   r   r   r   r   r   r   s        r   r   z_GenericStub.stream_stream  ss    !66::
 !% < < @ @!
 *MM&&!
 	
r   c                     | S r   r
   r,   s    r   	__enter__z_GenericStub.__enter__  r[   r   c                      yNFr
   r-   exc_typeexc_valexc_tbs       r   __exit__z_GenericStub.__exit__      r   )NNNr   )r/   r0   r1   r;   r   r   r   r   r   r   r   r   r   r   r}   r   r   r   r   r   r
   r   r   r   r   L  s    
D$ "
T  
P  
P "
T  
P  
T $* $( 
$& 
$
,
,
,
,r   r   c                   $    e Zd Zd Zd Zd Zd Zy)_DynamicStubc                 .    || _         || _        || _        y r   )_generic_stubr   _cardinalities)r-   backing_generic_stubr   cardinalitiess       r   r;   z_DynamicStub.__init__  s    1+r   c                 d   | j                   j                  |      }|t        j                  j                  u r&| j
                  j                  | j                  |      S |t        j                  j                  u r&| j
                  j                  | j                  |      S |t        j                  j                  u r&| j
                  j                  | j                  |      S |t        j                  j                  u r&| j
                  j                  | j                  |      S t        d|z        )Nz*_DynamicStub object has no attribute "%s"!)r   r   r   CardinalityUNARY_UNARYr   r}   r   UNARY_STREAMr   STREAM_UNARYr   STREAM_STREAMr   AttributeError)r-   attrmethod_cardinalitys      r   __getattr__z_DynamicStub.__getattr__  s    !0044T:!8!8!D!DD%%11$++tDD;#:#:#G#GG%%224;;EE;#:#:#G#GG%%224;;EE;#:#:#H#HH%%33DKKFF <tC r   c                     | S r   r
   r,   s    r   r   z_DynamicStub.__enter__  r[   r   c                      yr   r
   r   s       r   r   z_DynamicStub.__exit__  r   r   N)r/   r0   r1   r;   r  r   r   r
   r   r   r   r     s    ,
r   r   c                     t        | |||      S r   )r   )r   hostr   r   r   s        r   generic_stubr    s     	 r   c                 4    t        t        | |||      ||      S r   )r   r   )r   servicer   r  r   r   r   s          r   dynamic_stubr    s-      "		
 		 	r   )8__doc__rH   r   	grpc.betar   r   grpc.framework.commonr   grpc.framework.foundationr   grpc.framework.interfaces.facer   rj   	CANCELLEDr   r   CancellationErrorUNKNOWNREMOTE_FAILURERemoteErrorDEADLINE_EXCEEDEDEXPIREDExpirationErrorUNIMPLEMENTEDr   
LocalErrorr   r   r   r#   r(   GRPCInvocationContextr*   FutureCallr3   r   r   r   r   r   r   UnaryUnaryMultiCallabler   UnaryStreamMultiCallabler   StreamUnaryMultiCallabler   StreamStreamMultiCallabler   GenericStubr   DynamicStubr   r  r  r
   r   r   <module>r)     s   J      - , /
 	OO$$  	OO)) 	OO%%""( 	OO!!(($: 6(7P
	!A!A 
]$&-- ]$@$.N?6C6$.N?6C6>$t;; >$B($ = = ($V?$ = = ?$D)$!?!? )$Xk4## k\4## 8r   