
    Bvh                         d dl mZmZmZ d dlZd dlmZmZ d dl	m
Z
mZ  G d dee         Z G d dee         Ze
 G d	 d
ee                ZddZddZddZy)    )EmbeddingFunction
Embeddable
EmbeddingsN)castAny)register_embedding_functionknown_embedding_functionsc                       e Zd ZdedefdZy)LegacyCustomEmbeddingFunctioninputreturnc                 h    t        t        t        j                  g d      j	                               S N         r   r   nparraytolistselfr   s     I/RAG/venv/lib/python3.12/site-packages/chromadb/test/ef/test_custom_ef.py__call__z&LegacyCustomEmbeddingFunction.__call__   !    J 3 : : <==    N)__name__
__module____qualname__r   r   r    r   r   r   r   
   s    >j >Z >r   r   c                       e Zd ZdedefdZdededdfdZede	fd       Z
ed	ee	ef   dd fd
       Zdee	ef   fdZy)CustomEmbeddingFunctionr   r   c                 h    t        t        t        j                  g d      j	                               S r   r   r   s     r   r   z CustomEmbeddingFunction.__call__   r   r   argskwargsNc                      y Nr!   r   r%   r&   s      r   __init__z CustomEmbeddingFunction.__init__       r   c                       y)Ncustom_embedding_functionr!   r!   r   r   namezCustomEmbeddingFunction.name   s    *r   configc                     t               S r(   )r#   r/   s    r   build_from_configz)CustomEmbeddingFunction.build_from_config   s    &((r   c                     i S r(   r!   r   s    r   
get_configz"CustomEmbeddingFunction.get_config       	r   r   r   r    r   r   r   r   r*   staticmethodstrr.   dictr2   r5   r!   r   r   r#   r#      s    >j >Z >c S T  +# + + )$sCx. )5N ) )DcN r   r#   c                       e Zd ZdedefdZdededdfdZede	fd       Z
ed	ee	ef   dd fd
       Zdee	ef   fdZy)'CustomEmbeddingFunctionWithRegistrationr   r   c                 h    t        t        t        j                  g d      j	                               S r   r   r   s     r   r   z0CustomEmbeddingFunctionWithRegistration.__call__$   r   r   r%   r&   Nc                      y r(   r!   r)   s      r   r*   z0CustomEmbeddingFunctionWithRegistration.__init__'   r+   r   c                       y)N+custom_embedding_function_with_registrationr!   r!   r   r   r.   z,CustomEmbeddingFunctionWithRegistration.name*   s    <r   r/   c                     t               S r(   )r<   r1   s    r   r2   z9CustomEmbeddingFunctionWithRegistration.build_from_config.   s     788r   c                     i S r(   r!   r4   s    r   r5   z2CustomEmbeddingFunctionWithRegistration.get_config4   r6   r   r7   r!   r   r   r<   r<   "   s    >j >Z >c S T  =# = = 9S#X9	29 9
DcN r   r<   c                  j   t               }  | dg      }t        |t              sJ d       t        |      dk(  sJ d       t        |d   t        j
                        sJ d       t	        j                  g dt        j                        }t	        j                  |d   |      sJ d	|d    d
|        y NtestzResult should be a listr   z)Result should contain exactly one elementr   z&Result element should be a NumPy arrayr   )dtypezArrays not equal: z vs )	r   
isinstancelistlenr   ndarrayr   float32array_equalefresultexpecteds      r   test_legacy_custom_efrQ   8   s    	&	(B\F fd#>%>>#v;!HHHfQi,V.VV, xx	4H>>q	8 6	F1I;d8*56 r   c                  j   t               }  | dg      }t        |t              sJ d       t        |      dk(  sJ d       t        |d   t        j
                        sJ d       t	        j                  g dt        j                        }t	        j                  |d   |      sJ d	|d    d
|        y rD   )	r#   rG   rH   rI   r   rJ   r   rK   rL   rM   s      r   test_custom_efrS   H   s    	 	"B\F fd#>%>>#v;!HHHfQi,V.VV,xx	4H>>q	8 6	F1I;d8*56 r   c                  @    dt         vsJ dt         vsJ dt         v sJ y )N legacy_custom_embedding_functionr-   r@   )r	   r!   r   r   test_custom_ef_registrationrV   W   s1     .5NNNN&.GGGG8<UUUUr   )r   N)chromadb.api.typesr   r   r   numpyr   typingr   r   "chromadb.utils.embedding_functionsr   r	   r   r#   r<   rQ   rS   rV   r!   r   r   <module>r[      sk    H H  >$5j$A >
/
; & .?
.K  *6 6Vr   