Ë
    µŒj�  ã                   ó°   — d dl Z d dlmZmZmZmZmZ d dlZd dlm	Z	 d dl
mZ d dlmZmZ  e j                  e«      Z e	ddd¬	«       G d
„ dee«      «       Zy)é    N)ÚAnyÚDictÚListÚMappingÚOptional)Ú
deprecated)Ú
Embeddings)Ú	BaseModelÚ
ConfigDictz0.3.1z1.0.0z!langchain_ollama.OllamaEmbeddings)ÚsinceÚremovalÚalternative_importc                   óv  — e Zd ZU dZdZeed<   	 dZeed<   	 dZeed<   	 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<   	 d
Ze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<   	 d
Zee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d<   	 d
Zee   ed<   	 ede ee!f   fd„«       Z"d
Z#ee   ed<   	 ede$ee!f   fd„«       Z% e&dd ¬!«      Z'd"edee   fd#„Z(d"ee   deee      fd$„Z)d%ee   deee      fd&„Z*d'edee   fd(„Z+y
))ÚOllamaEmbeddingsa—  Ollama locally runs large language models.

    To use, follow the instructions at https://ollama.ai/.

    Example:
        .. code-block:: python

            from langchain_community.embeddings import OllamaEmbeddings
            ollama_emb = OllamaEmbeddings(
                model="llama:7b",
            )
            r1 = ollama_emb.embed_documents(
                [
                    "Alpha is the first letter of Greek alphabet",
                    "Beta is the second letter of Greek alphabet",
                ]
            )
            r2 = ollama_emb.embed_query(
                "What is the second letter of Greek alphabet"
            )

    zhttp://localhost:11434Úbase_urlÚllama2Úmodelz	passage: Úembed_instructionzquery: Úquery_instructionNÚmirostatÚmirostat_etaÚmirostat_tauÚnum_ctxÚnum_gpuÚ
num_threadÚrepeat_last_nÚrepeat_penaltyÚtemperatureÚstopÚtfs_zÚtop_kÚtop_pFÚshow_progressÚheadersÚreturnc                 ó@  — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  dœdœS )z.Get the default parameters for calling Ollama.)r   r   r   r   r   r   r   r   r   r   r    r!   r"   )r   Úoptions)r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   ©Úselfs    úo/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/embeddings/ollama.pyÚ_default_paramsz OllamaEmbeddings._default_paramsx   s   € ð —Z‘Zà ŸM™MØ $× 1Ñ 1Ø $× 1Ñ 1ØŸ<™<ØŸ<™<Ø"Ÿo™oØ!%×!3Ñ!3Ø"&×"5Ñ"5Ø#×/Ñ/ØŸ	™	ØŸ™ØŸ™ØŸ™ññ
ð 	
ó    Úmodel_kwargsc                 ó:   — i d| j                   i¥| j                  ¥S )zGet the identifying parameters.r   )r   r+   r(   s    r*   Ú_identifying_paramsz$OllamaEmbeddings._identifying_params‘   s$   € ð A�7˜DŸJ™JÐ'Ð@¨4×+?Ñ+?Ð@Ð@r,   Úforbid© )ÚextraÚprotected_namespacesÚinputc                 ó"  — ddi| j                   xs i ¥}	 t        j                  | j                  › d�|| j                  |dœ| j
                  ¥¬«      }|j                  dk7  r%t        d	|j                  ›d
|j                  ›�«      ‚	 |j                  «       }|d   S # t        j                  j                  $ r}t        d|› �«      ‚d}~ww xY w# t        j                  j                  $ r }t        d|› d|j                  › �«      ‚d}~ww xY w)z¥Process a response from the API.

        Args:
            response: The response from the API.

        Returns:
            The response as a dictionary.
        zContent-Typezapplication/jsonz/api/embeddings)r   Úprompt)r$   Újsonz$Error raised by inference endpoint: NéÈ   z)Error raised by inference API HTTP code: z, Ú	embeddingzError raised by inference API: z.
Response: )r$   ÚrequestsÚpostr   r   r+   Ú
exceptionsÚRequestExceptionÚ
ValueErrorÚstatus_codeÚtextr7   ÚJSONDecodeError)r)   r4   r$   ÚresÚeÚts         r*   Ú_process_emb_responsez&OllamaEmbeddings._process_emb_response˜   s  € ð Ð.ð
à�|‰|Ò!˜rð
ˆð
	IÜ—-‘-Ø—=‘=�/ Ð1ØØ#Ÿz™z°UÑS¸d×>RÑ>RÐSôˆCð �?‰?˜cÒ!Ýà—?“? C§H¢Hð.óð ð	Ø—‘“
