o
    ¨Ýj–  ã                   @  s,  d dl mZ d dlZd dlZd dlmZmZmZ d dlZd dl	Z	ddl
mZmZ G dd„ deƒZdEd
d„ZdFdd„ZdFdd„ZdFdd„ZdFdd„ZdGdd„ZdHdd„ZdIdd „ZdId!d"„ZdId#d$„ZdJd&d'„ZdJd(d)„ZdKd+d,„ZdLd.d/„ZdMd1d2„ZdNd4d5„ZdOd7d8„ZdPd<d=„ZdQd@dA„Z dRdCdD„Z!dS )Sé    )ÚannotationsN)ÚAnyÚProtocolÚcasté   )ÚDEFAULT_TIMEOUTÚDEFAULT_CONNECTION_LIMITSc                   @  sn   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< dS )Ú_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__© r   r   úI/var/www/html/chatgpt/venv/lib/python3.10/site-packages/openai/_httpx2.pyr	      s   
 r	   Úreturnú_LegacyHttpxModule | Nonec                  C  s"   t j d¡} | d urtt| ƒS d S )NZhttpx)ÚsysÚmodulesÚgetr   r	   ©Úmoduler   r   r   Ú_loaded_legacy_httpx   s   r#   ÚvalueÚobjectÚboolc                 C  ó   t | tjƒS ©N)Ú
isinstanceÚhttpx2r   ©r$   r   r   r   Úis_httpx2_sync_client!   ó   r,   c                 C  r'   r(   )r)   r*   r   r+   r   r   r   Úis_httpx2_async_client%   r-   r.   c                 C  ó   t ƒ }|d uot| |jƒS r(   )r#   r)   r   ©r$   r"   r   r   r   Úis_legacy_httpx_sync_client)   ó   r1   c                 C  r/   r(   )r#   r)   r   r0   r   r   r   Úis_legacy_httpx_async_client.   r2   r3   ústr | httpx2.URLú
httpx2.URLc                 C  sF   t | tjƒr| S tƒ }| }|d urt ||jƒrt t|ƒ¡S t | ¡S r(   )r)   r*   r   r#   Ústr)r$   r"   Zlegacy_valuer   r   r   Únormalize_httpx_url3   s   
r7   ú!tuple[type[httpx2.Response], ...]c                  C  ó"   t ƒ } | d u rtjfS tj| jfS r(   )r#   r*   r   r!   r   r   r   Úhttp_response_types?   ó   r:   úfloat | httpx2.Timeout | Nonec                 C  s2   t ƒ }|d urt| |jƒrtjdi |  ¡ ¤ŽS | S ©Nr   )r#   r)   r   r*   Úas_dictr0   r   r   r   Únormalize_httpx_timeoutD   ó   r?   c                 C  s   t | ƒS r(   )r?   r+   r   r   r   Únormalize_httpx2_timeoutK   s   rA   c                 C  s2   t ƒ }|d urt| tjƒr|jdi |  ¡ ¤ŽS | S r=   )r#   r)   r*   r   r>   r0   r   r   r   Únormalize_legacy_httpx_timeoutO   r@   rB   úhttpx2.Authc                 C  s(   t ƒ }|d urt| ƒ|ju rt ¡ S | S r(   )r#   Útyper
   r*   r0   r   r   r   Únormalize_httpx2_authV   ó   rE   c                 C  s(   t ƒ }|d urt| ƒtju r| ¡ S | S r(   )r#   rD   r*   r
   r0   r   r   r   Únormalize_legacy_httpx_auth]   rF   rG   ú)tuple[type[httpx2.TimeoutException], ...]c                  C  r9   r(   )r#   r*   r   r!   r   r   r   Útimeout_exceptionsd   r;   rI   útuple[type[Exception], ...]c                  C  s2   t ƒ } tjtjtjf}| d u r|S g |¢| j‘R S r(   )r#   r*   r   ÚsslÚSSLErrorÚanyioZEndOfStream)r"   Úerrorsr   r   r   Úrequest_exceptionsi   s   rO   ú(tuple[type[httpx2.HTTPStatusError], ...]c                  C  r9   r(   )r#   r*   r   r!   r   r   r   Ústatus_exceptionsp   r;   rQ   ú'tuple[type[httpx2.StreamConsumed], ...]c                  C  r9   r(   )r#   r*   r   r!   r   r   r   Ústream_consumed_exceptionsu   r;   rS   ú'tuple[type[httpx2.RequestNotRead], ...]c                  C  r9   r(   )r#   r*   r   r!   r   r   r   Úrequest_not_read_exceptionsz   r;   rU   Úkwargsúdict[str, Any]ÚNonec                 C  sh   t |  dt¡ƒ| d< |  dt¡}tƒ }|d ur(t||jƒr(tj|j|j	|j
d�}|| d< |  dd¡ d S )NÚtimeoutÚlimits)Úmax_connectionsÚmax_keepalive_connectionsÚkeepalive_expiryZfollow_redirectsT)rA   r    r   r   r#   r)   r   r*   r[   r\   r]   Ú
setdefault)rV   rZ   r"   r   r   r   Ú_set_httpx2_defaults   s   ýr_   r   úhttpx2.Clientc                  K  ó   t | ƒ tjdi | ¤ŽS )z<Create an HTTPX2 client with the SDK's recommended defaults.Nr   )r_   r*   r   ©rV   r   r   r   ÚDefaultHttpx2ClientŽ   ó   rc   úhttpx2.AsyncClientc                  K  ra   )zBCreate an async HTTPX2 client with the SDK's recommended defaults.Nr   )r_   r*   r   rb   r   r   r   ÚDefaultAsyncHttpx2Client”   rd   rf   )r   r   )r$   r%   r   r&   )r$   r4   r   r5   )r   r8   )r$   r<   r   r<   )r$   rC   r   rC   )r   rH   )r   rJ   )r   rP   )r   rR   )r   rT   )rV   rW   r   rX   )rV   r   r   r`   )rV   r   r   re   )"Ú
__future__r   rK   r   Útypingr   r   r   rM   r*   Ú
_constantsr   r   r	   r#   r,   r.   r1   r3   r7   r:   r?   rA   rB   rE   rG   rI   rO   rQ   rS   rU   r_   rc   rf   r   r   r   r   Ú<module>   s8    


















