Ë
    lQêjE;  ã                   ó˜  — d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZmZ d dlmZ d dlmZ d dlmZ  G d„ d	e«      Z G d
„ de«      Zeeeeedf   Z G d„ de«      Z G d„ d«      Z G d„ d«      Z  edd¬«      Z! G d„ ded   «      Z" G d„ de"«      Z# G d„ de#«      Z$e$Z% G d„ de"«      Z& G d„ de&«      Z'e'Z( G d„ de"«      Z)y) é    )ÚabstractmethodN)Úoverride)	ÚAnyÚClassVarÚDictÚListÚOptionalÚProtocolÚUnionÚTypeVarÚcast)ÚSelf)Ú	cpu_count)ÚJSONSerializablec                   ó   — e Zd ZdZy)ÚStaticParameterErrorz?Represents an error that occurs when a static parameter is set.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú_/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/chromadb/api/configuration.pyr   r      s   „ ÙIàr   r   c                   ó   — e Zd ZdZy)ÚInvalidConfigurationErrorz@Represents an error that occurs when a configuration is invalid.Nr   r   r   r   r   r      s   „ ÙJàr   r   ÚConfigurationInternalc                   ó*   — e Zd ZdZededefd„«       Zy)ÚParameterValidatorz+Represents an abstract parameter validator.ÚvalueÚreturnc                 ó   — t        «       ‚)z)Returns whether the given value is valid.)ÚNotImplementedError)Úselfr    s     r   Ú__call__zParameterValidator.__call__)   s   € ô "Ó#Ð#r   N)r   r   r   r   r   ÚParameterValueÚboolr%   r   r   r   r   r   &   s%   „ Ù5àð$˜nð $°ò $ó ñ$r   r   c                   óR   — e Zd ZU dZeed<   eed<   eed<   eed<   dedededefd„Z	y)ÚConfigurationDefinitionz-Represents the definition of a configuration.ÚnameÚ	validatorÚ	is_staticÚdefault_valuec                 ó<   — || _         || _        || _        || _        y ©N©r*   r+   r,   r-   )r$   r*   r+   r,   r-   s        r   Ú__init__z ConfigurationDefinition.__init__7   s!   € ð ˆŒ	Ø"ˆŒØ"ˆŒØ*ˆÕr   N)
r   r   r   r   ÚstrÚ__annotations__r   r'   r&   r1   r   r   r   r)   r)   /   sF   … Ù7à
ƒIØ!Ó!ØƒOØ!Ó!ð
+àð
+ð &ð
+ð ð	
+ð
 &ô
+r   r)   c                   óR   — e Zd ZU dZeed<   eed<   dedefd„Zdefd„Zde	de
fd„Zy	)
ÚConfigurationParameterz*Represents a parameter of a configuration.r*   r    c                 ó    — || _         || _        y r/   ©r*   r    )r$   r*   r    s      r   r1   zConfigurationParameter.__init__J   s   € ØˆŒ	Øˆ�
r   r!   c                 ó<   — d| j                   › d| j                  › d�S )NzConfigurationParameter(z, ú)r7   ©r$   s    r   Ú__repr__zConfigurationParameter.__repr__N   s   € Ø(¨¯©¨°2°d·j±j°\ÀÐCÐCr   Ú_ConfigurationParameter__valuec                 ó–   — t        |t        «      st        S | j                  |j                  k(  xr | j                  |j                  k(  S r/   )Ú
isinstancer5   ÚNotImplementedr*   r    )r$   r<   s     r   Ú__eq__zConfigurationParameter.__eq__Q   s8   € Ü˜'Ô#9Ô:Ü!Ð!Ø�y‰y˜GŸL™LÑ(ÒH¨T¯Z©Z¸7¿=¹=Ñ-HÐHr   N)r   r   r   r   r2   r3   r&   r1   r;   Úobjectr'   r@   r   r   r   r5   r5   D   sG   … Ù4à
ƒIØÓð˜Sð ¨ó ðD˜#ó DðI˜fð I¨ô Ir   r5   ÚT)Úboundc                   óT  — e Zd ZU dZeeef   ed<   eeee	f      ed<   dde
ee      fd„Zdefd„Zd	edefd
„Zedd„«       Zdee   fd„Zdedefd„Zdedeeeeef   ddfd„Zedefd„«       Zeededefd„«       «       Zedeeef   fd„«       Zeedeeef   defd„«       «       Z y)r   z@Represents an abstract configuration, used internally by Chroma.Úparameter_mapÚdefinitionsNÚ
parametersc                 ó´  — i | _         |��i|D �]c  }|j                  | j                  vrt        d|j                  › �«      ‚| j                  |j                     }t	        |j
                  t        «      rmt        «       j                  |j
                  j                  dd«      «      }|€t        d|j
                  › �«      ‚|j                  |j
                  «      |_        t	        |j
                  t        |j                  «      «      st        d|j
                  › �«      ‚|j                  } ||j
                  «      st        d|j
                  › �«      ‚|| j                   |j                  <   �Œf | j                  j                  «       D ]8  \  }}|| j                   vsŒt        ||j                  ¬«      | j                   |<   Œ: | j                  «        y)zbInitializes a new instance of the Configuration class. Respecting defaults and
        validators.NúInvalid parameter name: Ú_typezInvalid configuration type: zInvalid parameter value: r7   )rE   r*   rF   Ú
