
    LKiE;                        S SK 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Jr  S SKJr  S SKJr  S SKJr   " S S	\5      r " S
 S\5      r\\\\\S4   r " S S\5      r " S S5      r " S S5      r \" SSS9r! " S S\S   5      r" " S S\"5      r# " S S\#5      r$\$r% " S S\"5      r& " S S\&5      r'\'r( " S S\"5      r)g)     )abstractmethodN)override)	AnyClassVarDictListOptionalProtocolUnionTypeVarcast)Self)	cpu_count)JSONSerializablec                       \ rS rSrSrSrg)StaticParameterError   z?Represents an error that occurs when a static parameter is set. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       \/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/chromadb/api/configuration.pyr   r      s    Ir   r   c                       \ rS rSrSrSrg)InvalidConfigurationError   z@Represents an error that occurs when a configuration is invalid.r   Nr   r   r   r   r   r      s    Jr   r   ConfigurationInternalc                   4    \ rS rSrSr\S\S\4S j5       rSr	g)ParameterValidator&   z+Represents an abstract parameter validator.valuereturnc                     [        5       e)z)Returns whether the given value is valid.)NotImplementedError)selfr%   s     r   __call__ParameterValidator.__call__)   s     "##r   r   N)
r   r   r   r   r   r   ParameterValueboolr*   r   r   r   r   r#   r#   &   s%    5$n $ $ $r   r#   c                   \    \ rS rSr% Sr\\S'   \\S'   \\S'   \	\S'   S\S\S\S\	4S jr
Srg	)
ConfigurationDefinition/   z-Represents the definition of a configuration.name	validator	is_staticdefault_valuec                 4    Xl         X l        X0l        X@l        g Nr1   r2   r3   r4   )r)   r1   r2   r3   r4   s        r   __init__ ConfigurationDefinition.__init__7   s     	""*r   )r4   r3   r1   r2   N)r   r   r   r   r   str__annotations__r#   r-   r,   r8   r   r   r   r   r/   r/   /   sF    7
I!!O!!
+
+ &
+ 	
+
 &
