§
    šŠtjõ  ã                   óF   — d Z ddlmZmZmZ ddlmZ  G d„ de¦  «        ZdS )z+Wrapper around Xinference embedding models.é    )ÚAnyÚListÚOptional)Ú
Embeddingsc                   óÔ   ‡ — e Zd ZU dZeed<   ee         ed<   	 ee         ed<   	 	 ddee         dee         fˆ fd„Zde	e         de	e	e
                  fd	„Zd
ede	e
         fd„Zˆ xZS )ÚXinferenceEmbeddingsaq  Xinference embedding models.

    To use, you should have the xinference library installed:

    .. code-block:: bash

        pip install xinference

    If you're simply using the services provided by Xinference, you can utilize the xinference_client package:

    .. code-block:: bash

        pip install xinference_client

    Check out: https://github.com/xorbitsai/inference
    To run, you need to start a Xinference supervisor on one server and Xinference workers on the other servers.

    Example:
        To start a local instance of Xinference, run

        .. code-block:: bash

           $ xinference

        You can also deploy Xinference in a distributed cluster. Here are the steps:

        Starting the supervisor:

        .. code-block:: bash

           $ xinference-supervisor

        If you're simply using the services provided by Xinference, you can utilize the xinference_client package:

        .. code-block:: bash

            pip install xinference_client

        Starting the worker:

        .. code-block:: bash

           $ xinference-worker

    Then, launch a model using command line interface (CLI).

    Example:

    .. code-block:: bash

       $ xinference launch -n orca -s 3 -q q4_0

    It will return a model UID. Then you can use Xinference Embedding with LangChain.

    Example:

    .. code-block:: python

        from langchain_community.embeddings import XinferenceEmbeddings

        xinference = XinferenceEmbeddings(
            server_url="http://0.0.0.0:9997",
            model_uid = {model_uid} # replace model_uid with the model UID return from launching the model
        )

    ÚclientÚ
server_urlÚ	model_uidNc                 óL  •— 	 ddl m} n:# t          $ r- 	 ddlm} n"# t          $ r}t          d¦  «        |‚d }~ww xY wY nw xY wt	          ¦   «                              ¦   «          |€t          d¦  «        ‚|€t          d¦  «        ‚|| _        || _         ||¦  «        | _	        d S )Nr   )ÚRESTfulClientzƒCould not import RESTfulClient from xinference. Please install it with `pip install xinference` or `pip install xinference_client`.zPlease provide server URLzPlease provide the model UID)
Úxinference.clientr   ÚImportErrorÚxinference_clientÚsuperÚ__init__Ú
ValueErrorr
   r   r	   )Úselfr
   r   r   ÚeÚ	__class__s        €úg/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/embeddings/xinference.pyr   zXinferenceEmbeddings.__init__R   sû   ø€ ð		Ø7Ð7Ð7Ð7Ð7Ð7Ð7øÝð 	ð 	ð 	ðØ;Ð;Ð;Ð;Ð;Ð;Ð;øÝð ð ð Ý!ðYñô ð ðøøøøðøøøð <Ð;ð	øøøõ 	‰Œ×ÒÑÔÐàÐÝÐ8Ñ9Ô9Ð9àÐÝÐ;Ñ<Ô<Ð<à$ˆŒà"ˆŒà#�m JÑ/Ô/ˆŒˆˆs)   ƒ
 Š
A•›Aœ
;¦6¶;»AÁ AÚtextsÚreturnc                 óv   ‡— | j                              | j        ¦  «        Šˆfd„|D ¦   «         }d„ |D ¦   «         S )zµEmbed a list of documents using Xinference.
        Args:
            texts: The list of texts to embed.
        Returns:
            List of embeddings, one for each text.
        c                 ó^   •— g | ])}‰                      |¦  «        d          d         d         ‘Œ*S )Údatar   Ú	embedding)Úcreate_embedding)Ú.0ÚtextÚmodels     €r   ú
<listcomp>z8XinferenceEmbeddings.embed_documents.<locals>.<listcomp>x   sC   ø€ ð 
ð 
ð 
ØEIˆE×"Ò" 4Ñ(Ô(¨Ô0°Ô3°KÔ@ð
ð 
ð 
ó    c                 óR   — g | ]$}t          t          t          |¦  «        ¦  «        ‘Œ%S © )ÚlistÚmapÚfloat)r   r   s     r   r"   z8XinferenceEmbeddings.embed_documents.<locals>.<listcomp>{   s(   € Ð8Ð8Ð8¨••S� ‘]”]Ñ#Ô#Ð8Ð8Ð8r#   )r	   Ú	get_modelr   )r   r   Ú
embeddingsr!   s      @r   Úembed_documentsz$XinferenceEmbeddings.embed_documentsn   sZ   ø€ ð ”×%Ò% d¤nÑ5Ô5ˆð
ð 
ð 
ð 
ØMRð
ñ 
ô 
ˆ
ð 9Ð8¨ZÐ8Ñ8Ô8Ð8r#   r    c                 óÖ   — | j                              | j        ¦  «        }|                     |¦  «        }|d         d         d         }t	          t          t          |¦  «        ¦  «        S )zžEmbed a query of documents using Xinference.
        Args:
            text: The text to embed.
        Returns:
            Embeddings for the text.
        r   r   r   )r	   r)   r   r   r&   r'   r(   )r   r    r!   Úembedding_resr   s        r   Úembed_queryz XinferenceEmbeddings.embed_query}   sZ   € ð ”×%Ò% d¤nÑ5Ô5ˆà×.Ò.¨tÑ4Ô4ˆà! &Ô)¨!Ô,¨[Ô9ˆ	å•C�˜yÑ)Ô)Ñ*Ô*Ð*r#   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   Ústrr   r   r(   r+   r.   Ú__classcell__)r   s   @r   r   r      sö   ø€ € € € € € ðAð AðF €K€K�KØ˜”ÐÐÑØ&Ø˜Œ}ÐÐÑØ#ð LPð0ð 0Ø" 3œ-ð0Ø;CÀC¼=ð0ð 0ð 0ð 0ð 0ð 0ð89 T¨#¤Yð 9°4¸¸U¼Ô3Dð 9ð 9ð 9ð 9ð+ ð +¨¨U¬ð +ð +ð +ð +ð +ð +ð +ð +r#   r   N)r2   Útypingr   r   r   Úlangchain_core.embeddingsr   r   r%   r#   r   ú<module>r8      sy   ðØ 1Ð 1à &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à 0Ð 0Ð 0Ð 0Ð 0Ð 0ðC+ð C+ð C+ð C+ð C+˜:ñ C+ô C+ð C+ð C+ð C+r#   