
    -`i                     x    d dl mZmZ d dlmZ d dlZd dlZd dlmZ d dl	m
Z  G d d          Z e            ZdS )    )MappingMutableMapping)PathN)	parse_url)__version__c                   ,    e Zd ZdZdddeddf fdZdej        fdZde	j
        fd	Zd
efdZdedeeef         fdZdddddd
edededz  deeef         dz  def
dZddddd
ededz  deeef         dz  defdZdddd
ededz  dedefdZdddd
ededz  dedefdZddd
ededz  defdZddd
ededz  defdZddd
ededz  defdZddd
ededz  defdZddd d
ed!ededz  d"edef
d#Zddd d
ed!ededz  d"edef
d$Z xZS )%HTTPConnectionz#Helper class to send HTTP requests.T)reuse_clientr
   returnNc                r    t                                                       || _        d | _        d | _        d S N)super__init__r
   _sync_client_async_client)selfr
   	__class__s     d/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/connections.pyr   zHTTPConnection.__init__   s7    (59;?    c                 \    | j         | j        st          j                    | _         | j         S r   )r   r
   requestsSessionr   s    r   get_sync_clientzHTTPConnection.get_sync_client   s-    $D,=$ ( 0 2 2D  r   c                 d   K   | j         | j        st          j        d          | _         | j         S )NT)	trust_env)r   r
   aiohttpClientSessionr   s    r   get_async_clientzHTTPConnection.get_async_client!   s6      %T->%!(!6!F!F!FD!!r   urlc                 T    t          |          }|j        dvrt          d          d S )N)httphttpszFInvalid HTTP URL: A valid HTTP URL must have scheme 'http' or 'https'.)r   scheme
ValueError)r   r    
parsed_urls      r   _validate_http_urlz!HTTPConnection._validate_http_url'   s9    s^^
$555X   65r   extrasc                     ddt            i|S )Nz
User-AgentzvLLM/)VLLM_VERSION)r   r(   s     r   _headerszHTTPConnection._headers/   s    4l44???r   F)streamtimeoutextra_headersallow_redirectsr,   r-   r.   r/   c                    |                      |           |                                 }|pi }|                    | | j        di ||||          S )N)headersr,   r-   r/    )r'   r   getr+   )r   r    r,   r-   r.   r/   clients          r   get_responsezHTTPConnection.get_response2   so     	$$$%%''%+zz!DM22M22+  
 
 	
r   )r-   r.   r/   c                   K   |                      |           |                                  d {V }|pi }|                    | | j        di |||          S )N)r1   r-   r/   r2   )r'   r   r3   r+   )r   r    r-   r.   r/   r4   s         r   get_async_responsez!HTTPConnection.get_async_responseH   s       	$$$,,........%+zz!DM22M22+	  
 
 	
r   r-   r/   c                    |                      |||          5 }|                                 |j        cd d d            S # 1 swxY w Y   d S Nr8   )r5   raise_for_statuscontentr   r    r-   r/   rs        r   	get_byteszHTTPConnection.get_bytes\   s     /  
 
 	   9	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                   K   |                      |||           d {V 4 d {V 	 }|                                 |                                 d {V cd d d           d {V  S # 1 d {V swxY w Y   d S r:   )r7   r;   readr=   s        r   async_get_byteszHTTPConnection.async_get_bytesf   s2      00/ 1 
 
 
 
 
 
 
 
 	" 	" 	" 	" 	" 	" 	" 	"   >>>>>>	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   .A))
A36A3r-   c                    |                      ||          5 }|                                 |j        cd d d            S # 1 swxY w Y   d S NrC   )r5   r;   textr   r    r-   r>   s       r   get_textzHTTPConnection.get_textt   s    sG44 	   6	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A  AAc                   K   |                      ||           d {V 4 d {V }|                                 |                                 d {V cd d d           d {V  S # 1 d {V swxY w Y   d S rE   )r7   r;   rF   rG   s       r   async_get_textzHTTPConnection.async_get_textz         00g0FFFFFFFF 	" 	" 	" 	" 	" 	" 	"!   >>>>>>	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"   .A''
A14A1c                    |                      ||          5 }|                                 |                                cd d d            S # 1 swxY w Y   d S rE   )r5   r;   jsonrG   s       r   get_jsonzHTTPConnection.get_json   s    sG44 	   6688	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   (AAAc                   K   |                      ||           d {V 4 d {V }|                                 |                                 d {V cd d d           d {V  S # 1 d {V swxY w Y   d S rE   )r7   r;   rN   rG   s       r   async_get_jsonzHTTPConnection.async_get_json   rK   rL      )r-   
chunk_size	save_pathrS   c                B   |                      ||          5 }|                                 |                    d          5 }|                    |          D ]}|                    |           	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |S NrC   wb)r5   r;   openiter_contentwriter   r    rT   r-   rS   r>   fchunks           r   download_filezHTTPConnection.download_file   s    sG44 	#   %% #^^J77 # #EGGENNNN## # # # # # # # # # # # # # #	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# s5   *B.A=1B=B	BB	BBBc                  K   |                      ||           d {V 4 d {V }|                                 |                    d          5 }|j                            |          2 3 d {V }|                    |           6 	 d d d            n# 1 swxY w Y   d d d           d {V  n# 1 d {V swxY w Y   |S rV   )r7   r;   rX   r<   iter_chunkedrZ   r[   s           r   async_download_filez"HTTPConnection.async_download_file   s      00g0FFFFFFFF 	# 	# 	# 	# 	# 	# 	#!   %% ##$9#9#9*#E#E # # # # # # #%GGENNNN $F#E# # # # # # # # # # # # # # #	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# sA   *B3B+B1B
B3B	B3B	B33
B= B=) __name__
__module____qualname____doc__boolr   r   r   r   r   r   r   strr'   r   r+   floatr   r5   r7   bytesr?   rB   rH   rJ   rO   rQ   r   intr^   ra   __classcell__)r   s   @r   r	   r	      s       --/3 @ @ @ @ @ @ @ @ @ @!!1 ! ! ! !"(= " " " "c    @ @S)A @ @ @ @  $26 $
 
 

 	

 
 sCx(4/
 
 
 
 
4 !%26 $
 
 

 	

 sCx(4/
 
 
 
 
* 48QU  $)DLJN	    !% $" " "" 	"
 " 
" " " " =A   C UT\ S     !%		" 	" 	"	" 		"
 
	" 	" 	" 	" =A   C UT\ S     !%		" 	" 	"	" 		"
 
	" 	" 	" 	"  !%   
   
   , !%   
   
       r   r	   )collections.abcr   r   pathlibr   r   r   urllib3.utilr   vllm.versionr   r*   r	   global_http_connectionr2   r   r   <module>rq      s    4 3 3 3 3 3 3 3         " " " " " " 4 4 4 4 4 4h h h h h h h hV ())  r   