
    dh	                        S SK Jr  S SKJrJrJr  S SKJrJr  S SK	J
r
Jr  S SKJr  S SKJrJr   " S S\
5      r " S	 S
\5      rg)    )annotations)AnyOptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)	BaseModelmodel_validator)BaseBrowserTool)aget_current_pageget_current_pagec                      \ rS rSrSrSrg)ExtractTextToolInput   z+Explicit no-args input for ExtractTextTool. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       i/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/playwright/extract_text.pyr   r      s    5r   r   c                      \ rS rSr% SrSrS\S'   SrS\S'   \r	S\S	'   \
" S
S9\SS j5       5       rSSS jjr S   SS jjrSrg)ExtractTextTool   z8Tool for extracting all the text on the current webpage.extract_textstrnamez+Extract all the text on the current webpagedescriptionzType[BaseModel]args_schemabefore)modec                F     SSK Jn  U$ ! [         a    [        S5      ef = f)z#Check that the arguments are valid.r   BeautifulSoupzoThe 'beautifulsoup4' package is required to use this tool. Please install it with 'pip install beautifulsoup4'.)bs4r&   ImportError)clsvaluesr&   s      r   check_acheck_bs_importrgs)ExtractTextTool.check_acheck_bs_importrgs   s5    	)   	H 	s   
  Nc                    SSK Jn  U R                  c  [        SU R                   35      e[        U R                  5      nUR                  5       nU" US5      nSR                  S UR                   5       5      $ )Use the tool.r   r%   z$Synchronous browser not provided to lxml c              3  "   #    U H  ov   M     g 7fNr   .0texts     r   	<genexpr>'ExtractTextTool._run.<locals>.<genexpr>8        ?)>)>   )	r'   r&   sync_browser
ValueErrorr   r   contentjoinstripped_stringsselfrun_managerr&   pagehtml_contentsoups         r   _runExtractTextTool._run*   sn     	&$CDII;OPP 1 12||~ \62xx?)>)>???r   c                (  #    U R                   c  [        SU R                   35      eSSKJn  [        U R                   5      I Sh  vN nUR                  5       I Sh  vN nU" US5      nSR                  S UR                   5       5      $  NG N17f)r.   Nz%Asynchronous browser not provided to r   r%   r/   r0   c              3  "   #    U H  ov   M     g 7fr2   r   r3   s     r   r6   (ExtractTextTool._arun.<locals>.<genexpr>I   r8   r9   )	async_browserr;   r   r'   r&   r   r<   r=   r>   r?   s         r   _arunExtractTextTool._arun:   s      %DTYYKPQQ%&t'9'9::!\\^+ \62xx?)>)>??? ;+s$   ABBBB0BBr   )r*   dictreturnr   r2   )rA   z#Optional[CallbackManagerForToolRun]rN   r   )rA   z(Optional[AsyncCallbackManagerForToolRun]rN   r   )r   r   r   r   r   r   __annotations__r    r   r!   r
   classmethodr+   rE   rK   r   r   r   r   r   r      sm    BD#DKD#7K7(#	  $	@" GK@C@	@ @r   r   N)
__future__r   typingr   r   r   langchain_core.callbacksr   r   pydanticr	   r
   )langchain_community.tools.playwright.baser   *langchain_community.tools.playwright.utilsr   r   r   r   r   r   r   <module>rW      s:    " & & 0 E69 63@o 3@r   