ValueErrorr>   r    ÚdictÚglobalsÚgetÚ	from_jsonÚtyper-   r+   Úitemsr5   Úconfiguration_validator)r$   rG   Ú	parameterÚ
definitionÚ
child_typeÚparameter_validatorr*   s          r   r1   zConfigurationInternal.__init__b   sž  € ð  ˆÔØÑ!Ø'ó ?�	Ø—>‘>¨×)9Ñ)9Ñ9Ü$Ð'?À	ÇÁÐ?OÐ%PÓQÐQà!×-Ñ-¨i¯n©nÑ=�
ä˜iŸo™o¬tÔ4Ü!(£§¡¨y¯©×/BÑ/BÀ7ÈDÓ/QÓ!R�JØ!Ð)Ü(Ø:¸9¿?¹?Ð:KÐLóð ð '1×&:Ñ&:¸9¿?¹?Ó&K�I”OÜ! )§/¡/´4¸
×8PÑ8PÓ3QÔRÜ$Ð'@ÀÇÁÐ@QÐ%RÓSÐSà&0×&:Ñ&:Ð#Ù*¨9¯?©?Ô;Ü$Ð'@ÀÇÁÐ@QÐ%RÓSÐSØ5>�×"Ñ" 9§>¡>Ó2ð'?ð* !%× 0Ñ 0× 6Ñ 6Ó 8ò 	ÑˆD�*Ø˜4×-Ñ-Ò-Ü+AØ Z×%=Ñ%=ô,�×"Ñ" 4Ò(ð	ð 	×$Ñ$Õ&r   r!   c                 ó>   — d| j                   j                  «       › d�S )NzConfiguration(r9   )rE   Úvaluesr:   s    r   r;   zConfigurationInternal.__repr__„   s!   € Ø × 2Ñ 2× 9Ñ 9Ó ;Ð<¸AÐ>Ð>r   Ú_ConfigurationInternal__valuec                 ó`   — t        |t        «      st        S | j                  |j                  k(  S r/   )r>   r   r?   rE   )r$   rY   s     r   r@   zConfigurationInternal.__eq__‡   s*   € Ü˜'Ô#8Ô9Ü!Ð!Ø×!Ñ! W×%:Ñ%:Ñ:Ð:r   c                  ó   — y)z�Perform custom validation when parameters are dependent on each other.

        Raises an InvalidConfigurationError if the configuration is invalid.
        Nr   r:   s    r   rR   z-ConfigurationInternal.configuration_validatorŒ   s   € ð 	r   c                 óH   — t        | j                  j                  «       «      S )z,Returns the parameters of the configuration.)ÚlistrE   rX   r:   s    r   Úget_parametersz$ConfigurationInternal.get_parameters”   s   € ä�D×&Ñ&×-Ñ-Ó/Ó0Ð0r   r*   c                 ó¾   — || j                   vr%t        d|› d| j                  j                  › �«      ‚t	        t
        | j                   j                  |«      «      }|S )zIReturns the parameter with the given name, or except if it doesn't exist.rI   z for configuration )rE   rK   Ú	__class__r   r   r5   rN   )r$   r*   Úparam_values      r   Úget_parameterz#ConfigurationInternal.get_parameter˜   s_   € à�t×)Ñ)Ñ)ÜØ*¨4¨&Ð0CÀDÇNÁN×D[ÑD[ÐC\Ð]óð ô Ô1°4×3EÑ3E×3IÑ3IÈ$Ó3OÓPˆØÐr   r    c                 óþ   — || j                   vrt        d|› �«      ‚| j                   |   }| j                  |   }|j                  rt	        d|› �«      ‚|j                  |«      st        d|› d|› �«      ‚||_        y)z:Sets the parameter with the given name to the given value.rI   zCannot set static parameter: zInvalid value for parameter z: N)rF   rK   rE   r,   r   r+   r    )r$   r*   r    rT   rS   s        r   Úset_parameterz#ConfigurationInternal.set_parameter¡   s�   € à�t×'Ñ'Ñ'ÜÐ7¸°vÐ>Ó?Ð?Ø×%Ñ% dÑ+ˆ
