Ë
    µŒj¤  ã                   óV   — d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
  G d„ de«      Zy)é    )ÚAnyÚIteratorÚListÚOptional)ÚDocument)Ú
BaseLoader)ÚArxivAPIWrapperc                   óR   — e Zd ZdZ	 d
dedee   defd„Zde	e
   fd„Zdee
   fd	„Zy)ÚArxivLoaderaö  Load a query result from `Arxiv`.
    The loader converts the original PDF format into the text.

    Setup:
        Install ``arxiv`` and ``PyMuPDF`` packages.
        ``PyMuPDF`` transforms PDF files downloaded from the arxiv.org site
        into the text format.

        .. code-block:: bash

            pip install -U arxiv pymupdf


    Instantiate:
        .. code-block:: python

            from langchain_community.document_loaders import ArxivLoader

            loader = ArxivLoader(
                query="reasoning",
                # load_max_docs=2,
                # load_all_available_meta=False
            )

    Load:
        .. code-block:: python

            docs = loader.load()
            print(docs[0].page_content[:100])
            print(docs[0].metadata)

        .. code-block:: python
            Understanding the Reasoning Ability of Language Models
            From the Perspective of Reasoning Paths Aggre
            {
                'Published': '2024-02-29',
                'Title': 'Understanding the Reasoning Ability of Language Models From the
                        Perspective of Reasoning Paths Aggregation',
                'Authors': 'Xinyi Wang, Alfonso Amayuelas, Kexun Zhang, Liangming Pan,
                        Wenhu Chen, William Yang Wang',
                'Summary': 'Pre-trained language models (LMs) are able to perform complex reasoning
                        without explicit fine-tuning...'
            }


    Lazy load:
        .. code-block:: python

            docs = []
            docs_lazy = loader.lazy_load()

            # async variant:
            # docs_lazy = await loader.alazy_load()

            for doc in docs_lazy:
                docs.append(doc)
            print(docs[0].page_content[:100])
            print(docs[0].metadata)

        .. code-block:: python

            Understanding the Reasoning Ability of Language Models
            From the Perspective of Reasoning Paths Aggre
            {
                'Published': '2024-02-29',
                'Title': 'Understanding the Reasoning Ability of Language Models From the
                        Perspective of Reasoning Paths Aggregation',
                'Authors': 'Xinyi Wang, Alfonso Amayuelas, Kexun Zhang, Liangming Pan,
                        Wenhu Chen, William Yang Wang',
                'Summary': 'Pre-trained language models (LMs) are able to perform complex reasoning
                        without explicit fine-tuning...'
            }

    Async load:
        .. code-block:: python

            docs = await loader.aload()
            print(docs[0].page_content[:100])
            print(docs[0].metadata)

        .. code-block:: python

            Understanding the Reasoning Ability of Language Models
            From the Perspective of Reasoning Paths Aggre
            {
                'Published': '2024-02-29',
                'Title': 'Understanding the Reasoning Ability of Language Models From the
                        Perspective of Reasoning Paths Aggregation',
                'Authors': 'Xinyi Wang, Alfonso Amayuelas, Kexun Zhang, Liangming Pan,
                        Wenhu Chen, William Yang Wang',
                'Summary': 'Pre-trained language models (LMs) are able to perform complex reasoning
                        without explicit fine-tuning...'
            }

    Use summaries of articles as docs:
        .. code-block:: python

            from langchain_community.document_loaders import ArxivLoader

            loader = ArxivLoader(
                query="reasoning"
            )

            docs = loader.get_summaries_as_docs()
            print(docs[0].page_content[:100])
            print(docs[0].metadata)

        .. code-block:: python

            Pre-trained language models (LMs) are able to perform complex reasoning
            without explicit fine-tuning
            {
                'Entry ID': 'http://arxiv.org/abs/2402.03268v2',
                'Published': datetime.date(2024, 2, 29),
                'Title': 'Understanding the Reasoning Ability of Language Models From the
                        Perspective of Reasoning Paths Aggregation',
                'Authors': 'Xinyi Wang, Alfonso Amayuelas, Kexun Zhang, Liangming Pan,
                        Wenhu Chen, William Yang Wang'
            }
    NÚqueryÚdoc_content_chars_maxÚkwargsc                 ó6   — || _         t        dd|i|¤Ž| _        y)a$  Initialize with search query to find documents in the Arxiv.
        Supports all arguments of `ArxivAPIWrapper`.

        Args:
            query: free text which used to find documents in the Arxiv
            doc_content_chars_max: cut limit for the length of a document's content
        r   N© )r   r	   Úclient)Úselfr   r   r   s       út/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/document_loaders/arxiv.pyÚ__init__zArxivLoader.__init__ƒ   s'   € ð ˆŒ
Ü%ñ 
Ø"7ð
Ø;Añ
ˆ�ó    Úreturnc              #   ój   K  — | j                   j                  | j                  «      E d{  –—†  y7 Œ­w)zLazy load Arvix documentsN)r   Ú	lazy_loadr   ©r   s    r   r   zArxivLoader.lazy_load“   s"   è ø€ à—;‘;×(Ñ(¨¯©Ó4×4Ò4ús   ‚)3«1¬3c                 óL   — | j                   j                  | j                  «      S )zBUses papers summaries as documents rather than source Arvix papers)r   Úget_summaries_as_docsr   r   s    r   r   z!ArxivLoader.get_summaries_as_docs—   s   € à�{‰{×0Ñ0°·±Ó<Ð<r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   Úintr   r   r   r   r   r   r   r   r   r   r   r   	   sR   „ ñwðt BFñ
Øð
Ø19¸#±ð
ØQTó
ð 5˜8 HÑ-ó 5ð= t¨H¡~ô =r   r   N)Útypingr   r   r   r   Úlangchain_core.documentsr   Ú)langchain_community.document_loaders.baser   Ú#langchain_community.utilities.arxivr	   r   r   r   r   Ú<module>r&      s"   ðß 0Ó 0å -å @Ý ?ôP=�*õ P=r   