
    Yj	                        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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<   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.HTTPStatusError]HTTPStatusErrorztype[httpx2.StreamConsumed]StreamConsumedztype[httpx2.RequestNotRead]RequestNotReadN)__name__
__module____qualname____annotations__     M/var/www/html/vmm-quimica/venv/lib/python3.12/site-packages/openai/_httpx2.pyr   r      sD    
))	##!!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_clientr1   &   s%    !#FB*UFMM"BBr   c                N    t               }|d uxr t        | |j                        S r'   )r%   r(   r   r0   s     r   is_legacy_httpx_async_clientr3   +   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_urlr7   0   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_typesr9   <   s-    !#F!'FOOWfoov5WWr   c                    t               }|9t        | |j                        r#t        j                  di | j	                         S | S Nr   )r%   r(   r   r)   as_dictr0   s     r   normalize_httpx_timeoutr=   A   s:    !#Fj?~~000Lr   c                    t        |       S r'   )r=   r*   s    r   normalize_httpx2_timeoutr?   H   s    "5))r   c                    t               }|:t        | t        j                        r  |j                  di | j	                         S | S r;   )r%   r(   r)   r   r<   r0   s     r   normalize_legacy_httpx_timeoutrA   L   s<    !#Fj?v~~000Lr   c                t    t               }|+t        |       |j                  u rt        j                         S | S r'   )r%   typer   r)   r0   s     r   normalize_httpx2_authrD   S   s0    !#Fd5kV[[8{{}Lr   c                t    t               }|+t        |       t        j                  u r|j                         S | S r'   )r%   rC   r)   r   r0   s     r   normalize_legacy_httpx_authrF   Z   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_exceptionsrH   a   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   status_exceptionsrJ   f   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_exceptionsrL   k   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_exceptionsrO   p   rM   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)   rS   rT   rU   
setdefault)kwargsrR   r$   s      r   _set_httpx2_defaultsrY   u   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   )rY   r)   r   rX   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   )rY   r)   r   r[   s    r   DefaultAsyncHttpx2Clientr^      s     '''r   )returnz_LegacyHttpxModule | None)r+   objectr_   bool)r+   zstr | httpx2.URLr_   z
httpx2.URL)r_   z!tuple[type[httpx2.Response], ...])r+   float | httpx2.Timeout | Noner_   rb   )r+   httpx2.Authr_   rc   )r_   z)tuple[type[httpx2.TimeoutException], ...])r_   z(tuple[type[httpx2.HTTPStatusError], ...])r_   z'tuple[type[httpx2.StreamConsumed], ...])r_   z'tuple[type[httpx2.RequestNotRead], ...])rX   zdict[str, Any]r_   None)rX   r   r_   zhttpx2.Client)rX   r   r_   zhttpx2.AsyncClient)
__future__r   r    typingr   r   r   r)   
_constantsr   r	   r   r%   r,   r.   r1   r3   r7   r9   r=   r?   rA   rD   rF   rH   rJ   rL   rO   rY   r\   r^   r   r   r   <module>rh      s    " 
 & &  B0 0L
,1C
H
	X
*p
m
j
j
0#(r   