Ë
    µŒjM	  ã                   óX   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  G d„ dee	«      Z
y)	é    )ÚList)ÚCallbackManagerForRetrieverRun)ÚDocument)ÚBaseRetriever)ÚWikipediaAPIWrapperc                   ó*   — e Zd ZdZdededee   fd„Zy)ÚWikipediaRetrieveru:  `Wikipedia API` retriever.

    Setup:
        Install the ``wikipedia`` dependency:

        .. code-block:: bash

            pip install -U wikipedia

    Instantiate:
        .. code-block:: python

            from langchain_community.retrievers import WikipediaRetriever

            retriever = WikipediaRetriever()

    Usage:
        .. code-block:: python

            docs = retriever.invoke("TOKYO GHOUL")
            print(docs[0].page_content[:100])

        .. code-block:: none

            Tokyo Ghoul (Japanese: æ�±äº¬å–°ç¨®ï¼ˆãƒˆãƒ¼ã‚­ãƒ§ãƒ¼ã‚°ãƒ¼ãƒ«ï¼‰, Hepburn: TÅ�kyÅ� GÅ«ru) is a Japanese dark fantasy

    Use within a chain:
        .. code-block:: python

            from langchain_core.output_parsers import StrOutputParser
            from langchain_core.prompts import ChatPromptTemplate
            from langchain_core.runnables import RunnablePassthrough
            from langchain_openai import ChatOpenAI

            prompt = ChatPromptTemplate.from_template(
                """Answer the question based only on the context provided.

            Context: {context}

            Question: {question}"""
            )

            llm = ChatOpenAI(model="gpt-3.5-turbo-0125")

            def format_docs(docs):
                return "\n\n".join(doc.page_content for doc in docs)

            chain = (
                {"context": retriever | format_docs, "question": RunnablePassthrough()}
                | prompt
                | llm
                | StrOutputParser()
            )

            chain.invoke(
                "Who is the main character in `Tokyo Ghoul` and does he transform into a ghoul?"
            )

        .. code-block:: none

             'The main character in Tokyo Ghoul is Ken Kaneki, who transforms into a ghoul after receiving an organ transplant from a ghoul named Rize.'
    ÚqueryÚrun_managerÚreturnc                ó&   — | j                  |¬«      S )N)r
   )Úload)Úselfr
   r   s      úr/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/retrievers/wikipedia.pyÚ_get_relevant_documentsz*WikipediaRetriever._get_relevant_documentsJ   s   € ð �y‰y˜uˆyÓ%Ð%ó    N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   r   r   © r   r   r	   r	   
   s)   „ ñ=ð~&Øð&Ø*Hð&à	ˆh‰ô&r   r	   N)Útypingr   Úlangchain_core.callbacksr   Úlangchain_core.documentsr   Úlangchain_core.retrieversr   Ú'langchain_community.utilities.wikipediar   r	   r   r   r   Ú<module>r      s%   ðÝ å CÝ -Ý 3å GôC&˜Ð(;õ C&r   