ˆAØ�[‘>Ð!øô ×"Ñ"×3Ñ3ò 	IÜÐCÀAÀ3ÐGÓHÐHûð	Iûô ×"Ñ"×2Ñ2ò 	ÜØ1°!°°MÀ#Ç(Á(ÀÐLóð ûð	ús/   –>B Â	C ÂCÂ;C	Ã	CÃDÃ.D	Ä	Dc                 óÖ   — | j                   r	 ddlm}  ||d¬«      }n|}|D �cg c]  }| j                  |«      ‘Œ c}S # t        $ r t        j	                  d«       |}Y ŒAw xY wc c}w )Nr   )Útqdmr   )ÚdesczgUnable to show progress bar because tqdm could not be imported. Please install with `pip install tqdm`.)r#   rG   ÚImportErrorÚloggerÚwarningrE   )r)   r4   rG   Úiter_r6   s        r*   Ú_embedzOllamaEmbeddings._embed¼   su   € Ø×Òð	Ý%á˜UÐ);Ô<‘ð ˆEÙAFÓGÁ°v�×*Ñ*¨6Õ2ÀÑGÐGøô ò Ü—‘ð>ôð ’ðüò Hs   ŽA  ¥A&Á  A#Á"A#Útextsc                 ól   — |D �cg c]  }| j                   › |› �‘Œ }}| j                  |«      }|S c c}w )zÅEmbed documents using an Ollama deployed embedding model.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.
        )r   rM   )r)   rN   r@   Úinstruction_pairsÚ
embeddingss        r*   Úembed_documentsz OllamaEmbeddings.embed_documentsÌ   sF   € ñ LQÓQÉ5À4 × 6Ñ 6Ð7¸°vÒ>È5ÐÐQØ—[‘[Ð!2Ó3ˆ
ØÐùò Rs   …1r@   c                 óP   — | j                   › |› �}| j                  |g«      d   }|S )zªEmbed a query using a Ollama deployed embedding model.

        Args:
            text: The text to embed.

        Returns:
            Embeddings for the text.
        r   )r   rM   )r)   r@   Úinstruction_pairr9   s       r*   Úembed_queryzOllamaEmbeddings.embed_queryÙ   s7   € ð #×4Ñ4Ð5°d°VÐ<ÐØ—K‘KÐ!1Ð 2Ó3°AÑ6ˆ	ØÐr,   ),Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚstrÚ__annotations__r   r   r   r   r   Úintr   Úfloatr   r   r   r   r   r   r   r   r   r    r!   r"   r#   Úboolr$   ÚdictÚpropertyr   r   r+   r-   r   r/   r   Úmodel_configrE   rM   rR   rU   r1   r,   r*   r   r      sP  … ñð. -€HˆcÓ,Ø-Ø€Eˆ3ÓØà(Ð�sÓ(Ø.Ø&Ð�sÓ&Ø.à"€Hˆh�s‰mÓ"ðBð %)€L�(˜5‘/Ó(ð5ð
 %)€L�(˜5‘/Ó(ð%ð "€GˆX�c‰]Ó!ð$ð "€GˆX�c‰]Ó!ð+ð !%€J�˜‘Ó$ðNð
 $(€M�8˜C‘=Ó'ð=ð '+€N�H˜U‘OÓ*ð,ð $(€K�˜%‘Ó'ð=ð !%€Dˆ(�4˜‘9Ñ
Ó$Ø&à!€Eˆ8�E‰?Ó!ðMð  €Eˆ8�C‰=Óð0ð "€Eˆ8�E‰?Ó!ðCð  €M�4ÓØJà"€GˆX�d‰^Ó"ðð
 ð
  c¨3 h¡ò 
ó ð
ð* $(€L�(˜4‘.Ó'Ø"àðA W¨S°#¨XÑ%6ò Aó ðAñ  HÀ2ÔF€Lð"¨3ð "°4¸±;ó "ðHH˜D ™Ið H¨$¨t°E©{Ñ*;ó Hð  T¨#¡Yð °4¸¸U¹Ñ3Dó ð ð ¨¨U©ô r,   r   )ÚloggingÚtypingr   r   r   r   r   r:   Úlangchain_core._api.deprecationr   Úlangchain_core.embeddingsr	   Úpydanticr
   r   Ú	getLoggerrV   rJ   r   r1   r,   r*   Ú<module>rh      sZ   ðÛ ß 5Õ 5ã Ý 6Ý 0ß *à	ˆ×	Ñ	˜8Ó	$€ñ Ø
ØØ:ôô
S�y *ó Sóñ
Sr,   