
    dh                     h    S SK r S SKrS SKJrJr  S SKJr  S SKJ	r	   " S S\	5      r
 " S S\
5      rg)	    N)AnyIterator)Document)
BaseLoaderc                   T    \ rS rSrSrS\S\S\4S jrS\S\4S	 jrS\	\
   4S
 jrSrg)LarkSuiteDocLoader
   z!Load from `LarkSuite` (`FeiShu`).domainaccess_tokendocument_idc                 (    Xl         X l        X0l        g)zInitialize with domain, access_token (tenant / user), and document_id.

Args:
    domain: The domain to load the LarkSuite.
    access_token: The access_token to use.
    document_id: The document_id to load.
N)r
   r   r   )selfr
   r   r   s       f/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/document_loaders/larksuite.py__init__LarkSuiteDocLoader.__init__   s     (&    api_urlreturnc                 :   SSU R                    30n[        R                  R                  XS9n[        R                  R	                  U5       n[
        R                  " UR                  5       R                  5       5      nUsSSS5        $ ! , (       d  f       g= f)z.Get LarkSuite (FeiShu) API response json data.AuthorizationzBearer )headersN)	r   urllibrequestRequesturlopenjsonloadsreaddecode)r   r   r   r   response	json_datas         r   _get_larksuite_api_json_data/LarkSuiteDocLoader._get_larksuite_api_json_data   sq    "gd.?.?-@$AB..(((B^^##G,

8==?#9#9#;<I -,,s   4B
Bc              #     #    U R                    S3nU R                  U SU R                   35      nU R                  U SU R                   S35      nUS   S   nU R                  US   S   S   US   S   S   S	.n[        XES
9v   g7f)z&Lazy load LarkSuite (FeiShu) document.z/open-apis/docx/v1/documents/z/raw_contentdatacontentdocumentrevision_idtitle)r   r)   r*   )page_contentmetadataN)r
   r"   r   r   )r   api_url_prefixmetadata_jsonraw_content_jsontextr,   s         r   	lazy_loadLarkSuiteDocLoader.lazy_load!   s      KK=(DE99a 0 012
  <<a 0 01>
  '	2++(0<]K"6*:6w?

 D<<s   BB	)r   r   r
   N)__name__
__module____qualname____firstlineno____doc__strr   r   r"   r   r   r1   __static_attributes__ r   r   r   r   
   sC    +
's 
'# 
'C 
'C C =8H- =r   r   c                   P   ^  \ rS rSrSrS\S\S\4S jrS\\   4U 4S jjr	S	r
U =r$ )
LarkSuiteWikiLoader3   z&Load from `LarkSuite` (`FeiShu`) wiki.r
   r   wiki_idc                 6    Xl         X l        X0l        SU l        g)zInitialize with domain, access_token (tenant / user), and wiki_id.

Args:
    domain: The domain to load the LarkSuite.
    access_token: The access_token to use.
    wiki_id: The wiki_id to load.
 N)r
   r   r>   r   )r   r
   r   r>   s       r   r   LarkSuiteWikiLoader.__init__6   s     (r   r   c              #      >#    U R                   (       d?  U R                   S3nU R                  U SU R                   35      nUS   S   S   U l         [        TU ]  5        Sh  vN   g N7f)z+Lazy load LarkSuite (FeiShu) wiki document.z"/open-apis/wiki/v2/spaces/get_nodez?token=r&   node	obj_tokenN)r   r
   r"   r>   superr1   )r   wiki_url_prefixwiki_node_info_json	__class__s      r   r1   LarkSuiteWikiLoader.lazy_loadC   sp      !%-OPO"&"C"C"#74<<.9#  36:6B;OD7$&&&s   A"A-%A+&A-)r   r   r
   r>   )r3   r4   r5   r6   r7   r8   r   r   r   r1   r9   __classcell__)rH   s   @r   r<   r<   3   s6    0s #  '8H- ' 'r   r<   )r   urllib.requestr   typingr   r   langchain_core.documentsr   )langchain_community.document_loaders.baser   r   r<   r:   r   r   <module>rO      s.        - @&= &=R', 'r   