+r   r/   c                   `    \ rS rSr% Sr\\S'   \\S'   S\S\4S jrS\4S jr	S\
S\4S	 jrS
rg)ConfigurationParameterD   z*Represents a parameter of a configuration.r1   r%   c                     Xl         X l        g r6   r1   r%   )r)   r1   r%   s      r   r8   ConfigurationParameter.__init__J   s    	
r   r&   c                 <    SU R                    SU R                   S3$ )NzConfigurationParameter(z, )r@   r)   s    r   __repr__ConfigurationParameter.__repr__N   s    (2djj\CCr   _ConfigurationParameter__valuec                     [        U[        5      (       d  [        $ U R                  UR                  :H  =(       a    U R                  UR                  :H  $ r6   )
isinstancer=   NotImplementedr1   r%   )r)   rG   s     r   __eq__ConfigurationParameter.__eq__Q   s;    '#9::!!yyGLL(HTZZ7==-HHr   r@   N)r   r   r   r   r   r:   r;   r,   r8   rE   objectr-   rK   r   r   r   r   r=   r=   D   sG    4
IS  D# DIf I Ir   r=   T)boundc                   t   \ rS rSr% Sr\\\4   \S'   \	\\\
4      \S'   SS\\\      4S jjrS\4S	 jrS
\S\4S jr\SS j5       rS\\   4S jrS\S\4S jrS\S\\\\\4   SS4S jr\S\4S j5       r\\S\S\4S j5       5       r\S\\\4   4S j5       r \\S\\\4   S\4S j5       5       r!Sr"g)r!   Z   z@Represents an abstract configuration, used internally by Chroma.parameter_mapdefinitionsN
parametersc                    0 U l         UGb|  U GHu  nUR                  U R                  ;  a  [        SUR                   35      eU R                  UR                     n[	        UR
                  [        5      (       an  [        5       R                  UR
                  R                  SS5      5      nUc  [        SUR
                   35      eUR                  UR
                  5      Ul        [	        UR
                  [        UR                  5      5      (       d  [        SUR
                   35      eUR                  nU" UR
                  5      (       d  [        SUR
                   35      eX R                   UR                  '   GMx     U R                  R                  5        H6  u  pcX`R                   ;  d  M  [        XcR                  S9U R                   U'   M8     U R                  5         g)zZInitializes a new instance of the Configuration class. Respecting defaults and
validators.NInvalid parameter name: _typezInvalid configuration type: zInvalid parameter value: r@   )rR   r1   rS   
ValueErrorrI   r%   dictglobalsget	from_jsontyper4   r2   itemsr=   configuration_validator)r)   rT   	parameter
definition
child_typeparameter_validatorr1   s          r   r8   ConfigurationInternal.__init__b   s     !'	>>)9)99$'?	?O%PQQ!--inn=
ioot44!(y/B/B7D/Q!RJ!)(:9??:KL  '1&:&:9??&KIO!)//4
8P8P3QRR$'@@Q%RSS&0&:&:#*9??;;$'@@Q%RSS5>""9>>2' (* !% 0 0 6 6 8D---+A%=%=,""4( !9 	$$&r   r&   c                 >    SU R                   R                  5        S3$ )NzConfiguration(rC   )rR   valuesrD   s    r   rE   ConfigurationInternal.__repr__   s!     2 2 9 9 ;<A>>r   _ConfigurationInternal__valuec                 j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r6   )rI   r!   rJ   rR   )r)   rh   s     r   rK   ConfigurationInternal.__eq__   s-    '#899!!!!W%:%:::r   c                     g)zPerform custom validation when parameters are dependent on each other.

Raises an InvalidConfigurationError if the configuration is invalid.
Nr   rD   s    r   r_   -ConfigurationInternal.configuration_validator   s     	r   c                 H    [        U R                  R                  5       5      $ )z,Returns the parameters of the configuration.)listrR   rf   rD   s    r   get_parameters$ConfigurationInternal.get_parameters   s    D&&--/00r   r1   c                     XR                   ;  a%  [        SU SU R                  R                   35      e[	        [
        U R                   R                  U5      5      nU$ )zIReturns the parameter with the given name, or except if it doesn't exist.rV   z for configuration )rR   rX   	__class__r   r   r=   r[   )r)   r1   param_values      r   get_parameter#ConfigurationInternal.get_parameter   s]    )))*4&0CDNND[D[C\]  143E3E3I3I$3OPr   r%   c                    XR                   ;  a  [        SU 35      eU R                   U   nU R                  U   nUR                  (       a  [	        SU 35      eUR                  U5      (       d  [        SU SU 35      eX$l        g)z:Sets the parameter with the given name to the given value.rV   zCannot set static parameter: zInvalid value for parameter z: N)rS   rX   rR   r3   r   r2   r%   )r)   r1   r%   ra   r`   s        r   set_parameter#ConfigurationInternal.set_parameter   s    '''7v>??%%d+
&&t,	&)Ftf'MNN##E**;D6E7KLLr   c                 J    [         R                  " U R                  5       5      $ )z5Returns the JSON representation of the configuration.)jsondumpsto_jsonrD   s    r   to_json_str!ConfigurationInternal.to_json_str   s     zz$,,.))r   json_strc                      [         R                  " U5      nU(       a  U R	                  U5      $ U " 5       $ ! [         R                   a    [        SU 35      ef = f)3Returns a configuration from the given JSON string.z1Unable to decode configuration from JSON string: )rz   loadsJSONDecodeErrorrX   r\   )clsr   config_jsons      r   from_json_str#ConfigurationInternal.from_json_str   s]    	**X.K
 .9s}}[)CceC	 ## 	CH:N 	s	   7 #Ac           	      (   U R                   R                  5        VVs0 s HK  u  pU[        UR                  [        5      (       a  UR                  R                  5       OUR                  _MM     nnnU R                  R                  US'   U$ s  snnf )zKReturns the JSON compatible dictionary representation of the configuration.rW   )rR   r^   rI   r%   r!   r|   rr   r   )r)   r1   r`   	json_dicts       r   r|   ConfigurationInternal.to_json   s     $(#5#5#;#;#=	
 $> )//+@AA //))+! $>	 	 
 "^^44	'
