
    3i                     N   S SK JrJr  S SKJrJrJrJrJrJ	r	  S SK
rS SKJr  S SKJrJrJrJrJrJrJrJr  S SKJrJrJr  \ " S S5      5       r\ " S	 S
5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r\ " S S\5      5       r \ " S S\5      5       r!\ " S S\5      5       r"\ " S S\5      5       r#\ " S S\5      5       r$\ " S S\5      5       r%\ " S S\5      5       r&\ " S S \5      5       r'\ " S! S"\5      5       r(\ " S# S$\5      5       r)\ " S% S&\5      5       r* " S' S(5      r+\+" S)5      \+l,        \+" S*5      \+l-        \+" S+5      \+l.        \+" S,5      \+l/        \+" S-5      \+l0        \+r1\ " S. S/5      5       r2\ " S0 S15      5       r3\ " S2 S35      5       r4\ " S4 S55      5       r5\ " S6 S75      5       r6\ " S8 S9\65      5       r7\ " S: S;\65      5       r8\ " S< S=\65      5       r9\ " S> S?\65      5       r:\ " S@ SA\65      5       r;\ " SB SC\65      5       r<\ " SD SE\65      5       r=\ " SF SG\65      5       r>\ " SH SI\65      5       r?\ " SJ SK\65      5       r@\ " SL SM\65      5       rA\ " SN SO\65      5       rB\ " SP SQ5      5       rCg)R    )	dataclassfield)OptionalListDictSetAnyUnionN)NDArray)
EmbeddingsIDsIncludeSparseVectorTYPE_KEYSPARSE_VECTOR_TYPE_VALUEnormalize_embeddingsvalidate_embeddings)
CollectionRequestVersionContextSegmentc                   V    \ rS rSr% \\S'   \\S'   \\S'   \\S'   \S\4S j5       r	Sr
g	)
Scan   
collectionknnmetadatarecordreturnc                 f    [        U R                  R                  U R                  R                  S9$ )N)collection_versionlog_position)r   r   versionr!   selfs    `/home/james-whalen/.local/lib/python3.13/site-packages/chromadb/execution/expression/operator.pyr"   Scan.version   s)    $#6655
 	
     N)__name__
__module____qualname____firstlineno__r   __annotations__r   propertyr   r"   __static_attributes__r(   r'   r%   r   r      s2    	LO
. 
 
r'   r   c                   j    \ rS rSrSrS\\\4   4S jr\	S\\\4   SS 4S j5       r
SS jrSS jrS	rg
)Where'   a  Base class for Where expressions (algebraic data type).

Supports logical operators for combining conditions:
    - AND: where1 & where2
    - OR: where1 | where2

Examples:
    # Simple conditions
    where1 = Key("status") == "active"
    where2 = Key("score") > 0.5

    # Combining with AND
    combined_and = where1 & where2

    # Combining with OR
    combined_or = where1 | where2

    # Complex expressions
    complex_where = (Key("status") == "active") & ((Key("score") > 0.5) | (Key("priority") == "high"))
r   c                     [        S5      e)zCConvert the Where expression to a dictionary for JSON serialization#Subclasses must implement to_dict()NotImplementedErrorr#   s    r%   to_dictWhere.to_dict>       !"GHHr'   datac                 
   [        U [        5      (       d!  [        S[        U 5      R                   35      eU (       d  [        S5      eSU ;   a  [        U S   [        5      (       d$  [        S[        U S   5      R                   35      e[        U S   5      S:X  a  [        S5      e[        U 5      S:  a  [        S5      eU S    Vs/ s H  n[        R                  U5      PM     nn[        U5      S:X  a  US   $ US   nUSS	  H  nX1-  nM	     U$ S
U ;   a  [        U S
   [        5      (       d$  [        S[        U S
   5      R                   35      e[        U S
   5      S:X  a  [        S5      e[        U 5      S:  a  [        S5      eU S
    Vs/ s H  n[        R                  U5      PM     nn[        U5      S:X  a  US   $ US   nUSS	  H  nX1-  nM	     U$ [        U 5      S:w  a  [        S[        U 5       35      e[        [        U R                  5       5      5      u  pE[        U[        5      (       d!  [        S[        U5      R                   35      e[        U[        5      (       Ga  U(       d  [        SU S35      e[        U5      S:w  a  [        SU S35      e[        [        UR                  5       5      5      u  pgUS:X  a  [        U5      U:H  $ US:X  a  [        U5      U:g  $ US:X  a  [        U5      U:  $ US:X  a  [        U5      U:  $ US:X  a  [        U5      U:  $ US:X  a  [        U5      U:*  $ US:X  aP  [        U[        5      (       d!  [        S[        U5      R                   35      e[        U5      R                  U5      $ US:X  aP  [        U[        5      (       d!  [        S[        U5      R                   35      e[        U5      R!                  U5      $ US:X  aP  [        U[        5      (       d!  [        S[        U5      R                   35      e[        U5      R#                  U5      $ US:X  aP  [        U[        5      (       d!  [        S [        U5      R                   35      e[        U5      R%                  U5      $ US!:X  aP  [        U[        5      (       d!  [        S"[        U5      R                   35      e[        U5      R'                  U5      $ US#:X  aP  [        U[        5      (       d!  [        S$[        U5      R                   35      e[        U5      R)                  U5      $ [        S%U 35      e[        U5      U:H  $ s  snf s  snf )&a  Create Where expression from dictionary.

Supports MongoDB-style query operators:
- {"field": "value"} -> Key("field") == "value" (shorthand for equality)
- {"field": {"$eq": value}} -> Key("field") == value
- {"field": {"$ne": value}} -> Key("field") != value
- {"field": {"$gt": value}} -> Key("field") > value
- {"field": {"$gte": value}} -> Key("field") >= value
- {"field": {"$lt": value}} -> Key("field") < value
- {"field": {"$lte": value}} -> Key("field") <= value
- {"field": {"$in": [values]}} -> Key("field").is_in([values])
- {"field": {"$nin": [values]}} -> Key("field").not_in([values])
- {"field": {"$contains": "text"}} -> Key("field").contains("text")
- {"field": {"$not_contains": "text"}} -> Key("field").not_contains("text")
- {"field": {"$regex": "pattern"}} -> Key("field").regex("pattern")
- {"field": {"$not_regex": "pattern"}} -> Key("field").not_regex("pattern")
- {"$and": [conditions]} -> condition1 & condition2 & ...
- {"$or": [conditions]} -> condition1 | condition2 | ...
zExpected dict for Where, got zWhere dict cannot be empty$andz$and must be a list, got r   z$$and requires at least one condition   z:$and cannot be combined with other fields in the same dictN$orz$or must be a list, got z#$or requires at least one conditionz9$or cannot be combined with other fields in the same dictz/Where dict must contain exactly one field, got z!Field name must be a string, got zOperator dict for field 'z' cannot be emptyz#' must contain exactly one operator$eq$ne$gt$gte$lt$lte$inz$in requires a list, got $ninz$nin requires a list, got 	$containsz!$contains requires a string, got $not_containsz%$not_contains requires a string, got $regexz&$regex requires a string pattern, got 
$not_regexz*$not_regex requires a string pattern, got zUnknown operator: )
isinstancedict	TypeErrortyper)   
ValueErrorlistlenr1   	from_dictnextiteritemsstrKeyis_innot_incontainsnot_containsregex	not_regex)r:   c
conditionsresultr   	conditionopvalues           r%   rR   Where.from_dictB   sM   * $%%;DJ<O<O;PQRR9:: T>d6lD11/T&\0B0K0K/LM  4< A% !GHH4y1} P  7;6lCl%//!,lJC:!#!!}$]F^ $Md]d5k400":4U;L;U;U:V WXX4;1$ !FGG4y1} O  7;5kBk%//!,kJB:!#!!}$]F^ $M 4yA~ Ec$i[Q   $D$67EeS))7U8L8L7MN  )T** $3E7:KL  y>Q&$3E7:]^  !ioo&7!89	;u:..5[u:..5[u:--6\u:..5[u:--6\u:..5[%eT22'7U8L8L7MN  u:++E226\%eT22'8e9M9M8NO  u:,,U33;&%eS11'?U@T@T?UV  u:..u55?*%eS11'CDKDXDXCYZ  u:225998^%eS11'DT%[EYEYDZ[  u:++E22<'%eS11'HeI]I]H^_  u://66$'9"%>?? 5zY..S D$ Cs   	U'U,c                 @   [        U [        5      (       aP  [        U[        5      (       a"  [        U R                  UR                  -   5      $ [        U R                  U/-   5      $ [        U[        5      (       a  [        U /UR                  -   5      $ [        X/5      $ )zOverload & operator for AND)rK   Andr_   r$   others     r%   __and__Where.__and__   s     dC  %%%4??U-=-==>>t%011s##v 0 0011D=!!r'   c                 @   [        U [        5      (       aP  [        U[        5      (       a"  [        U R                  UR                  -   5      $ [        U R                  U/-   5      $ [        U[        5      (       a  [        U /UR                  -   5      $ [        X/5      $ )zOverload | operator for OR)rK   Orr_   rg   s     r%   __or__Where.__or__   s     dB%$$$//E,<,<<==doo/00r""tfu///004-  r'   r(   N)rh   r1   r   rf   )rh   r1   r   rl   )r)   r*   r+   r,   __doc__r   rV   r	   r7   staticmethodrR   ri   rm   r/   r(   r'   r%   r1   r1   '   sV    *Ic3h I P/S#X P/7 P/ P/d"!r'   r1   c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)rf      z(Logical AND of multiple where conditionsr_   r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr<   r_   r7   r$   r^   s     r%   r7   And.to_dict   s'    doo>oo>??>   -r(   Nr)   r*   r+   r,   ro   r   r1   r-   r   rV   r	   r7   r/   r(   r'   r%   rf   rf      s%    2U@c3h @r'   rf   c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)rl      z'Logical OR of multiple where conditionsr_   r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr>   rt   ru   s     r%   r7   
Or.to_dict  s'    T__=_		_=>>=rw   r(   Nrx   r(   r'   r%   rl   rl      s#    1U?c3h ?r'   rl   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Eqi  zEquality comparisonkeyrc   r   c                 6    U R                   SU R                  00$ )Nr?   r   rc   r#   s    r%   r7   
Eq.to_dict      5$**-..r'   r(   Nr)   r*   r+   r,   ro   rV   r-   r	   r   r7   r/   r(   r'   r%   r~   r~     s#    	HJ/c3h /r'   r~   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Nei  zNot equal comparisonr   rc   r   c                 6    U R                   SU R                  00$ )Nr@   r   r#   s    r%   r7   
Ne.to_dict  r   r'   r(   Nr   r(   r'   r%   r   r     #    	HJ/c3h /r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Gti  zGreater than comparisonr   rc   r   c                 6    U R                   SU R                  00$ )NrA   r   r#   s    r%   r7   
Gt.to_dict#  r   r'   r(   Nr   r(   r'   r%   r   r     s#    !	HJ/c3h /r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Gtei'  z Greater than or equal comparisonr   rc   r   c                 6    U R                   SU R                  00$ )NrB   r   r#   s    r%   r7   Gte.to_dict.      64::.//r'   r(   Nr   r(   r'   r%   r   r   '  s#    *	HJ0c3h 0r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Lti2  zLess than comparisonr   rc   r   c                 6    U R                   SU R                  00$ )NrC   r   r#   s    r%   r7   
Lt.to_dict9  r   r'   r(   Nr   r(   r'   r%   r   r   2  r   r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Ltei=  zLess than or equal comparisonr   rc   r   c                 6    U R                   SU R                  00$ )NrD   r   r#   s    r%   r7   Lte.to_dictD  r   r'   r(   Nr   r(   r'   r%   r   r   =  s#    '	HJ0c3h 0r'   r   c                   L    \ rS rSr% Sr\\S'   \\   \S'   S\	\\4   4S jr
Srg)	IniH  z"In comparison - value is in a listr   valuesr   c                 6    U R                   SU R                  00$ )NrE   r   r   r#   s    r%   r7   
In.to_dictO  s    5$++.//r'   r(   Nr)   r*   r+   r,   ro   rV   r-   r   r	   r   r7   r/   r(   r'   r%   r   r   H  s(    ,	HI0c3h 0r'   r   c                   L    \ rS rSr% Sr\\S'   \\   \S'   S\	\\4   4S jr
Srg)	NiniS  z*Not in comparison - value is not in a listr   r   r   c                 6    U R                   SU R                  00$ )NrF   r   r#   s    r%   r7   Nin.to_dictZ  s    64;;/00r'   r(   Nr   r(   r'   r%   r   r   S  s(    4	HI1c3h 1r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Containsi^  z(Contains comparison for document contentr   contentr   c                 6    U R                   SU R                  00$ )NrG   r   r   r#   s    r%   r7   Contains.to_dicte  s    ;566r'   r(   Nr)   r*   r+   r,   ro   rV   r-   r   r	   r7   r/   r(   r'   r%   r   r   ^  s#    2	HL7c3h 7r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	NotContainsii  z,Not contains comparison for document contentr   r   r   c                 6    U R                   SU R                  00$ )NrH   r   r#   s    r%   r7   NotContains.to_dictp  s    ?DLL9::r'   r(   Nr   r(   r'   r%   r   r   i  s#    6	HL;c3h ;r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	Regexit  zRegular expression matchingr   patternr   c                 6    U R                   SU R                  00$ )NrI   r   r   r#   s    r%   r7   Regex.to_dict{  s    8T\\233r'   r(   Nr   r(   r'   r%   r   r   t  s#    %	HL4c3h 4r'   r   c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\4   4S jr	Sr
g)	NotRegexi  z$Negative regular expression matchingr   r   r   c                 6    U R                   SU R                  00$ )NrJ   r   r#   s    r%   r7   NotRegex.to_dict  s    <677r'   r(   Nr   r(   r'   r%   r   r     s#    .	HL8c3h 8r'   r   c                   L   \ rS rSr% SrS \S'   S \S'   S \S'   S \S'   S \S'   S\4S	 jrS
\4S jr	S\
S
\4S jrS\
S
\4S jrS\
S
\4S jrS\
S
\4S jrS\
S
\4S jrS\
S
\4S jrS\\
   S
\4S jrS\\
   S
\4S jrS\S
\4S jrS\S
\4S jrS\S
\ 4S jr!S\S
\"4S jr#Sr$g)rW   i  aM  Field proxy for building Where conditions with operator overloading.

The Key class allows for readable field references using either:
1. Predefined constants for special fields: K.EMBEDDING, K.DOCUMENT, K.SCORE, etc.
2. String literals with # prefix for special fields: Key("#embedding")
3. Metadata field names without # prefix: Key("my_metadata_field")

Predefined field constants (special fields with # prefix):
    Key.ID - ID field (equivalent to Key("#id"))
    Key.DOCUMENT - Document field (equivalent to Key("#document"))
    Key.EMBEDDING - Embedding field (equivalent to Key("#embedding"))
    Key.METADATA - Metadata field (equivalent to Key("#metadata"))
    Key.SCORE - Score field (equivalent to Key("#score"))

Note: K is an alias for Key, so you can use K.DOCUMENT or Key.DOCUMENT interchangeably.

Examples:
    # Using predefined keys with K alias for special fields
    from chromadb.execution.expression import K
    K.DOCUMENT.contains("search text")  # Searches document field

    # Custom metadata field names (without # prefix)
    K("status") == "active"  # Metadata field named "status"
    K("category").is_in(["science", "tech"])  # Metadata field named "category"
    K("sparse_embedding")  # Example: metadata field (could store anything)

    # Using with Knn for different fields
    Knn(query=[0.1, 0.2])  # Default: searches "#embedding"
    Knn(query=[0.1, 0.2], key=K.EMBEDDING)  # Explicit: searches "#embedding"
    Knn(query=sparse, key="sparse_embedding")  # Example: searches a metadata field

    # Combining conditions
    (K("status") == "active") & (K.SCORE > 0.5)
IDDOCUMENT	EMBEDDINGMETADATASCOREnamec                     Xl         g )Nr   )r$   r   s     r%   __init__Key.__init__  s    	r'   r   c                 ,    [        U R                  5      $ )z!Make Key hashable for use in sets)hashr   r#   s    r%   __hash__Key.__hash__  s    DIIr'   rc   c                 .    [        U R                  U5      $ )zEquality: Key('field') == value)r~   r   r$   rc   s     r%   __eq__
Key.__eq__      $))U##r'   c                 .    [        U R                  U5      $ )z Not equal: Key('field') != value)r   r   r   s     r%   __ne__
Key.__ne__  r   r'   c                 .    [        U R                  U5      $ )z"Greater than: Key('field') > value)r   r   r   s     r%   __gt__
Key.__gt__  r   r'   c                 .    [        U R                  U5      $ )z,Greater than or equal: Key('field') >= value)r   r   r   s     r%   __ge__
Key.__ge__      499e$$r'   c                 .    [        U R                  U5      $ )zLess than: Key('field') < value)r   r   r   s     r%   __lt__
Key.__lt__  r   r'   c                 .    [        U R                  U5      $ )z)Less than or equal: Key('field') <= value)r   r   r   s     r%   __le__
Key.__le__  r   r'   r   c                 .    [        U R                  U5      $ )z?Check if field value is in list: Key('field').is_in(['a', 'b']))r   r   r$   r   s     r%   rX   	Key.is_in  s    $))V$$r'   c                 .    [        U R                  U5      $ )zDCheck if field value is not in list: Key('field').not_in(['a', 'b']))r   r   r   s     r%   rY   
Key.not_in  s    499f%%r'   r   c                 .    [        U R                  U5      $ )z9Match field against regex: Key('field').regex('^pattern'))r   r   r$   r   s     r%   r\   	Key.regex  s    TYY((r'   c                 .    [        U R                  U5      $ )z@Field should not match regex: Key('field').not_regex('^pattern'))r   r   r   s     r%   r]   Key.not_regex      		7++r'   r   c                 .    [        U R                  U5      $ )z;Check if field contains text: Key('field').contains('text'))r   r   r$   r   s     r%   rZ   Key.contains  r   r'   c                 .    [        U R                  U5      $ )zFCheck if field doesn't contain text: Key('field').not_contains('text'))r   r   r   s     r%   r[   Key.not_contains  s    499g..r'   r   N)%r)   r*   r+   r,   ro   r-   rV   r   intr   r	   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   rX   r   rY   r   r\   r   r]   r   rZ   r   r[   r/   r(   r'   r%   rW   rW     s(   !H 	IOOLS # 
$C $B $$C $B $$C $B $%C %C %$C $B $%C %C %
%DI %" %&T#Y &3 &)S )U ), , ,, , ,/C /K /r'   rW   #id	#document
#embedding	#metadata#scorec                   R    \ rS rSr% Sr\\   \S'   Sr\\	   \S'   Sr
\\	   \S'   Srg)Filteri  Nuser_idswherewhere_documentr(   )r)   r*   r+   r,   r   r   r   r-   r   r	   r   r/   r(   r'   r%   r   r     s,    "Hhsm"E8C=$(NHSM(r'   r   c                   *    \ rS rSr% \\S'   \\S'   Srg)KNNi  
embeddingsfetchr(   N)r)   r*   r+   r,   r   r-   r   r/   r(   r'   r%   r   r     s    Jr'   r   c                   v    \ rS rSr% Sr\\S'   Sr\\   \S'   S\	\
\4   4S jr\S\	\
\4   SS 4S	 j5       rS
rg)Limiti  r   offsetNlimitr   c                 Z    SU R                   0nU R                  b  U R                  US'   U$ )z8Convert the Limit to a dictionary for JSON serializationr   r  r   r  )r$   r`   s     r%   r7   Limit.to_dict  s,    DKK(::!"jjF7Or'   r:   c                 ^   [        U [        5      (       d!  [        S[        U 5      R                   35      eU R                  SS5      n[        U[        5      (       d!  [        S[        U5      R                   35      eUS:  a  [        SU 35      eU R                  S5      nUbJ  [        U[        5      (       d!  [        S[        U5      R                   35      eUS::  a  [        SU 35      eSS1n[        U R                  5       5      U-
  nU(       a  [        S	U 35      e[        XS
9$ )zCreate Limit from dictionary.

Examples:
- {"offset": 10} -> Limit(offset=10)
- {"offset": 10, "limit": 20} -> Limit(offset=10, limit=20)
- {"limit": 20} -> Limit(offset=0, limit=20)
zExpected dict for Limit, got r   r   z%Limit offset must be an integer, got z'Limit offset must be non-negative, got r  z$Limit limit must be an integer, got z"Limit limit must be positive, got zUnexpected keys in Limit dict: r  )rK   rL   rM   rN   r)   getr   rO   setkeysr   )r:   r   r  allowed_keysunexpected_keyss        r%   rR   Limit.from_dict  s,    $%%;DJ<O<O;PQRR(A&&#&&7V8M8M7NO  A:FvhOPP!eS)):4;;O;O:PQ  z #EeW!MNN !'*diik*\9>>OPQQF00r'   r(   )r)   r*   r+   r,   r   r   r-   r  r   r   rV   r	   r7   rp   rR   r/   r(   r'   r%   r   r     sW    FCOE8C=c3h  "1S#X "17 "1 "1r'   r   c                   t    \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S'   Sr
\\S'   \S\4S	 j5       rS
rg)
Projectioni:  Fdocument	embeddingr   rankurir   c                 n   [        5       nU R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R
                  (       a  UR                  S5        U R                  (       a  UR                  S5        U$ )N	documentsr   	metadatas	distancesuris)rP   r  appendr  r   r  r  )r$   includess     r%   includedProjection.includedB  sm    6==OOK(>>OOL)==OOK(99OOK(88OOF#r'   r(   N)r)   r*   r+   r,   r  boolr-   r  r   r  r  r.   r   r  r/   r(   r'   r%   r  r  :  sM    HdItHdD$C'  r'   r  c                      \ rS rSrSrS\\\4   4S jr\	S\\\4   SS 4S j5       r
S\S \\4   SS4S	 jrS\\\4   SS4S
 jrS\S \\4   SS4S jrS\\\4   SS4S jrS\S \\4   SS4S jrS\\\4   SS4S jrS\S \\4   SS4S jrS\\\4   SS4S jrSS jrS S jrS S jrS!S jrS"S jrS\S \\4   SS4S jrS\S \\4   SS4S jrSrg)#RankiS  a  Base class for Rank expressions (algebraic data type).

Supports arithmetic operations for combining rank expressions:
    - Addition: rank1 + rank2, rank + 0.5
    - Subtraction: rank1 - rank2, rank - 0.5
    - Multiplication: rank1 * rank2, rank * 0.8
    - Division: rank1 / rank2, rank / 2.0
    - Negation: -rank
    - Absolute value: abs(rank)

Supports mathematical functions:
    - Exponential: rank.exp()
    - Logarithm: rank.log()
    - Maximum: rank.max(other)
    - Minimum: rank.min(other)

Examples:
    # Weighted combination
    Knn(query=[0.1, 0.2]) * 0.8 + Val(0.5) * 0.2

    # Normalization
    Knn(query=[0.1, 0.2]) / Val(10.0)

    # Clamping
    Knn(query=[0.1, 0.2]).min(1.0).max(0.0)
r   c                     [        S5      e)zCConvert the Score expression to a dictionary for JSON serializationr4   r5   r#   s    r%   r7   Rank.to_dictp  r9   r'   r:   c                    [        U [        5      (       d!  [        S[        U 5      R                   35      eU (       d  [        S5      e[        U 5      S:w  a  [        S[        U 5       35      e[        [        U R                  5       5      5      nUS:X  aL  U S   n[        U[        [        45      (       d!  [        S[        U5      R                   35      e[        U5      $ US:X  GaF  U S   n[        U[        5      (       d!  [        S[        U5      R                   35      eS	U;  a  [        S
5      eUS	   n[        U[        5      (       aP  UR                  [        5      [        :X  a  [         R"                  " U5      nO[        S[         S[         SU 35      e[        U[$        [&        [(        R*                  45      (       a=  [-        U5      nU(       a  [        U5      S:  a  [        S5      e[/        U5        US   nO![        S[        U5      R                   35      eUR                  SS5      n[        U[0        5      (       d!  [        S[        U5      R                   35      eUR                  SS5      n[        U[        5      (       d!  [        S[        U5      R                   35      eUS::  a  [        SU 35      eUR                  SS5      n[        U[2        5      (       d!  [        S[        U5      R                   35      e[5        UUUUR                  S5      US9$ US:X  a  U S   n	[        U	[$        [&        45      (       d!  [        S[        U	5      R                   35      e[        U	5      S:  a  [        S [        U	5       35      eU	 V
s/ s H  n
[6        R#                  U
5      PM     nn
US   nUSS!  H  n
X-   nM	     U$ US":X  a  U S"   n[        U[        5      (       d!  [        S#[        U5      R                   35      eS$U;  d  S%U;  a  [        S&5      e[6        R#                  US$   5      n[6        R#                  US%   5      nX-
  $ US':X  a  U S'   n	[        U	[$        [&        45      (       d!  [        S([        U	5      R                   35      e[        U	5      S:  a  [        S)[        U	5       35      eU	 V
s/ s H  n
[6        R#                  U
5      PM     nn
US   nUSS!  H  n
X-  nM	     U$ US*:X  a  U S*   n[        U[        5      (       d!  [        S+[        U5      R                   35      eS$U;  d  S%U;  a  [        S,5      e[6        R#                  US$   5      n[6        R#                  US%   5      nX-  $ US-:X  aY  U S-   n[        U[        5      (       d!  [        S.[        U5      R                   35      e[9        [6        R#                  U5      5      $ US/:X  a^  U S/   n[        U[        5      (       d!  [        S0[        U5      R                   35      e[6        R#                  U5      R;                  5       $ US1:X  a^  U S1   n[        U[        5      (       d!  [        S2[        U5      R                   35      e[6        R#                  U5      R=                  5       $ US3:X  a  U S3   n	[        U	[$        [&        45      (       d!  [        S4[        U	5      R                   35      e[        U	5      S:  a  [        S5[        U	5       35      eU	 V
s/ s H  n
[6        R#                  U
5      PM     nn
US   nUSS!  H  n
UR?                  U
5      nM     U$ US6:X  a  U S6   n	[        U	[$        [&        45      (       d!  [        S7[        U	5      R                   35      e[        U	5      S:  a  [        S8[        U	5       35      eU	 V
s/ s H  n
[6        R#                  U
5      PM     nn
US   nUSS!  H  n
URA                  U
5      nM     U$ [        S9U 35      es  sn
f s  sn
f s  sn
f s  sn
f ):a  Create Rank expression from dictionary.

Supports operators:
- {"$val": number} -> Val(number)
- {"$knn": {...}} -> Knn(...)
- {"$sum": [ranks]} -> rank1 + rank2 + ...
- {"$sub": {"left": ..., "right": ...}} -> left - right
- {"$mul": [ranks]} -> rank1 * rank2 * ...
- {"$div": {"left": ..., "right": ...}} -> left / right
- {"$abs": rank} -> abs(rank)
- {"$exp": rank} -> rank.exp()
- {"$log": rank} -> rank.log()
- {"$max": [ranks]} -> rank1.max(rank2).max(rank3)...
- {"$min": [ranks]} -> rank1.min(rank2).min(rank3)...
zExpected dict for Rank, got zRank dict cannot be emptyr=   z1Rank dict must contain exactly one operator, got $valz$val requires a number, got $knnz$knn requires a dict, got queryz$knn requires 'query' fieldzExpected dict with z='z', got z)$knn requires exactly one query embeddingr   zB$knn query must be a list, numpy array, or SparseVector dict, got r   r   z$knn key must be a string, got r     z#$knn limit must be an integer, got z!$knn limit must be positive, got return_rankFz($knn return_rank must be a boolean, got default)r#  r   r  r&  r%  $sumz$sum requires a list, got    z$$sum requires at least 2 ranks, got N$subz2$sub requires a dict with 'left' and 'right', got leftrightz'$sub requires 'left' and 'right' fields$mulz$mul requires a list, got z$$mul requires at least 2 ranks, got $divz2$div requires a dict with 'left' and 'right', got z'$div requires 'left' and 'right' fields$absz$abs requires a rank dict, got $expz$exp requires a rank dict, got $logz$log requires a rank dict, got $maxz$max requires a list, got z$$max requires at least 2 ranks, got $minz$min requires a list, got z$$min requires at least 2 ranks, got zUnknown rank operator: )!rK   rL   rM   rN   r)   rO   rQ   rS   rT   r  r   floatValr  r   r   r   rR   rP   tuplenpndarrayr   r   rV   r  Knnr  absexplogmaxmin)r:   rb   rc   knn_datar#  
normalizedr   r  r%  
ranks_datarranksr`   sub_datar*  r+  div_data
child_datas                     r%   rR   Rank.from_dictt  s   " $%%:4:;N;N:OPQQ899t9>CCI;O  $tyy{#$<LEec5\22">tE{?S?S>T UVVu:6\F|Hh--"<T(^=T=T<U VWWh& !>??W%E%&&99X&*BB(2259E %-hZr:R9SSZ[`Zab  ED%#<==1%8
!S_q%8$%PQQ $J/"1  XY]^cYdYmYmXno  ,,ul3Cc3''"A$s)BTBTAU VWWLL"-EeS))9$u+:N:N9OP  z #DUG!LMM",,}e<Kk400>tK?P?Y?Y>Z[   Y/'  6\fJj4-880j1A1J1J0KL  :" :3z?:KL  1;;
1T^^A&
E;1XF12Y M6\F|Hh--HhI`I`Hab  X%)@ !JKK>>(6"23DNN8G#45E<6\fJj4-880j1A1J1J0KL  :" :3z?:KL  1;;
1T^^A&
E;1XF12Y M6\F|Hh--HhI`I`Hab  X%)@ !JKK>>(6"23DNN8G#45E<6\fJj$//5d:6F6O6O5PQ  t~~j1226\fJj$//5d:6F6O6O5PQ  >>*-11336\fJj$//5d:6F6O6O5PQ  >>*-11336\fJj4-880j1A1J1J0KL  :" :3z?:KL  1;;
1T^^A&
E;1XF12YA M6\fJj4-880j1A1J1J0KL  :" :3z?:KL  1;;
1T^^A&
E;1XF12YA M 6rd;<<Y << <l <" <s   !`;a 2a(a
rh   Sumc                    [        U[        [        45      (       a  [        U5      OUn[        U [        5      (       aP  [        U[        5      (       a"  [	        U R
                  UR
                  -   5      $ [	        U R
                  U/-   5      $ [        U[        5      (       a  [	        U /UR
                  -   5      $ [	        X/5      $ )z'Addition: rank1 + rank2 or rank + value)rK   r   r3  r4  rG  rB  r$   rh   
other_ranks      r%   __add__Rank.__add__P      #-ec5\#B#BSZ
dC  *c**4::
(8(8899tzzZL011
C((v
 0 0011D%&&r'   c                     [        U5      U -   $ )zRight addition: value + rankr4  rg   s     r%   __radd__Rank.__radd__\      5zD  r'   Subc                 h    [        U[        [        45      (       a  [        U5      OUn[	        X5      $ )z*Subtraction: rank1 - rank2 or rank - value)rK   r   r3  r4  rS  rI  s      r%   __sub__Rank.__sub__`  (    #-ec5\#B#BSZ
4$$r'   c                 ,    [        [        U5      U 5      $ )zRight subtraction: value - rank)rS  r4  rg   s     r%   __rsub__Rank.__rsub__e      3u:t$$r'   Mulc                    [        U[        [        45      (       a  [        U5      OUn[        U [        5      (       aP  [        U[        5      (       a"  [	        U R
                  UR
                  -   5      $ [	        U R
                  U/-   5      $ [        U[        5      (       a  [	        U /UR
                  -   5      $ [	        X/5      $ )z-Multiplication: rank1 * rank2 or rank * value)rK   r   r3  r4  r\  rB  rI  s      r%   __mul__Rank.__mul__i  rM  r'   c                     [        U5      U -  $ )z"Right multiplication: value * rankrO  rg   s     r%   __rmul__Rank.__rmul__u  rR  r'   Divc                 h    [        U[        [        45      (       a  [        U5      OUn[	        X5      $ )z'Division: rank1 / rank2 or rank / value)rK   r   r3  r4  rc  rI  s      r%   __truediv__Rank.__truediv__y  rW  r'   c                 ,    [        [        U5      U 5      $ )zRight division: value / rank)rc  r4  rg   s     r%   __rtruediv__Rank.__rtruediv__~  r[  r'   c                 .    [        [        S5      U /5      $ )z)Negation: -rank (equivalent to -1 * rank))r\  r4  r#   s    r%   __neg__Rank.__neg__  s    CGT?##r'   c                     [        U 5      $ )zAbsolute value: abs(rank)Absr#   s    r%   __abs__Rank.__abs__      4yr'   c                     [        U 5      $ )z"Absolute value builder: rank.abs()ro  r#   s    r%   r9  Rank.abs  rs  r'   c                     [        U 5      $ )zExponential: e^rank)Expr#   s    r%   r:  Rank.exp  rs  r'   c                     [        U 5      $ )zNatural logarithm: ln(rank))Logr#   s    r%   r;  Rank.log  rs  r'   Maxc                    [        U[        [        45      (       a  [        U5      OUn[        U [        5      (       aP  [        U[        5      (       a"  [	        U R
                  UR
                  -   5      $ [	        U R
                  U/-   5      $ [        U[        5      (       a  [	        U /UR
                  -   5      $ [	        X/5      $ )z1Maximum of this rank and another: rank.max(rank2))rK   r   r3  r4  r|  rB  rI  s      r%   r<  Rank.max      #-ec5\#B#BSZ
 dC  *c**4::
(8(8899tzzZL011
C((v
 0 0011D%&&r'   Minc                    [        U[        [        45      (       a  [        U5      OUn[        U [        5      (       aP  [        U[        5      (       a"  [	        U R
                  UR
                  -   5      $ [	        U R
                  U/-   5      $ [        U[        5      (       a  [	        U /UR
                  -   5      $ [	        X/5      $ )z1Minimum of this rank and another: rank.min(rank2))rK   r   r3  r4  r  rB  rI  s      r%   r=  Rank.min  r  r'   r(   N)r   r\  )r   rp  )r   rw  )r   rz  )r)   r*   r+   r,   ro   r   rV   r	   r7   rp   rR   r
   r3  r   rK  rP  rU  rY  r^  ra  re  rh  rl  rq  r9  r:  r;  r<  r=  r/   r(   r'   r%   r  r  S  s   6Ic3h I X=S#X X=6 X= X=v
'U65##56 
'5 
'!eE3J/ !E !%U65##56 %5 %
%eE3J/ %E %
'U65##56 
'5 
'!eE3J/ !E !%vuc'9!: %u %
%%s
"3 % %$
'vuc12 'u ''vuc12 'u 'r'   r  c                   <    \ rS rSr% Sr\\S'   S\\\	4   4S jr
Srg)rp  i  zAbsolute value of a rankr  r   c                 :    SU R                   R                  5       0$ )Nr.  r  r7   r#   s    r%   r7   Abs.to_dict      		))+,,r'   r(   Nr)   r*   r+   r,   ro   r  r-   r   rV   r	   r7   r/   r(   r'   r%   rp  rp        "
J-c3h -r'   rp  c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\	4   4S jr
Srg)	rc  i  zDivision of two ranksr*  r+  r   c                 p    SU R                   R                  5       U R                  R                  5       S.0$ )Nr-  r*  r+  r*  r7   r+  r#   s    r%   r7   Div.to_dict  ,    !2!2!4tzz?Q?Q?STUUr'   r(   Nr  r(   r'   r%   rc  rc    s%    
JKVc3h Vr'   rc  c                   <    \ rS rSr% Sr\\S'   S\\\	4   4S jr
Srg)rw  i  zExponentiation of a rankr  r   c                 :    SU R                   R                  5       0$ )Nr/  r  r#   s    r%   r7   Exp.to_dict  r  r'   r(   Nr  r(   r'   r%   rw  rw    r  r'   rw  c                   <    \ rS rSr% Sr\\S'   S\\\	4   4S jr
Srg)rz  i  zLogarithm of a rankr  r   c                 :    SU R                   R                  5       0$ )Nr0  r  r#   s    r%   r7   Log.to_dict  r  r'   r(   Nr  r(   r'   r%   rz  rz    s    
J-c3h -r'   rz  c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)r|  i  zMaximum of multiple ranksrB  r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr1  rB  r7   r$   rA  s     r%   r7   Max.to_dict  '    djj9jj9::9rw   r(   Nr)   r*   r+   r,   ro   r   r  r-   r   rV   r	   r7   r/   r(   r'   r%   r|  r|    #    #:;c3h ;r'   r|  c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)r  i  zMinimum of multiple ranksrB  r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr2  r  r  s     r%   r7   Min.to_dict  r  rw   r(   Nr  r(   r'   r%   r  r    r  r'   r  c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)r\  i  z Multiplication of multiple ranksrB  r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr,  r  r  s     r%   r7   Mul.to_dict  r  rw   r(   Nr  r(   r'   r%   r\  r\    s#    *:;c3h ;r'   r\  c                       \ rS rSr% Sr\\\\   \	SSS4   \
S'   Sr\\
S'   S	r\\
S
'   Sr\\   \
S'   Sr\\
S'   S\\\4   4S jrSrg)r8  i  a^  KNN-based ranking

Args:
    query: The query for KNN search. Can be:
           - A string (will be automatically embedded using the collection's embedding function)
           - A dense vector (list or numpy array)
           - A sparse vector (SparseVector dict)
    key: The embedding key to search against. Can be:
         - "#embedding" (default) - searches the main embedding field
         - A metadata field name (e.g., "my_custom_field") - searches that metadata field
    limit: Maximum number of results to consider (default: 16)
    default: Default score for records not in KNN results (default: None)
    return_rank: If True, return the rank position (0, 1, 2, ...) instead of distance (default: False)

Examples:
    # Search with string query (automatically embedded)
    Knn(query="hello world")  # Will use collection's embedding function

    # Search main embeddings with vectors (equivalent forms)
    Knn(query=[0.1, 0.2])  # Uses default key="#embedding"
    Knn(query=[0.1, 0.2], key=K.EMBEDDING)
    Knn(query=[0.1, 0.2], key="#embedding")

    # Search sparse embeddings stored in metadata with string
    Knn(query="hello world", key="custom_embedding")  # Will use schema's embedding function

    # Search sparse embeddings stored in metadata with vector
    Knn(query=my_vector, key="custom_embedding")  # Example: searches a metadata field
zNDArray[np.float32]zNDArray[np.float64]zNDArray[np.int32]r#  r   r   r$  r  Nr&  Fr%  r   c                 v   U R                   n[        U[        5      (       a  UR                  5       nO/[        U[        R
                  5      (       a  UR                  5       nXR                  U R                  S.nU R                  b  U R                  US'   U R                  (       a  U R                  US'   SU0$ )N)r#  r   r  r&  r%  r"  )r#  rK   r   r7   r6  r7  tolistr   r  r&  r%  )r$   query_valuer`   s      r%   r7   Knn.to_dict&  s    jjk<00%--/KRZZ00%,,.K 'xx$**M <<# $F9$($4$4F=!r'   r(   )r)   r*   r+   r,   ro   r
   rV   r   r3  r   r-   r   r  r   r&  r   r%  r  r   r	   r7   r/   r(   r'   r%   r8  r8    sr    < U	  CE3O#GXe_#K c3h  r'   r8  c                   F    \ rS rSr% Sr\\S'   \\S'   S\\\	4   4S jr
Srg)	rS  i<  zSubtraction of two ranksr*  r+  r   c                 p    SU R                   R                  5       U R                  R                  5       S.0$ )Nr)  r  r  r#   s    r%   r7   Sub.to_dictC  r  r'   r(   Nr  r(   r'   r%   rS  rS  <  s%    "
JKVc3h Vr'   rS  c                   B    \ rS rSr% Sr\\   \S'   S\\	\
4   4S jrSrg)rG  iG  zSummation of multiple ranksrB  r   c                 d    SU R                    Vs/ s H  oR                  5       PM     sn0$ s  snf )Nr'  r  r  s     r%   r7   Sum.to_dictM  r  rw   r(   Nr  r(   r'   r%   rG  rG  G  s#    %:;c3h ;r'   rG  c                   <    \ rS rSr% Sr\\S'   S\\\	4   4S jr
Srg)r4  iQ  zConstant rank valuerc   r   c                     SU R                   0$ )Nr!  )rc   r#   s    r%   r7   Val.to_dictW  s    

##r'   r(   N)r)   r*   r+   r,   ro   r3  r-   r   rV   r	   r7   r/   r(   r'   r%   r4  r4  Q  s    L$c3h $r'   r4  c                   x    \ rS rSr% Sr\\   \S'   Sr\	\S'   Sr
\\\      \S'   Sr\\S	'   S
\\\4   4S jrSrg)Rrfi[  aV  Reciprocal Rank Fusion for combining multiple ranking strategies.

RRF formula: score = -sum(weight_i / (k + rank_i)) for each ranking strategy
The negative is used because RRF produces higher scores for better results,
but Chroma uses ascending order (lower scores = better results).

Args:
    ranks: List of Rank expressions to fuse (must have at least one)
    k: Smoothing constant (default: 60, standard in literature)
    weights: Optional weights for each ranking strategy. If not provided,
            all ranks are weighted equally (weight=1.0 each).
    normalize: If True, normalize weights to sum to 1.0 (default: False).
              When False, weights are used as-is for relative importance.
              When True, weights are scaled so they sum to 1.0.

Examples:
    # Note: metadata fields (like "sparse_embedding" below) are user-defined and can store any data.
    # The field name is just an example - use whatever name matches your metadata structure.
    # Basic RRF combining KNN rankings (equal weight)
    Rrf([
        Knn(query=[0.1, 0.2], return_rank=True),
        Knn(query=another_vector, key="custom_embedding", return_rank=True)  # Example metadata field
    ])

    # Weighted RRF with relative weights (not normalized)
    Rrf(
        ranks=[
            Knn(query=[0.1, 0.2], return_rank=True),
            Knn(query=another_vector, key="custom_embedding", return_rank=True)  # Example metadata field
        weights=[2.0, 1.0],  # First ranking is 2x more important
        k=100
    )

    # Weighted RRF with normalized weights
    Rrf(
        ranks=[
            Knn(query=[0.1, 0.2], return_rank=True),
            Knn(query=another_vector, key="custom_embedding", return_rank=True)  # Example metadata field
        ],
        weights=[3.0, 1.0],  # Will be normalized to [0.75, 0.25]
        normalize=True,
        k=100
    )
rB  <   kNweightsF	normalizer   c                    U R                   (       d  [        S5      eU R                  S::  a  [        SU R                   35      eU R                  b  [	        U R                  5      [	        U R                   5      :w  a8  [        S[	        U R                  5       S[	        U R                   5       S35      e[        S U R                   5       5      (       a  [        S	5      eU R                  (       a  U R                  OS
/[	        U R                   5      -  nU R                  (       a0  [        U5      nUS:X  a  [        S5      eU Vs/ s H  o3U-  PM	     nn[        XR                   5       VVs/ s H  u  p4X0R                  U-   -  PM     nnnUS   nUSS  H  nXg-   nM	     U* R                  5       $ s  snf s  snnf )zConvert RRF to a composition of existing expression operators.

Builds: -sum(weight_i / (k + rank_i)) for each rank
Using Python's overloaded operators for cleaner code.
zRRF requires at least one rankr   zk must be positive, got NzNumber of weights (z) must match number of ranks ()c              3   *   #    U  H	  oS :  v   M     g7f)g        Nr(   ).0ws     r%   	<genexpr>Rrf.to_dict.<locals>.<genexpr>  s     1Lqs7Ls   z All weights must be non-negativeg      ?z3Sum of weights must be positive when normalize=Truer=   )
rB  rO   r  r  rQ   anyr  sumzipr7   )r$   r  
weight_sumr  r  termsrrf_sumterms           r%   r7   Rrf.to_dict  s    zz=>>66Q;7x@AA <<#4<< C

O3 )#dll*;)<<Z[^_c_i_i[jZkklm  1DLL111 !CDD #',,$,,SEC

O4K >>WJQ !VWW/67w!:~wG7 584LM4Lfftm$4LM a!"IDnG  !!## 8 Ns   	F71F<r(   )r)   r*   r+   r,   ro   r   r  r-   r  r   r  r   r3  r  r  r   rV   r	   r7   r/   r(   r'   r%   r  r  [  sN    +Z :AsK%)GXd5k")It($c3h ($r'   r  c                   ~    \ rS rSr% Sr\" \S9r\\	\
\4      \S'   S\\\4   4S jr\S\\\4   SS 4S j5       rS	rg
)Selecti  a  Selection configuration for search results.

Fields can be:
- Key.DOCUMENT - Select document key (equivalent to Key("#document"))
- Key.EMBEDDING - Select embedding key (equivalent to Key("#embedding"))
- Key.SCORE - Select score key (equivalent to Key("#score"))
- Any other string - Select specific metadata property

Note: You can use K as an alias for Key for more concise code.

Examples:
    # Select predefined keys using K alias (K is shorthand for Key)
    from chromadb.execution.expression import K
    Select(keys={K.DOCUMENT, K.SCORE})

    # Select specific metadata properties
    Select(keys={"title", "author", "date"})

    # Mixed selection
    Select(keys={K.DOCUMENT, "title", "author"})
)default_factoryr  r   c                     / nU R                    HF  n[        U[        5      (       a  UR                  UR                  5        M5  UR                  U5        MH     S[        [        R                  U5      5      0$ )z9Convert the Select to a dictionary for JSON serializationr  )r  rK   rW   r  r   rP   rL   fromkeys)r$   key_stringsr  s      r%   r7   Select.to_dict  s_     A!S!!""166*""1%	  T]];7899r'   r:   c                    [        U [        5      (       d!  [        S[        U 5      R                   35      eU R                  S/ 5      n[        U[        [        [        45      (       d!  [        S[        U5      R                   35      e/ nU GH  n[        U[        5      (       d!  [        S[        U5      R                   35      eUS:X  a!  UR                  [        R                  5        Ma  US:X  a!  UR                  [        R                  5        M  US:X  a!  UR                  [        R                  5        M  US:X  a!  UR                  [        R                  5        M  US	:X  a!  UR                  [        R                   5        M  UR                  [        U5      5        GM     S1n[        U R#                  5       5      U-
  nU(       a  [%        S
U 35      e['        [        U5      S9$ )zCreate Select from dictionary.

Examples:
- {"keys": ["#document", "#score"]} -> Select(keys={Key.DOCUMENT, Key.SCORE})
- {"keys": ["title", "author"]} -> Select(keys={"title", "author"})
zExpected dict for Select, got r  z*Select keys must be a list/tuple/set, got z!Select key must be a string, got r   r   r   r   r   z Unexpected keys in Select dict: )r  )rK   rL   rM   rN   r)   r  rP   r5  r  rV   r  rW   r   r   r   r   r   r  rO   r  )r:   r  key_listr  r	  r
  s         r%   rR   Select.from_dict  s    $%%<T$Z=P=P<QRSSxx#$uc 233<T$Z=P=P<QR 
 Aa%%"CDGDTDTCU VWW Ez'k!-l".k!-h		* A'# ( xdiik*\9??PQRR 3x=))r'   r(   N)r)   r*   r+   r,   ro   r   r  r  r   r
   rW   rV   r-   r   r	   r7   rp   rR   r/   r(   r'   r%   r  r    sc    , "'s!;D#eCHo
;
:c3h 
: ,*S#X ,*8 ,* ,*r'   r  )Ddataclassesr   r   typingr   r   r   r   r	   r
   numpyr6  numpy.typingr   chromadb.api.typesr   r   r   r   r   r   r   r   chromadb.typesr   r   r   r   r1   rf   rl   r~   r   r   r   r   r   r   r   r   r   r   r   rW   r   r   r   r   r   Kr   r   r   r  r  rp  rc  rw  rz  r|  r  r\  r8  rS  rG  r4  r  r  r(   r'   r%   <module>r     s   ( 8 8   	 	 	  
 
 
 G! G! G!T @% @ @ ? ? ? / / / / / / / / / 0% 0 0 / / / 0% 0 0 0 0 0 1% 1 1 7u 7 7 ;% ; ; 4E 4 4 8u 8 8b/ b/L 
U;L!;M	  ) ) )   
 .1 .1 .1b   0 [' [' ['|
 -$ - - V$ V V -$ - - -$ - - ;$ ; ; ;$ ; ; ;$ ; ; ? $ ?  ? D V$ V V ;$ ; ; $$ $ $ [$$ [$ [$| R* R* R*r'   