Ø×&Ñ& tÑ,ˆ	Ø×ÒÜ&Ð)FÀtÀfÐ'MÓNÐNØ×#Ñ# EÔ*ÜÐ;¸D¸6ÀÀEÀ7ÐKÓLÐLØˆ	�r   c                 óH   — t        j                  | j                  «       «      S )z5Returns the JSON representation of the configuration.)ÚjsonÚdumpsÚto_jsonr:   s    r   Úto_json_strz!ConfigurationInternal.to_json_str­   s   € ô �z‰z˜$Ÿ,™,›.Ó)Ð)r   Újson_strc                 ó¬   — 	 t        j                  |«      }|r| j	                  |«      S  | «       S # t         j                  $ r t        d|› �«      ‚w xY w)ú3Returns a configuration from the given JSON string.z1Unable to decode configuration from JSON string: )rf   ÚloadsÚJSONDecodeErrorrK   rO   )Úclsrj   Úconfig_jsons      r   Úfrom_json_strz#ConfigurationInternal.from_json_str²   s]   € ð	ÜŸ*™* XÓ.ˆKñ
 .9ˆs�}‰}˜[Ó)ÐC¹c»eÐCøô	 ×#Ñ#ò 	ÜØCÀHÀ:ÐNóð ð	ús	   ‚1 ±"Ac           	      ó  — | j                   j                  «       D ��ci c]F  \  }}|t        |j                  t        «      r|j                  j                  «       n|j                  “ŒH }}}| j                  j                  |d<   |S c c}}w )zKReturns the JSON compatible dictionary representation of the configuration.rJ   )rE   rQ   r>   r    r   rh   r`   r   )r$   r*   rS   Ú	json_dicts       r   rh   zConfigurationInternal.to_json¾   s„   € ð $(×#5Ñ#5×#;Ñ#;Ó#=÷	
ñ  ��ið Ü˜)Ÿ/™/Ô+@ÔAð —/‘/×)Ñ)Ô+à—‘ñ!ð
ˆ	ñ 
ð "Ÿ^™^×4Ñ4ˆ	�'ÑØÐùó
s   žABÚjson_mapc                 ó  — | j                   |j                  dd«      k7  rt        d| j                   › d|d   › �«      ‚g }|j                  «       D ]'  \  }}|dk(  rŒ|j	                  t        ||¬«      «       Œ)  | |¬«      S )rl   rJ   Nz,Trying to instantiate configuration of type z from JSON with type r7   ©rG   )r   rN   rK   rQ   Úappendr5   )ro   rt   rG   r*   r    s        r   rO   zConfigurationInternal.from_jsonË   s•   € ð �<‰<˜8Ÿ<™<¨°Ó6Ò6ÜØ>¸s¿|¹|¸nÐLaÐbjÐkrÑbsÐatÐuóð ð ˆ
Ø#Ÿ>™>Ó+ò 	N‰KˆD�%à�wŠØØ×ÑÔ4¸$ÀeÔLÕMð		Nñ
 ˜jÔ)Ð)r   r/   ©r!   N)!r   r   r   r   r   r2   r5   r3   r   r)   r	   r   r1   r;   rA   r'   r@   r   rR   r^   rb   r   ÚintÚfloatrd   r   ri   Úclassmethodr   rq   r   rh   rO   r   r   r   r   r   Z   se  … ÙJð ˜Ð3Ð3Ñ4Ó4Ø˜$˜sÐ$;Ð;Ñ<Ñ=Ó=ñ ' 8¨DÐ1GÑ,HÑ#Ió  'ðD?˜#ó ?ð;˜fð ;¨ó ;ð
 òó ðð1 Ð%;Ñ <ó 1ð #ð Ð*@ó ð
  #ð 
 ¨e°C¸¸eÀTÐ4IÑ.Jð 
 Ètó 
 ð ð*˜Sò *ó ð*ð ØðD Sð D¨Tò Dó ó ðDð ð
