Ë
    lQêj»  ã                   óp   — d dl mZmZmZmZ d dlmZ d dlmZm	Z	m
Z
 d dlZd dlmZ dZ G d„ dee   «      Zy)	é    )Ú
EmbeddingsÚ	DocumentsÚEmbeddingFunctionÚSpace©Úvalidate_config_schema)ÚListÚDictÚAnyN)Úurlparsezchroma/all-minilm-l6-v2-f32c            	       óú   — e Zd ZdZdedfdedededdfd	„Zd
ede	fd„Z
edefd„«       Zdefd„Zdee   fd„Zedeeef   ddfd„«       Zdeeef   fd„Zdeeef   deeef   ddfd„Zedeeef   ddfd„«       Zy)ÚOllamaEmbeddingFunctionz¸
    This class is used to generate embeddings for a list of texts using the Ollama Embedding API
    (https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings).
    zhttp://localhost:11434é<   ÚurlÚ
model_nameÚtimeoutÚreturnNc                 ó8  — 	 ddl m} || _        || _        || _        || _        | j                  j                  d«      r+t        |«      }|j                  › d|j                  › �| _         || j                  |¬«      | _        y# t        $ r t        d«      ‚w xY w)a¼  
        Initialize the Ollama Embedding Function.

        Args:
            url (str): The Base URL of the Ollama Server (default: "http://localhost:11434").
            model_name (str): The name of the model to use for text embeddings.
                Defaults to "chroma/all-minilm-l6-v2-f32", for available models see https://ollama.com/library.
            timeout (int): The timeout for the API call in seconds. Defaults to 60.
        r   )ÚClientzWThe ollama python package is not installed. Please install it with `pip install ollama`z/api/embeddingsz://)Úhostr   N)Úollamar   ÚImportErrorÚ
ValueErrorr   r   r   Ú	_base_urlÚendswithr   ÚschemeÚnetlocÚ_client)Úselfr   r   r   r   Ú
parsed_urls         ú�/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/chromadb/utils/embedding_functions/ollama_embedding_function.pyÚ__init__z OllamaEmbeddingFunction.__init__   s™   € ð	Ý%ð ˆŒØ$ˆŒØˆŒð ˆŒØ�>‰>×"Ñ"Ð#4Ô5Ü! #›ˆJØ *× 1Ñ 1Ð2°#°j×6GÑ6GÐ5HÐIˆDŒNá 4§>¡>¸7ÔCˆ�øô ò 	ÜØióð ð	ús   ‚B ÂBÚinputc                 óÆ   — | j                   j                  | j                  |¬«      }|d   D �cg c]'  }t        j                  |t        j
                  ¬«      ‘Œ) c}S c c}w )a†  
        Get the embeddings for a list of texts.

        Args:
            input (Documents): A list of texts to get embeddings for.

        Returns:
            Embeddings: The embeddings for the texts.

        Example:
            >>> ollama_ef = OllamaEmbeddingFunction()
            >>> texts = ["Hello, world!", "How are you?"]
            >>> embeddings = ollama_ef(texts)
        )Úmodelr#   Ú
embeddings)Údtype)r   Úembedr   ÚnpÚarrayÚfloat32)r   r#   ÚresponseÚ	embeddings       r!   Ú__call__z OllamaEmbeddingFunction.__call__2   sW   € ð  —<‘<×%Ñ%¨D¯O©OÀ5Ð%ÓIˆð
 & lÑ3ö
àô �H‰H�Y¤b§j¡jÖ1ò
ð 	
ùò 
s   ¯,Ac                   ó   — y)Nr   © r0   ó    r!   ÚnamezOllamaEmbeddingFunction.nameJ   s   € àr1   c                  ó   — y)NÚcosiner0   ©r   s    r!   Údefault_spacez%OllamaEmbeddingFunction.default_spaceN   s   € Ør1   c                 ó
   — g d¢S )N)r4   Úl2Úipr0   r5   s    r!   Úsupported_spacesz(OllamaEmbeddingFunction.supported_spacesQ   s   € Ú%Ð%r1   ÚconfigzEmbeddingFunction[Documents]c                 óž   — | j                  d«      }| j                  d«      }| j                  d«      }|�|�|€J d«       ‚t        |||¬«      S )Nr   r   r   zThis code should not be reached©r   r   r   )Úgetr   )r;   r   r   r   s       r!   Úbuild_from_configz)OllamaEmbeddingFunction.build_from_configT   sT   € à�j‰j˜ÓˆØ—Z‘Z Ó-ˆ
Ø—*‘*˜YÓ'ˆàˆ;˜*Ð,°°Ø;Ð;Ó;�5ä&¨3¸:ÈwÔWÐWr1   c                 óJ   — | j                   | j                  | j                  dœS )Nr=   r=   r5   s    r!   Ú
get_configz"OllamaEmbeddingFunction.get_config_   s   € Ø—x‘x¨t¯©È4Ï<É<ÑXÐXr1   Ú
old_configÚ
new_configc                 ó"   — d|v rt        d«      ‚y )Nr   zSThe model name cannot be changed after the embedding function has been initialized.)r   )r   rB   rC   s      r!   Úvalidate_config_updatez.OllamaEmbeddingFunction.validate_config_updateb   s!   € ð ˜:Ñ%ÜØeóð ð &r1   c                 ó   — t        | d«       y)zÝ
        Validate the configuration using the JSON schema.

        Args:
            config: Configuration to validate

        Raises:
            ValidationError: If the configuration does not match the schema
        r   Nr   )r;   s    r!   Úvalidate_configz'OllamaEmbeddingFunction.validate_configj   s   € ô 	˜v xÕ0r1   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚDEFAULT_MODEL_NAMEÚstrÚintr"   r   r   r.   Ústaticmethodr2   r   r6   r	   r:   r
   r   r?   rA   rE   rG   r0   r1   r!   r   r   
   s)  „ ñð ,Ø,Øñ	 Dàð Dð ð Dð ð	 Dð
 
ó DðD
˜ið 
¨Jó 
ð0 ð�#ò ó ðð˜uó ð& $ u¡+ó &ð ðX $ s¨C x¡.ð XÐ5Sò Xó ðXðY˜D  c ™Nó YðØ˜s C˜x™.ðØ6:¸3À¸8±nðà	óð ð
1  S¨# X¡ð 
1°4ò 
1ó ñ
1r1   r   )Úchromadb.api.typesr   r   r   r   Ú*chromadb.utils.embedding_functions.schemasr   Útypingr	   r
   r   Únumpyr)   Úurllib.parser   rL   r   r0   r1   r!   ú<module>rU      s4   ðß NÓ NÝ Mß "Ñ "Û Ý !à2Ð ôk1Ð/°	Ñ:õ k1r1   