§
    šŠtjå  ã                   óÊ   — d dl Z d dlmZmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZ d	d
ddddœZ eddd¬¦  «         G d„ de¦  «        ¦   «         ZdS )é    N)ÚAnyÚDictÚListÚMappingÚOptional)Ú
deprecated)ÚCallbackManagerForLLMRun)ÚLLM)Úget_from_dict_or_envÚpre_init)Ú
ConfigDict)Úenforce_stop_tokensÚtranslation_textÚsummary_textÚgenerated_text)ÚtranslationÚsummarizationÚconversationalztext-generationztext2text-generationz0.0.21z1.0z)langchain_huggingface.HuggingFaceEndpoint)ÚremovalÚalternative_importc                   óV  — e Zd ZU dZdZeed<   dZee	         ed<   	 dZ
ee	         ed<   	 dZee         ed<   	 dZee	         ed<    ed¬	¦  «        Zed
edefd„¦   «         Zedee	ef         fd„¦   «         Zede	fd„¦   «         Z	 	 dde	deee	                  dee         dede	f
d„ZdS )ÚHuggingFaceHuba  HuggingFaceHub  models.
    ! This class is deprecated, you should use HuggingFaceEndpoint instead.

    To use, you should have the ``huggingface_hub`` python package installed, and the
    environment variable ``HUGGINGFACEHUB_API_TOKEN`` set with your API token, or pass
    it as a named parameter to the constructor.

    Supports `text-generation`, `text2text-generation`, `conversational`, `translation`,
     and `summarization`.

    Example:
        .. code-block:: python

            from langchain_community.llms import HuggingFaceHub
            hf = HuggingFaceHub(repo_id="gpt2", huggingfacehub_api_token="my-api-key")
    NÚclientÚrepo_idÚtaskÚmodel_kwargsÚhuggingfacehub_api_tokenÚforbid)ÚextraÚvaluesÚreturnc                 ó´  — t          |dd¦  «        }	 ddlm}m} |d         } |||¬¦  «        }|d         s;|st	          d¦  «        ‚ ||¬	¦  «                             |¬
¦  «        }|j        |d<   |d         t          vr3t	          d|d         › dt                               ¦   «         › d�¦  «        ‚||d<   n# t          $ r t          d¦  «        ‚w xY w|S )z?Validate that api key and python package exists in environment.r   ÚHUGGINGFACEHUB_API_TOKENr   )ÚHfApiÚInferenceClientr   )ÚmodelÚtokenr   z1Must specify either `repo_id` or `task`, or both.)r'   )r   zGot invalid task z, currently only z are supportedr   zfCould not import huggingface_hub python package. Please install it with `pip install huggingface_hub`.)
r   Úhuggingface_hubr$   r%   Ú
ValueErrorÚ
model_infoÚpipeline_tagÚVALID_TASKS_DICTÚkeysÚImportError)Úclsr    r   r$   r%   r   r   r*   s           úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/llms/huggingface_hub.pyÚvalidate_environmentz#HuggingFaceHub.validate_environment?   sk  € õ $8ØÐ.Ð0Jñ$
ô $
Ð ð	Ø>Ð>Ð>Ð>Ð>Ð>Ð>Ð>à˜YÔ'ˆGØ$�_ØØ.ðñ ô ˆFð ˜&”>ð 	9Øð Ý$ØKñô ð ð #˜UÐ)AÐBÑBÔB×MÒMØ#ð Nñ ô �
ð ",Ô!8��v‘Ø�fŒ~Õ%5Ð5Ð5Ý ðN¨¨v¬ð Nð NÝ&6×&;Ò&;Ñ&=Ô&=ðNð Nð Nñô ð ð  &ˆF�8ÑÐøÝð 	ð 	ð 	ÝðHñô ð ð	øøøð
 ˆs   “B'B; Â;Cc                 ó>   — | j         pi }i | j        | j        dœ¥d|i¥S )zGet the identifying parameters.)r   r   r   )r   r   r   )ÚselfÚ_model_kwargss     r0   Ú_identifying_paramsz"HuggingFaceHub._identifying_paramsd   s<   € ð Ô)Ð/¨Rˆð
