
    Oj                        d dl mZ d dlZd dlmZmZmZ d dlZddlm	Z	m
Z
  G d de      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!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y)*    )annotationsN)AnyProtocolcast   )DEFAULT_TIMEOUTDEFAULT_CONNECTION_LIMITSc                      e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   y)_LegacyHttpxModuleztype[httpx2.Auth]Authztype[httpx2.Client]Clientztype[httpx2.AsyncClient]AsyncClientztype[httpx2.URL]URLztype[httpx2.Response]Responseztype[httpx2.Timeout]Timeoutztype[httpx2.Limits]Limitsztype[httpx2.TimeoutException]TimeoutExceptionztype[httpx2.RequestError]RequestErrorztype[httpx2.HTTPStatusError]HTTPStatusErrorztype[httpx2.StreamConsumed]StreamConsumedztype[httpx2.RequestNotRead]RequestNotReadN)__name__
__module____qualname____annotations__     e/var/www/origus_pro_usr/data/www/origus.pro/core/.venv/lib/python3.12/site-packages/openai/_httpx2.pyr   r      sJ    
))	##!!33++11////r   r   c                 h    t         j                  j                  d      } | t        t        |       S d S )Nhttpx)sysmodulesgetr   r   modules    r   _loaded_legacy_httpxr&      s,    [[__W%F/5/A4"F+KtKr   c                6    t        | t        j                        S N)
isinstancehttpx2r   values    r   is_httpx2_sync_clientr-      s    eV]]++r   c                6    t        | t        j                        S r(   )r)   r*   r   r+   s    r   is_httpx2_async_clientr/   #   s    eV//00r   c                N    t               }|d uxr t        | |j                        S r(   )r&   r)   r   r,   r%   s     r   is_legacy_httpx_sync_clientr2   '   s%    !#FB*UFMM"BBr   c                N    t               }|d uxr t        | |j                        S r(   )r&   r)   r   r1   s     r   is_legacy_httpx_async_clientr4   ,   s'    !#FG*UF4F4F"GGr   c                    t        | t        j                        r| S t               }| }|4t        ||j                        rt        j                  t	        |            S t        j                  |       S r(   )r)   r*   r   r&   str)r,   r%   legacy_values      r   normalize_httpx_urlr8   1   sX    %$!#F LjvzzBzz#l+,,::er   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   http_response_typesr:   =   s-    !#F!'FOOWfoov5WWr   c                    t               }|9t        | |j                        r#t        j                  di | j	                         S | S Nr   )r&   r)   r   r*   as_dictr1   s     r   normalize_httpx_timeoutr>   B   s:    !#Fj?~~000Lr   c                    t        |       S r(   )r>   r+   s    r   normalize_httpx2_timeoutr@   I   s    "5))r   c                    t               }|:t        | t        j                        r  |j                  di | j	                         S | S r<   )r&   r)   r*   r   r=   r1   s     r   normalize_legacy_httpx_timeoutrB   M   s<    !#Fj?v~~000Lr   c                t    t               }|+t        |       |j                  u rt        j                         S | S r(   )r&   typer   r*   r1   s     r   normalize_httpx2_authrE   T   s0    !#Fd5kV[[8{{}Lr   c                t    t               }|+t        |       t        j                  u r|j                         S | S r(   )r&   rD   r*   r   r1   s     r   normalize_legacy_httpx_authrG   [   s0    !#Fd5kV[[8{{}Lr   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   timeout_exceptionsrI   b   s4    !#F)/F##%of>U>UW]WnWn=oor   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   request_exceptionsrK   g   s3    !#F%+^F!c&:M:MvObOb9ccr   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   status_exceptionsrM   l   s4    !#F(.F""$lV=S=SU[UkUk<llr   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   stream_consumed_exceptionsrO   q   4    !#F'-~F!!#iF<Q<QSYShSh;iir   c                 t    t               } | t        j                  fS t        j                  | j                  fS r(   )r&   r*   r   r$   s    r   request_not_read_exceptionsrR   v   rP   r   c                R   t        | j                  dt                    | d<   | j                  dt              }t	               }|Lt        ||j                        r6t        j                  |j                  |j                  |j                        }|| d<   | j                  dd       y )Ntimeoutlimits)max_connectionsmax_keepalive_connectionskeepalive_expiryfollow_redirectsT)r@   r#   r   r	   r&   r)   r   r*   rV   rW   rX   
setdefault)kwargsrU   r%   s      r   _set_httpx2_defaultsr\   {   s    0I1WXF9ZZ";<F!#Fj?"22&,&F&F#44

 F8
($/r   c                 B    t        |        t        j                  di | S )z<Create an HTTPX2 client with the SDK's recommended defaults.r   )r\   r*   r   r[   s    r   DefaultHttpx2Clientr_      s     =="6""r   c                 B    t        |        t        j                  di | S )zBCreate an async HTTPX2 client with the SDK's recommended defaults.r   )r\   r*   r   r^   s    r   DefaultAsyncHttpx2Clientra      s     '''r   )returnz_LegacyHttpxModule | None)r,   objectrb   bool)r,   zstr | httpx2.URLrb   z
httpx2.URL)rb   z!tuple[type[httpx2.Response], ...])r,   float | httpx2.Timeout | Nonerb   re   )r,   httpx2.Authrb   rf   )rb   z)tuple[type[httpx2.TimeoutException], ...])rb   z%tuple[type[httpx2.RequestError], ...])rb   z(tuple[type[httpx2.HTTPStatusError], ...])rb   z'tuple[type[httpx2.StreamConsumed], ...])rb   z'tuple[type[httpx2.RequestNotRead], ...])r[   zdict[str, Any]rb   None)r[   r   rb   zhttpx2.Client)r[   r   rb   zhttpx2.AsyncClient) 
__future__r   r!   typingr   r   r   r*   
_constantsr   r	   r   r&   r-   r/   r2   r4   r8   r:   r>   r@   rB   rE   rG   rI   rK   rM   rO   rR   r\   r_   ra   r   r   r   <module>rk      s    " 
 & &  B0 0L
,1C
H
	X
*p
d
m
j
j
0#(r   