
    dhb                        S r SSKJr  SSKJrJrJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJrJrJr  SSKJr  S	S
0r " S S\5      rg)z<Chain that hits a URL and then uses an LLM to parse results.    )annotations)AnyDictListOptional)LLMChain)Chain)CallbackManagerForChainRun)
ConfigDictFieldmodel_validator)TextRequestsWrapperz
User-AgentzrMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36c                      \ rS rSr% SrS\S'   \" S SS9rS\S	'   S
rS\S'   Sr	S\S'   Sr
S\S'   SrS\S'   \" SSS9r\SS j5       r\SS j5       r\" SS9\S S j5       5       r S!     S"S jjr\S#S j5       rSrg)$LLMRequestsChain   aJ  Chain that requests a URL and then uses an LLM to parse results.

**Security Note**: This chain can make GET requests to arbitrary URLs,
    including internal URLs.

    Control access to who can run this chain and what network access
    this chain has.

    See https://python.langchain.com/docs/security for more information.
r   	llm_chainc                     [        [        S9$ )N)headers)r   DEFAULT_HEADERS     _/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/chains/llm_requests.py<lambda>LLMRequestsChain.<lambda>!   s
     3O Lr   T)default_factoryexcluder   requests_wrapperi@  inttext_lengthrequests_resultstrrequests_keyurl	input_keyoutput
output_keyforbid)arbitrary_types_allowedextrac                    U R                   /$ )z:Will be whatever keys the prompt expects.

:meta private:
)r$   selfs    r   
input_keysLLMRequestsChain.input_keys.   s     r   c                    U R                   /$ )z-Will always return text key.

:meta private:
)r&   r+   s    r   output_keysLLMRequestsChain.output_keys6   s       r   before)modec                F     SSK Jn  U$ ! [         a    [        S5      ef = f)z?Validate that api key and python package exists in environment.r   BeautifulSoupzNCould not import bs4 python package. Please install it with `pip install bs4`.)bs4r6   ImportError)clsvaluesr6   s      r   validate_environment%LLMRequestsChain.validate_environment>   s4    	)   	< 	s   
  Nc                   SSK Jn  U=(       d    [        R                  " 5       nUR	                  5        VVs0 sH  u  pVXPR
                  :w  d  M  XV_M     nnnXR
                     nU R                  R                  U5      n	U" U	S5      n
U
R                  5       S U R                   XpR                  '   U R                  R                  " SSUR                  5       0UD6nU R                  U0$ s  snnf )Nr   r5   zhtml.parser	callbacksr   )r7   r6   r
   get_noop_manageritemsr$   r   getget_textr   r"   r   predict	get_childr&   )r,   inputsrun_managerr6   _run_managerkv
other_keysr#   ressoupresults               r   _callLLMRequestsChain._callL   s    
 	&"S&@&Q&Q&S'-||~M~tqnn9Ldad~
M^^$##'',S-0(,8J$:J:J(K
$$%'' 
",,.
2<
 (( Ns   C.C.c                    g)Nllm_requests_chainr   r+   s    r   _chain_typeLLMRequestsChain._chain_type`   s    #r   r   )returnz	List[str])r:   r   rT   r   )N)rE   Dict[str, Any]rF   z$Optional[CallbackManagerForChainRun]rT   rU   )rT   r!   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r"   r$   r&   r   model_configpropertyr-   r0   r   classmethodr;   rN   rR   __static_attributes__r   r   r   r   r      s    	 ,1L-)  K)L#)IsJ $L
     ! ! (#
  $
 =A)) :) 
	)( $ $r   r   N)rZ   
__future__r   typingr   r   r   r   langchain.chainsr   langchain.chains.baser	   langchain_core.callbacksr
   pydanticr   r   r   &langchain_community.utilities.requestsr   r   r   r   r   r   <module>rg      sC    B " , , % ' ? 7 7 F   G
O$u O$r   