˜˜c 3˜h™ò 
ó ð
ð Øð*  c¨3 h¡ð *°Dò *ó ó ñ*r   c                   ó  — e Zd ZdZ edd„ dd¬«       edd„ dd	¬«       ed
d„ dd	¬«       edd„ d e«       ¬«       edd„ dd¬«       edd„ dd¬«       edd„ dd	¬«       edd„ dd¬«      dœZed d„«       Ze	de
eef   defd„«       Zy)!ÚHNSWConfigurationInternalzxInternal representation of the HNSW configuration.
    Used for validation, defaults, serialization and deserialization.Úspacec                 ó.   — t        | t        «      xr | dv S )N)Úl2ÚipÚcosine)r>   r2   ©r    s    r   ú<lambda>z"HNSWConfigurationInternal.<lambda>ã   s   € ¤J¨u´cÓ$:ò %0ØÐ/Ð/ð r   Tr€   r0   Úef_constructionc                 ó0   — t        | t        «      xr | dk\  S ©Né   ©r>   ry   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>ê   ó   € ¤J¨u´cÓ$:Ò$I¸uÈ¹z€ r   éd   Ú	ef_searchc                 ó0   — t        | t        «      xr | dk\  S r‡   r‰   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>ð   rŠ   r   FÚnum_threadsc                 ó0   — t        | t        «      xr | dk\  S r‡   r‰   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>ö   rŠ   r   ÚMc                 ó0   — t        | t        «      xr | dk\  S r‡   r‰   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>ü   rŠ   r   é   Úresize_factorc                 ó0   — t        | t        «      xr | dk\  S r‡   )r>   rz   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>  s   € ¤J¨u´eÓ$<Ò$KÀÈ!Á€ r   ç333333ó?Ú
batch_sizec                 ó0   — t        | t        «      xr | dk\  S r‡   r‰   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>  rŠ   r   Úsync_thresholdc                 ó0   — t        | t        «      xr | dk\  S r‡   r‰   rƒ   s    r   r„   z"HNSWConfigurationInternal.<lambda>  rŠ   r   éè  )r~   r…   rŒ   rŽ   r�   r“   r–   r˜   r!   Nc                 óü   — | j                   j                  d«      }| j                   j                  d«      }|rD|rAt        t        |j                  «      t        t        |j                  «      kD  rt        d«      ‚y y y )Nr–   r˜   z7batch_size must be less than or equal to sync_threshold)rE   rN   r   ry   r    r   )r$   r–   r˜   s      r   rR   z1HNSWConfigurationInternal.configuration_validator  sy   € à×'Ñ'×+Ñ+¨LÓ9ˆ
Ø×+Ñ+×/Ñ/Ð0@ÓAˆñ ÙÜ”S˜*×*Ñ*Ó+¬d´3¸×8LÑ8LÓ.MÒMä+ØIóð ð Nð ð r   Úparamsc           	      ó¾   — ddddddddd	œ}g }|j                  «       D ]6  \  }}||vrt        d
|› �«      ‚|j                  t        ||   |¬«      «       Œ8  | |«      S )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: r7   )rQ   rK   rw   r5   )ro   rœ   Ú
old_to_newrG   r*   r    s         r   Úfrom_legacy_paramsz,HNSWConfigurationInternal.from_legacy_params"  s‡   € ð "Ø$5Ø)ØØ -Ø"1Ø+Ø#3ñ	
ˆ
ð ˆ
Ø!Ÿ<™<›>ò 	‰KˆD�%Ø˜:Ñ%Ü Ð#GÈÀvÐ!NÓOÐOØ×ÑÜ&¨J°tÑ,<ÀEÔJõð	ñ �:‹Ðr   rx   )r   r   r   r   r)   r   rF   r   rR   r{   r   r2   r   r   rŸ   r   r   r   r}   r}   Ü   s  „ ñIñ )Øñ0àØô
ñ 3Ø"ÙIØØô	
ñ -ØÙIØØô	
ñ /ØÙIØÙ#›+ô	
ñ %ØÙIØØô	
ñ 1Ø ÙKØØô	
ñ .ØÙIØØô	
ñ 2Ø!ÙIØØô	
ñY2€Kðh òó ðð ð¨¨S°#¨X©ð ¸4ò ó ñr   r}   c                   ó`   ‡ — e Zd ZdZddd e«       ddddfdeded	ed
ededededefˆ fd„Zˆ xZ	S )ÚHNSWConfigurationInterfacezˆHNSW 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	                 óê   •— t        d|¬«      t        d|¬«      t        d|¬«      t        d|¬«      t        d|¬«      t        d|¬«      t        d|¬«      t        d	|¬«      g}	t        ‰
| �	  |	¬
«       y )Nr~   r7   r…   rŒ   rŽ   r�   r“   r–   r˜   rv   )r5   Úsuperr1   )r$   r~   r…   rŒ   rŽ   r�   r“   r–   r˜   rG   r`   s             €r   r1   z#HNSWConfigurationInterface.__init__G  sp   ø€ ô #¨°uÔ=Ü"Ð(9ÀÔQÜ"¨¸9ÔEÜ"¨¸[ÔIÜ"¨°1Ô5Ü"¨¸}ÔMÜ"¨¸JÔGÜ"Ð(8ÀÔOð	
ˆ
ô 	‰Ñ JÐÕ/r   )
r   r   r   r   r   r2   ry   rz   r1   Ú__classcell__©r`   s   @r   r¡   r¡   B  s|   ø„ ñð Ø"ØÙ$›;ØØ"ØØ"ñ0àð0ð ð0ð ð	0ð
 ð0ð ð0ð ð0ð ð0ð ÷0ñ 0r   r¡   c                   óJ   — e Zd ZdZd edd„ d e«       ¬«      iZedd„«       Zy)	ÚCollectionConfigurationInternalz€Internal representation of the collection configuration.
    Used for validation, defaults, and serialization / deserialization.Úhnsw_configurationc                 ó"   — t        | t        «      S r/   )r>   r}   rƒ   s    r   r„   z(CollectionConfigurationInternal.<lambda>k  s   € ¤J¨uÔ6OÓ$P€ r   Tr0   Nc                  ó   — y r/   r   r:   s    r   rR   z7CollectionConfigurationInternal.configuration_validatorq  ó   € àr   rx   )	r   r   r   r   r)   r}   rF   r   rR   r   r   r   r§   r§   d  s?   „ ñKð 	Ñ5Ø%ÙPØÙ3Ó5ô	
