
    dhE$                         S r SSKJr  SSKJrJrJrJrJrJ	r	  SSK
r
SSKrSSKJrJr  SSKJr   " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      r\rg)z@Lightweight wrapper around requests library, with async support.    )asynccontextmanager)AnyAsyncGeneratorDictLiteralOptionalUnionN)	BaseModel
ConfigDict)Responsec                   4   \ rS rSr% SrSr\\\\4      \	S'   Sr
\\R                     \	S'   Sr\\   \	S'   Sr\\   \	S'   \" SS	S
9rS\S\S\R(                  4S jrS\S\\\4   S\S\R(                  4S jrS\S\\\4   S\S\R(                  4S jrS\S\\\4   S\S\R(                  4S jrS\S\S\R(                  4S jr\S\S\S\S\\R8                  S4   4S j5       r\S\S\S\\R8                  S4   4S j5       r\S\S\\\4   S\S\\R8                  S4   4S j5       r\S\S\\\4   S\S\\R8                  S4   4S j5       r \S\S\\\4   S\S\\R8                  S4   4S j5       r!\S\S\S\\R8                  S4   4S j5       r"Sr#g)Requests   zWrapper around requests to handle auth and async.

The main purpose of this wrapper is to handle authentication (by saving
headers) and enable easy async methods on the same base object.
Nheaders
aiosessionauthTverifyforbidarbitrary_types_allowedextraurlkwargsreturnc                 t    [         R                  " U4U R                  U R                  U R                  S.UD6$ ) GET the URL and return the text.r   r   r   )requestsgetr   r   r   selfr   r   s      ^/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/utilities/requests.pyr   Requests.get   s6    ||
DIIdkk
MS
 	
    datac                 v    [         R                  " U4UU R                  U R                  U R                  S.UD6$ )$POST to the URL and return the text.jsonr   r   r   )r   postr   r   r   r!   r   r%   r   s       r"   r*   Requests.post#   s=    }}
LL;;
 
 	
r$   c                 v    [         R                  " U4UU R                  U R                  U R                  S.UD6$ )"PATCH the URL and return the text.r(   )r   patchr   r   r   r+   s       r"   r/   Requests.patch.   s=    ~~
LL;;
 
 	
r$   c                 v    [         R                  " U4UU R                  U R                  U R                  S.UD6$ ) PUT the URL and return the text.r(   )r   putr   r   r   r+   s       r"   r3   Requests.put9   s=    ||
LL;;
 
 	
r$   c                 t    [         R                  " U4U R                  U R                  U R                  S.UD6$ )#DELETE the URL and return the text.r   )r   deleter   r   r   r    s      r"   r7   Requests.deleteD   s6    
DIIdkk
MS
 	
r$   methodc                x  #    U R                   (       dx  [        R                  " 5        ISh  vN nUR                  " UU4U R                  U R
                  S.UD6 ISh  vN nU7v   SSS5      ISh  vN   SSS5      ISh  vN   gU R                   R                  " UU4U R                  U R
                  S.UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N Nm! , ISh  vN  (       d  f       N= f Ny! , ISh  vN  (       d  f       g= f NV NC! , ISh  vN  (       d  f       g= f7f)zMake an async request.N)r   r   )r   aiohttpClientSessionrequestr   r   )r!   r9   r   r   sessionresponses         r"   	_arequestRequests._arequestJ   s    
 ,,..'"?? !LL	
   "N  /.. .. YY	
      /    /...   s   +D:C D:0D!C""D%C&+D6C$7D;D:D >D:DD:	D D:DD:"D$D&C=	,C/-C=	9D D:DD	DD:D: D7&D)'D73D:c                   #    U R                   " SU40 UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N! , ISh  vN  (       d  f       g= f7f)/GET the URL and return the text asynchronously.GETNr@   r!   r   r   r?   s       r"   agetRequests.agetc   s8     
 >>%7778N 877777<   A6A:A8AAA AAAc                   #    U R                   " SU4SU0UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N! , ISh  vN  (       d  f       g= f7f)3POST to the URL and return the text asynchronously.POSTr)   NrE   r!   r   r%   r   r?   s        r"   apostRequests.apostk   s>     
 >>&#CDCFCCxN DCCCCC<   A8A<A:AAAAAAc                   #    U R                   " SU4SU0UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N! , ISh  vN  (       d  f       g= f7f)1PATCH the URL and return the text asynchronously.PATCHr)   NrE   rM   s        r"   apatchRequests.apatchs   s>     
 >>'3DTDVDDN EDDDDDrP   c                   #    U R                   " SU4SU0UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N! , ISh  vN  (       d  f       g= f7f)/PUT the URL and return the text asynchronously.PUTr)   NrE   rM   s        r"   aputRequests.aput{   s>     
 >>%B4B6BBhN CBBBBBrP   c                   #    U R                   " SU40 UD6 ISh  vN nU7v   SSS5      ISh  vN   g N N! , ISh  vN  (       d  f       g= f7f)2DELETE the URL and return the text asynchronously.DELETENrE   rF   s       r"   adeleteRequests.adelete   s8     
 >>(C:6::hN ;:::::rI    )$__name__
__module____qualname____firstlineno____doc__r   r   r   str__annotations__r   r;   r<   r   r   r   boolr   model_configr   r   r   r*   r/   r3   r7   r   r   ClientResponser@   rG   rN   rT   rY   r^   __static_attributes__r`   r$   r"   r   r      s    )-GXd38n%,26J../6D(3-!FHTN! $L

s 
c 
h.?.? 
	
 	
4S> 	
S 	
XEVEV 	
	
 	
DcN 	
c 	
hFWFW 	
	
s 	
$sCx. 	
C 	
HDUDU 	

# 
 
1B1B 
  #/2	..4	5 0 "%	..4	5  "38n8;	..4	5  "38n8;	..4	5  "38n8;	..4	5  "%	..4	5 r$   r   c                      \ rS rSr% SrSr\\\\4      \	S'   Sr
\\R                     \	S'   Sr\\   \	S'   Sr\S   \	S	'   S
r\\	S'   \" S
SS9r\S\4S j5       rS\S\\\\\4   4   4S jrS\R6                  S\\\\\4   4   4S jrS\S\S\\\\\4   4   4S jrS\S\\\4   S\S\\\\\4   4   4S jrS\S\\\4   S\S\\\\\4   4   4S jrS\S\\\4   S\S\\\\\4   4   4S jr S\S\S\\\\\4   4   4S jr!S\S\S\\\\\4   4   4S jr"S\S\\\4   S\S\\\\\4   4   4S jr#S\S\\\4   S\S\\\\\4   4   4S jr$S\S\\\4   S\S\\\\\4   4   4S jr%S\S\S\\\\\4   4   4S jr&S r'g)!GenericRequestsWrapper   z,Lightweight wrapper around requests library.Nr   r   r   textro   r)   response_content_typeTr   r   r   r   c                 j    [        U R                  U R                  U R                  U R                  S9$ )N)r   r   r   r   )r   r   r   r   r   )r!   s    r"   r   GenericRequestsWrapper.requests   s+    LL;;	
 	
r$   r?   c                     U R                   S:X  a  UR                  $ U R                   S:X  a  UR                  5       $ [        SU R                    35      eNro   r)   zInvalid return type: rq   ro   r)   
ValueErrorr!   r?   s     r"   _get_resp_content(GenericRequestsWrapper._get_resp_content   sN    %%/== ''61==?"4T5O5O4PQRRr$   c                    #    U R                   S:X  a  UR                  5       I S h  vN $ U R                   S:X  a  UR                  5       I S h  vN $ [        SU R                    35      e ND N7fru   rv   rx   s     r"   _aget_resp_content)GenericRequestsWrapper._aget_resp_content   sc      %%/!((''61!((4T5O5O4PQRR	 )(s!   $A/A+'A/A-A/-A/r   r   c                 Z    U R                  U R                  R                  " U40 UD65      $ )r   )ry   r   r   r    s      r"   r   GenericRequestsWrapper.get   s'    %%dmm&7&7&Fv&FGGr$   r%   c                 Z    U R                  U R                  R                  " X40 UD65      $ )r'   )ry   r   r*   r+   s       r"   r*   GenericRequestsWrapper.post   s)     %%dmm&8&8&Mf&MNNr$   c                 Z    U R                  U R                  R                  " X40 UD65      $ )r.   )ry   r   r/   r+   s       r"   r/   GenericRequestsWrapper.patch   s)     %%dmm&9&9#&Nv&NOOr$   c                 Z    U R                  U R                  R                  " X40 UD65      $ )r2   )ry   r   r3   r+   s       r"   r3   GenericRequestsWrapper.put   s)     %%dmm&7&7&LV&LMMr$   c                 Z    U R                  U R                  R                  " U40 UD65      $ )r6   )ry   r   r7   r    s      r"   r7   GenericRequestsWrapper.delete   s'    %%dmm&:&:3&I&&IJJr$   c                    #    U R                   R                  " U40 UD6 ISh  vN nU R                  U5      I Sh  vN sSSS5      ISh  vN   $  N. N N	! , ISh  vN  (       d  f       g= f7f)rC   N)r   rG   r|   rF   s       r"   rG   GenericRequestsWrapper.aget   sN     ==%%c4V4400:: 544: 5444T   "A3AA3AAAA3AA3AA3A0A" A0,A3c                    #    U R                   R                  " X40 UD6 ISh  vN nU R                  U5      I Sh  vN sSSS5      ISh  vN   $  N. N N	! , ISh  vN  (       d  f       g= f7f)rK   N)r   rN   r|   rM   s        r"   rN   GenericRequestsWrapper.apost   sP      ==&&s;F;;x00:: <;;: <;;;r   c                    #    U R                   R                  " X40 UD6 ISh  vN nU R                  U5      I Sh  vN sSSS5      ISh  vN   $  N. N N	! , ISh  vN  (       d  f       g= f7f)rR   N)r   rT   r|   rM   s        r"   rT   GenericRequestsWrapper.apatch   sP      ==''<V<<00:: =<<: =<<<r   c                    #    U R                   R                  " X40 UD6 ISh  vN nU R                  U5      I Sh  vN sSSS5      ISh  vN   $  N. N N	! , ISh  vN  (       d  f       g= f7f)rW   N)r   rY   r|   rM   s        r"   rY   GenericRequestsWrapper.aput   sP      ==%%c:6::h00:: ;::: ;:::r   c                    #    U R                   R                  " U40 UD6 ISh  vN nU R                  U5      I Sh  vN sSSS5      ISh  vN   $  N. N N	! , ISh  vN  (       d  f       g= f7f)r\   N)r   r^   r|   rF   s       r"   r^   GenericRequestsWrapper.adelete   sN     ==((777800:: 877: 8777r   r`   )(ra   rb   rc   rd   re   r   r   r   rf   rg   r   r;   r<   r   r   rq   r   r   rh   r   ri   propertyr   r   r   r	   ry   rj   r|   r   r*   r/   r3   r7   rG   rN   rT   rY   r^   rk   r`   r$   r"   rm   rm      s   6(,GXd38n%,26J../6D(3-5;7>2;FD $L
 
( 
 
S( SuS$sCx.=P7Q SS..S	sDcN"	#SHs Hc HeCc3h4G.H HOO"38nO8;O	sDcN"	#OPP"38nP8;P	sDcN"	#PNN"38nN8;N	sDcN"	#NK# K KsDcN7J1K K;c ;S ;U3S#X;N5O ;
;;"38n;8;;	sDcN"	#;;;"38n;8;;	sDcN"	#;;;"38n;8;;	sDcN"	#;; ; ;c4S>>Q8R ;r$   rm   c                   .    \ rS rSr% SrSr\S   \S'   Srg)JsonRequestsWrapper   zLightweight wrapper around requests library, with async support.

The main purpose of this wrapper is to always return a json output.r)   rp   rq   r`   N	ra   rb   rc   rd   re   rq   r   rg   rk   r`   r$   r"   r   r          K 6<7>2;r$   r   c                   .    \ rS rSr% SrSr\S   \S'   Srg)TextRequestsWrapper   zLightweight wrapper around requests library, with async support.

The main purpose of this wrapper is to always return a text output.ro   rp   rq   r`   Nr   r`   r$   r"   r   r      r   r$   r   )re   
contextlibr   typingr   r   r   r   r   r	   r;   r   pydanticr
   r   r   r   rm   r   r   RequestsWrapperr`   r$   r"   <module>r      s\    F * F F   * }y }@`;Y `;F<0 <<0 < &r$   