s   ABjson_mapc                     U R                   UR                  SS5      :w  a  [        SU R                    SUS    35      e/ nUR                  5        H%  u  p4US:X  a  M  UR	                  [        X4S95        M'     U " US9$ )r   rW   Nz,Trying to instantiate configuration of type z from JSON with type r@   rT   )r   r[   rX   r^   appendr=   )r   r   rT   r1   r%   s        r   r\   ConfigurationInternal.from_json   s     <<8<<66>s||nLabjkrbsatu  
#>>+KDw4$LM	 ,
 j))r   )rR   r6   r&   N)#r   r   r   r   r   r   r:   r=   r;   r   r/   r	   r   r8   rE   rM   r-   rK   r   r_   ro   rt   r   intfloatrw   r   r}   classmethodr   r   r   r|   r\   r   r   r   r   r!   r!   Z   se   J 3344$s$;;<== '8D1G,H#I  'D?# ?;f ; ;
  1%; < 1# *@ 
 # 
 eCeT4I.J 
 t 
  *S * * DS DT D  D 
c3h 
 
 *c3h *D *  *r   c                       \ rS rSrSr\" SS SSS9\" SS	 SS
S9\" SS SS
S9\" SS S\" 5       S9\" SS SSS9\" SS SSS9\" SS SS
S9\" SS SSS9S.r\S"S j5       r	\
S\\\4   S\4S  j5       rS!rg)#HNSWConfigurationInternal   ztInternal representation of the HNSW configuration.
Used for validation, defaults, serialization and deserialization.spacec                 :    [        U [        5      =(       a    U S;   $ )N)l2ipcosine)rI   r:   r%   s    r   <lambda>"HNSWConfigurationInternal.<lambda>   s    Juc$: %0//%0r   Tr   r7   ef_constructionc                 :    [        U [        5      =(       a    U S:  $ N   rI   r   r   s    r   r   r          Juc$:$Iuz$Ir   d   	ef_searchc                 :    [        U [        5      =(       a    U S:  $ r   r   r   s    r   r   r      r   r   Fnum_threadsc                 :    [        U [        5      =(       a    U S:  $ r   r   r   s    r   r   r      r   r   Mc                 :    [        U [        5      =(       a    U S:  $ r   r   r   s    r   r   r      r   r      resize_factorc                 :    [        U [        5      =(       a    U S:  $ r   )rI   r   r   s    r   r   r     s    Jue$<$K!$Kr   333333?
batch_sizec                 :    [        U [        5      =(       a    U S:  $ r   r   r   s    r   r   r     r   r   sync_thresholdc                 :    [        U [        5      =(       a    U S:  $ r   r   r   s    r   r   r     r   r     )r   r   r   r   r   r   r   r   r&   Nc                    U R                   R                  S5      nU R                   R                  S5      nU(       aJ  U(       aB  [        [        UR                  5      [        [        UR                  5      :  a  [        S5      eg g g )Nr   r   z7batch_size must be less than or equal to sync_threshold)rR   r[   r   r   r%   r   )r)   r   r   s      r   r_   1HNSWConfigurationInternal.configuration_validator  sy    ''++L9
++//0@A S***+d38L8L.MM+I  N  r   paramsc           	          SSSSSSSSS	.n/ nUR                  5        H3  u  pEXB;  a  [        S
U 35      eUR                  [        X$   US95        M5     U " U5      $ )zhReturns an HNSWConfiguration from a metadata dict containing legacy HNSW parameters. Used for migration.r   r   r   r   r   r   r   r   )z
hnsw:spacezhnsw:construction_efzhnsw:search_efzhnsw:Mzhnsw:num_threadszhnsw:resize_factorzhnsw:batch_sizezhnsw:sync_thresholdz$Invalid legacy HNSW parameter name: r@   )r^   rX   r   r=   )r   r   
old_to_newrT   r1   r%   s         r   from_legacy_params,HNSWConfigurationInternal.from_legacy_params"  s|     "$5) -"1+#3	

 
!<<>KD% #Gv!NOO&J,<EJ * :r   r   r   )r   r   r   r   r   r/   r   rS   r   r_   r   r   r:   r   r   r   r   r   r   r   r   r      s   I )0
 3"I	
 -I	
 /I#+	
 %I	
 1 K	
 .I	
 2!I	
Y2Kh   S#X 4  r   r   c                   n   ^  \ rS rSrSrSSS\" 5       SSSS4S\S	\S
\S\S\S\S\S\4U 4S jjjr	Sr
U =r$ )HNSWConfigurationInterfaceiB  zHNSW index configuration parameters.
See https://docs.trychroma.com/guides#changing-the-distance-function for more information.
r   r   r   r   r   r   r   r   r   r   r   r   r   c	                    > [        SUS9[        SUS9[        SUS9[        SUS9[        SUS9[        SUS9[        SUS9[        S	US9/n	[        T
U ]	  U	S
9  g )Nr   r@   r   r   r   r   r   r   r   r   )r=   superr8   )r)   r   r   r   r   r   r   r   r   rT   rr   s             r   r8   #HNSWConfigurationInterface.__init__G  sp     #u="(9Q"9E"[I"15"}M"JG"(8O	

 	J/r   r   )r   r   r   r   r   r   r:   r   r   r8   r   __classcell__rr   s   @r   r   r   B  s|     "$;""00 0 	0
 0 0 0 0 0 0r   r   c                   N    \ rS rSrSrS\" SS S\" 5       S90r\S
S j5       r	S	r
g)CollectionConfigurationInternalid  z|Internal representation of the collection configuration.
Used for validation, defaults, and serialization / deserialization.hnsw_configurationc                 "    [        U [        5      $ r6   )rI   r   r   s    r   r   (CollectionConfigurationInternal.<lambda>k  s    Ju6O$Pr   Tr7   Nc                     g r6   r   rD   s    r   r_   7CollectionConfigurationInternal.configuration_validatorq      r   r   r   )r   r   r   r   r   r/   r   rS   r   r_   r   r   r   r   r   r   d  s?    K 	5%P35	
K  r   r   c                   :   ^  \ rS rSrSrS\\   4U 4S jjrSrU =r	$ ) CollectionConfigurationInterfaceiz  z3Configuration parameters for creating a collection.r   c                 P   > Uc
  [        5       n[        SUS9/n[        TU ]  US9  g)zInitializes a new instance of the CollectionConfiguration class.
Args:
    hnsw_configuration: The HNSW configuration to use for the collection.
Nr   r@   r   )r   r=   r   r8   )r)   r   rT   rr   s      r   r8   )CollectionConfigurationInterface.__init__}  s9    
 %!:!<"(<DVW

 	J/r   r   )
r   r   r   r   r   r	   r   r8   r   r   r   s   @r   r   r   z  s    =
084M+N 
0 
0r   r   c                   @    \ rS rSrS\" SS SSS90r\S
S j5       rS	rg)$EmbeddingsQueueConfigurationInternali  automatically_purgec                 "    [        U [        5      $ r6   )rI   r-   r   s    r   r   -EmbeddingsQueueConfigurationInternal.<lambda>  s    Jud$;r   FTr7   Nc                     g r6   r   rD   s    r   r_   <EmbeddingsQueueConfigurationInternal.configuration_validator  r   r   r   r   )	r   r   r   r   r/   rS   r   r_   r   r   r   r   r   r     s4    6&;	 
K  r   r   )*abcr   rz   	overridesr   typingr   r   r   r   r	   r
   r   r   r   typing_extensionsr   multiprocessingr   chromadb.serder   	Exceptionr   rX   r   r:   r   r   r-   r,   r#   r/   r=   rN   r!   r   r   HNSWConfigurationr   r   CollectionConfigurationr   r   r   r   <module>r      s      
 
 
 # % +
	9 		
 	 sC.EEF$ $+ +*I I& C./*,-DE *D_ 5 _L0!: 0> / &; ,0'F 0" ; +@ r   