ð€Kð òó ñr   r§   c                   ó.   ‡ — e Zd ZdZdee   fˆ fd„Zˆ xZS )Ú CollectionConfigurationInterfacez3Configuration parameters for creating a collection.r¨   c                 óZ   •— |€
t        «       }t        d|¬«      g}t        ‰| �  |¬«       y)z©Initializes a new instance of the CollectionConfiguration class.
        Args:
            hnsw_configuration: The HNSW configuration to use for the collection.
        Nr¨   r7   rv   )r}   r5   r£   r1   )r$   r¨   rG   r`   s      €r   r1   z)CollectionConfigurationInterface.__init__}  s9   ø€ ð
 Ð%Ü!:Ó!<Ðä"Ð(<ÐDVÔWð
ˆ
ô 	‰Ñ JÐÕ/r   )r   r   r   r   r	   r}   r1   r¤   r¥   s   @r   r­   r­   z  s   ø„ Ù=ð
0¨8Ð4MÑ+N÷ 
0ñ 
0r   r­   c                   ó<   — e Zd Zd edd„ dd¬«      iZedd„«       Zy)	Ú$EmbeddingsQueueConfigurationInternalÚautomatically_purgec                 ó"   — t        | t        «      S r/   )r>   r'   rƒ   s    r   r„   z-EmbeddingsQueueConfigurationInternal.<lambda>’  s   € ¤J¨u´dÓ$;€ r   FTr0   Nc                  ó   — y r/   r   r:   s    r   rR   z<EmbeddingsQueueConfigurationInternal.configuration_validator˜  r«   r   rx   )r   r   r   r)   rF   r   rR   r   r   r   r°   r°   Ž  s4   „ àÑ6Ø&Ù;ØØô	 
ð€Kð òó ñr   r°   )*Úabcr   rf   Ú	overridesr   Útypingr   r   r   r   r	   r
   r   r   r   Útyping_extensionsr   Úmultiprocessingr   Úchromadb.serder   Ú	Exceptionr   rK   r   r2   ry   rz   r'   r&   r   r)   r5   rB   r   r}   r¡   ÚHNSWConfigurationr§   r­   ÚCollectionConfigurationr°   r   r   r   ú<module>r½      só   ðÝ Û Ý ÷
÷ 
õ 
õ #Ý %å +ô
	˜9ô 	ô	 
ô 	ð �s˜C ¨Ð.EÐEÑF€ô$˜ô $÷+ñ +÷*Iñ Iñ& ˆCÐ.Ô/€ô*Ð,Ð-DÑEô *ôD_Ð 5ô _ôL0Ð!:ô 0ð> /Ð ôÐ&;ô ô,0Ð'Fô 0ð" ;Ð ôÐ+@õ r   