Øœ,°´	Ð:Ð:ð
à˜}Ð-ð
ð 	
ó    c                 ó   — dS )zReturn type of llm.r(   © )r3   s    r0   Ú	_llm_typezHuggingFaceHub._llm_typem   s
   € ð !Ð r6   ÚpromptÚstopÚrun_managerÚkwargsc                 ó�  — | j         pi }i |¥|¥}| j                             ||dœ| j        ¬¦  «        }t	          j        |                     ¦   «         ¦  «        }d|v rt          d|d         › �¦  «        ‚t          | j                 }t          |t          ¦  «        r|d         |         }	n||         }	|�t          |	|¦  «        }	|	S )an  Call out to HuggingFace Hub's inference endpoint.

        Args:
            prompt: The prompt to pass into the model.
            stop: Optional list of stop words to use when generating.

        Returns:
            The string generated by the model.

        Example:
            .. code-block:: python

                response = hf("Tell me a joke.")
        )ÚinputsÚ
parameters)Újsonr   ÚerrorzError raised by inference API: r   )r   r   Úpostr   rA   ÚloadsÚdecoder)   r,   Ú
isinstanceÚlistr   )
r3   r:   r;   r<   r=   r4   r@   ÚresponseÚresponse_keyÚtexts
             r0   Ú_callzHuggingFaceHub._callr   sá   € ð* Ô)Ð/¨RˆØ0˜Ð0¨Ð0ˆ
à”;×#Ò#Ø"°*Ð=Ð=ÀDÄIð $ñ 
ô 
ˆõ ”:˜hŸošoÑ/Ô/Ñ0Ô0ˆØ�hÐÐÝÐR¸xÈÔ?PÐRÐRÑSÔSÐSå'¨¬	Ô2ˆÝ�h¥Ñ%Ô%ð 	*Ø˜A”;˜|Ô,ˆDˆDà˜LÔ)ˆDàÐõ ' t¨TÑ2Ô2ˆDØˆr6   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   Ústrr   r   Údictr   r   Úmodel_configr   r   r1   Úpropertyr   r5   r9   r   r	   rK   r8   r6   r0   r   r      s’  € € € € € € ðð ð" €FˆCÐÐÑØ!€GˆX�cŒ]Ð!Ð!Ñ!ðLà€Dˆ(�3Œ-ÐÐÑðð $(€L�(˜4”.Ð'Ð'Ñ'Ø1à.2Ð˜h sœmÐ2Ð2Ñ2à�:Øðñ ô €Lð ð"¨$ð "°4ð "ð "ð "ñ „Xð"ðH ð
 W¨S°#¨XÔ%6ð 
ð 
ð 
ñ „Xð
ð ð!˜3ð !ð !ð !ñ „Xð!ð %)Ø:>ð	)ð )àð)ð �t˜C”yÔ!ð)ð Ð6Ô7ð	)ð
 ð)ð 
ð)ð )ð )ð )ð )ð )r6   r   )rA   Útypingr   r   r   r   r   Úlangchain_core._api.deprecationr   Úlangchain_core.callbacksr	   Ú#langchain_core.language_models.llmsr
   Úlangchain_core.utilsr   r   Úpydanticr   Úlangchain_community.llms.utilsr   r,   r   r8   r6   r0   ú<module>r\      s/  ðØ €€€Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø =Ð =Ð =Ð =Ð =Ð =Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø Ð Ð Ð Ð Ð à >Ð >Ð >Ð >Ð >Ð >ð
 &Ø#Ø&Ø'Ø,ðð Ð ð €ØØØBðñ ô ð
ð ð ð ð �Sñ ô ñô ð
ð ð r6   