
    3iq                     t    S SK JrJrJrJr  S SKJr  S SKJrJ	r	J
r
Jr  S SKrS SKrS SKr " S S\\   5      rg)    )EmbeddingFunctionSpace
Embeddings	Documentsvalidate_config_schema)ListDictAnyOptionalNc                   *   \ rS rSrSr     SS\\   S\S\S\\   S\4
S	 jjrS
\	S\
4S jr\S\4S j5       rS\4S jrS\\   4S jr\S\\\4   SS4S j5       rS\\\4   4S jrS\\\4   S\\\4   SS4S jr\S\\\4   SS4S j5       rSrg)VoyageAIEmbeddingFunction	   zW
This class is used to generate embeddings for a list of texts using the VoyageAI API.
Napi_key
model_nameapi_key_env_var
input_type
truncationc                 p    SSK nUb  [        R                  " S[
        5        X0l        U=(       d    [        R                  " U5      U l	        U R                  (       d  [        SU S35      eX l
        X@l        XPl        UR                  U R                  S9U l        g! [         a    [        S5      ef = f)a  
Initialize the VoyageAIEmbeddingFunction.

Args:
    api_key_env_var (str, optional): Environment variable name that contains your API key for the VoyageAI API.
        Defaults to "CHROMA_VOYAGE_API_KEY".
    model_name (str, optional): The name of the model to use for text embeddings.
        Defaults to "voyage-large-2".
    api_key (str, optional): API key for the VoyageAI API. If not provided, will look for it in the environment variable.
    input_type (str, optional): The type of input to use for the VoyageAI API.
        Defaults to None.
    truncation (bool): Whether to truncate the input text.
        Defaults to True.
r   Nz[The voyageai python package is not installed. Please install it with `pip install voyageai`zDirect api_key configuration will not be persisted. Please use environment variables via api_key_env_var for persistent storage.zThe z! environment variable is not set.)r   )voyageaiImportError
ValueErrorwarningswarnDeprecationWarningr   osgetenvr   r   r   r   Client_client)selfr   r   r   r   r   r   s          x/home/james-whalen/.local/lib/python3.13/site-packages/chromadb/utils/embedding_functions/voyageai_embedding_function.py__init__"VoyageAIEmbeddingFunction.__init__   s    ,	 MM_"  /<"))O"<||tO#44UVWW$$$t||<)  	m 	s   B B5inputreturnc                     U R                   R                  UU R                  U R                  U R                  S9nUR
                   Vs/ s H&  n[        R                  " U[        R                  S9PM(     sn$ s  snf )z
Generate embeddings for the given documents.

Args:
    input: Documents to generate embeddings for.

Returns:
    Embeddings for the documents.
)textsmodelr   r   )dtype)	r   embedr   r   r   
embeddingsnparrayfloat32)r    r$   r+   	embeddings       r!   __call__"VoyageAIEmbeddingFunction.__call__<   sp     \\''//	 ( 

 DNCXCX
CXiBHHYbjj1CX
 	
 
s   	-A9c                      g)Nr    r3       r!   nameVoyageAIEmbeddingFunction.nameR   s    r4   c                     g)Ncosiner3   r    s    r!   default_space'VoyageAIEmbeddingFunction.default_spaceV   s    r4   c                 
    / SQ$ )N)r8   l2ipr3   r9   s    r!   supported_spaces*VoyageAIEmbeddingFunction.supported_spacesY   s    %%r4   configzEmbeddingFunction[Documents]c                     U R                  S5      nU R                  S5      nU R                  S5      nU R                  S5      nUb  Uc   S5       e[        UUUUb  US9$ SS9$ )Nr   r   r   r   zThis code should not be reachedTr   r   r   r   )getr   )rA   r   r   r   r   s        r!   build_from_config+VoyageAIEmbeddingFunction.build_from_config\   s     **%67ZZ-
ZZ-
ZZ-
"j&8;;;5(+!!%/%;z	
 	
 BF	
 	
r4   c                 `    U R                   U R                  U R                  U R                  S.$ )NrC   rC   r9   s    r!   
get_config$VoyageAIEmbeddingFunction.get_configm   s*    #33//////	
 	
r4   
old_config
new_configc                 &    SU;   a  [        S5      eg )Nr   zSThe model name cannot be changed after the embedding function has been initialized.)r   )r    rJ   rK   s      r!   validate_config_update0VoyageAIEmbeddingFunction.validate_config_updateu   s!     :%e  &r4   c                     [        U S5        g)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   )rA   s    r!   validate_config)VoyageAIEmbeddingFunction.validate_config}   s     	vz2r4   )r   r   r   r   r   r   )Nzvoyage-large-2CHROMA_VOYAGE_API_KEYNT)__name__
__module____qualname____firstlineno____doc__r   strboolr"   r   r   r0   staticmethodr5   r   r:   r	   r?   r
   r   rE   rH   rM   rP   __static_attributes__r3   r4   r!   r   r   	   s6    "&*6$(,=#,= ,= 	,=
 SM,= ,=\
i 
J 
, #  u &$u+ & 
$sCx. 
5S 
 
 
DcN 
sCx.6:38n	 
3S#X 
34 
3 
3r4   r   )chromadb.api.typesr   r   r   r   *chromadb.utils.embedding_functions.schemasr   typingr	   r
   r   r   r   numpyr,   r   r   r3   r4   r!   <module>r`      s1    N N M , , 	  3 1) < 3r4   