
    _j                         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dS )    )EmbeddingFunction
Embeddable
EmbeddingsN)castAny)register_embedding_functionknown_embedding_functionsc                       e Zd ZdedefdZdS )LegacyCustomEmbeddingFunctioninputreturnc                 x    t          t          t          j        g d                                                    S N         r   r   nparraytolistselfr   s     \/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/chromadb/test/ef/test_custom_ef.py__call__z&LegacyCustomEmbeddingFunction.__call__   ,    J 3 3 : : < <===    N)__name__
__module____qualname__r   r   r    r   r   r   r   
   s6        >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dS )CustomEmbeddingFunctionr   r   c                 x    t          t          t          j        g d                                                    S r   r   r   s     r   r   z CustomEmbeddingFunction.__call__   r   r   argskwargsNc                     d S Nr!   r   r%   r&   s      r   __init__z CustomEmbeddingFunction.__init__       r   c                      dS )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dS )'CustomEmbeddingFunctionWithRegistrationr   r   c                 x    t          t          t          j        g d                                                    S r   r   r   s     r   r   z0CustomEmbeddingFunctionWithRegistration.__call__$   r   r   r%   r&   Nc                     d S r(   r!   r)   s      r   r*   z0CustomEmbeddingFunctionWithRegistration.__init__'   r+   r   c                      dS )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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 9 \9
DcN      r   r<   r   c                     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
|             d S 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R\\F fd##>>%>>>>v;;!HfQi,,VV.VVVV x			444H>q	8  6 65F1I558556 6 6 6 6r   c                     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
|             d S rD   )	r#   rG   rH   rI   r   rJ   r   rK   rL   rM   s      r   test_custom_efrS   H   s    	 	"	"BR\\F fd##>>%>>>>v;;!HfQi,,VV.VVVVx			444H>q	8  6 65F1I558556 6 6 6 6r   c                  H    dt           vsJ dt           vsJ dt           v sJ d S )N legacy_custom_embedding_functionr-   r@   )r	   r!   r   r   test_custom_ef_registrationrV   W   s@     .5NNNNN&.GGGGG8<UUU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[      sX   H H H H H H H H H H                   > > > > >$5j$A > > >
    /
;   &     .?
.K   *6 6 6 6 6 6 6 6V V V V V Vr   