
    7|h                     N    d dl 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)    )IteratorOptional)Document)
BaseLoader)WikipediaAPIWrapperc                   Z    e Zd ZdZ	 	 	 	 ddededee   dee   dee   f
dZde	e
   fd	Zy
)WikipediaLoaderzLoad from `Wikipedia`.

    The hard limit on the length of the query is 300 for now.

    Each wiki page represents one Document.
    querylangload_max_docsload_all_available_metadoc_content_chars_maxc                 J    || _         || _        || _        || _        || _        y)a  
        Initializes a new instance of the WikipediaLoader class.

        Args:
            query (str): The query string to search on Wikipedia.
            lang (str, optional): The language code for the Wikipedia language edition.
                Defaults to "en".
            load_max_docs (int, optional): The maximum number of documents to load.
                Defaults to 100.
            load_all_available_meta (bool, optional): Indicates whether to load all
                available metadata for each document. Defaults to False.
            doc_content_chars_max (int, optional): The maximum number of characters
                for the document content. Defaults to 4000.
        N)r
   r   r   r   r   )selfr
   r   r   r   r   s         m/var/www/html/test/engine/venv/lib/python3.12/site-packages/langchain_community/document_loaders/wikipedia.py__init__zWikipediaLoader.__init__   s*    , 
	*'>$%:"    returnc              #      K   t        | j                  | j                  | j                  | j                        }|j                  | j                        E d{    y7 w)z
        Loads the query result from Wikipedia into a list of Documents.

        Returns:
            A list of Document objects representing the loaded
                Wikipedia pages.
        )r   top_k_resultsr   r   N)r   r   r   r   r   loadr
   )r   clients     r   	lazy_loadzWikipediaLoader.lazy_load-   sL      %,,$($@$@"&"<"<	
 ;;tzz***s   AA AA N)en   Fi  )__name__
__module____qualname____doc__strr   intboolr   r   r   r    r   r   r	   r	   	   sg     ')27/3;; ;  }	;
 "*$;  (};8+8H- +r   r	   N)
typingr   r   langchain_core.documentsr   )langchain_community.document_loaders.baser   'langchain_community.utilities.wikipediar   r	   r#   r   r   <module>r(      s    % - @ G2+j 2+r   