
    Zǻi                        d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZ 	 d dlZ G d de      Zy# e$ r dZY w xY w)	    )annotations)AnyOptional)Embedder)EmbeddingsGenerationError)RateLimitHandlerrate_limit_handlerNc                  F     e Zd Z	 	 d	 	 	 	 	 	 	 d fdZedd       Z xZS )CohereEmbeddingsc                    t         t        d      t        |   |       || _        t        j
                  di || _        y )NzuCould not import cohere python client.
                Please install it with `pip install "neo4j-graphrag[cohere]"`. )cohereImportErrorsuper__init__modelClientclient)selfr   r	   kwargs	__class__s       ^/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j_graphrag/embeddings/cohere.pyr   zCohereEmbeddings.__init__   sG     >R  	+,
mm-f-    c                    	  | j                   j                  d|g| j                  d|}|j                  d   S # t        $ r}t        d|       |d }~ww xY w)N)textsr   r   z*Failed to generate embedding with Cohere: r   )r   embedr   
embeddings	Exceptionr   )r   textr   responsees        r   embed_queryzCohereEmbeddings.embed_query-   su    
	(t{{(( fjj H
 &&q)) 	+<QC@	s   8; 	AAA) N)r   strr	   zOptional[RateLimitHandler]r   r   returnNone)r   r$   r   r   r%   zlist[float])__name__
__module____qualname__r   r	   r"   __classcell__)r   s   @r   r   r      sJ     9=.. 7. 	.
 
.  r   r   )
__future__r   typingr   r   neo4j_graphrag.embeddings.baser   neo4j_graphrag.exceptionsr   neo4j_graphrag.utils.rate_limitr   r	   r   r   r   r   r   r   <module>r0      s@    #   3 ? P
x 	  Fs   4 >>