
    LKi                     F   S SK Jr  S SKJrJrJrJr  S SKJr  \(       a  S SK	J
r
  S SKJrJrJr  S SKJr  S SKJrJrJrJr  S SKJr  S S	KJrJr  S S
KJr  S SKJr  S SKJ r   S SK!J"r"J#r#J$r$J%r%J&r&  S SK'J(r(J)r)J*r*  S SK+J,r,J-r-J.r.J/r/  S SK0J1r1  S SK2J3r3  S SK4J5r6  S SK7J8r8  S SK9J:r:J;r;J<r<  S SK=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrR  S SKSJTrTJUrUJVrVJWrWJXrXJYrY  S SK4JZr[  S SK J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrcJdrd  S SKeJfrf  S SKgJhrhJiri  S SKjJkrk  S SKlrlS SKmrmS SKnrnS SK'Joro  \c" S\bS\`4   S9rp\mR                  " \r5      rsS \tS!S4S" jruS#\pS!\p4S$ jrv " S% S&\5      rw    S.S'\[R                  S(\?S)\\\@   S*\\\A   S+\\\B   S,\\\E   S!\^\[R                  SS4   4S- jjrzg)/    )TYPE_CHECKING)retrystop_after_attemptretry_if_exception
wait_fixed)	ServerAPI)AttachedFunction)CreateCollectionConfigurationUpdateCollectionConfiguration'create_collection_configuration_to_json)UserIdentity)DEFAULT_DATABASEDEFAULT_TENANTSettingsSystem)SysDB)QuotaEnforcerAction)RateLimitEnforcer)SegmentManager)Executor)ScanFilterLimitKNN
Projection)	CountPlanGetPlanKNNPlan)add_attributes_to_current_spanOpenTelemetryClientOpenTelemetryGranularitytrace_method)ProductTelemetryClient)Producer)
Collection__version__)InvalidDimensionExceptionNotFoundErrorVersionMismatchError)CollectionMetadataIDs
Embeddings	Metadatas	Documents	ReadLevelSchemaURIsWhereWhereDocumentInclude	GetResultQueryResultSearchResultvalidate_metadatavalidate_update_metadatavalidate_wherevalidate_where_documentvalidate_batchIncludeMetadataDocuments!IncludeMetadataDocumentsDistances)CollectionAddEventCollectionDeleteEventCollectionGetEventCollectionUpdateEventCollectionQueryEventClientCreateCollectionEventN)	OptionalSequence	GeneratorListAnyDictCallableTypeVarTuple)override)UUIDuuid4)wraps)SearchT.)bound
index_namereturnc                    SU  3n[        U 5      S:  d  [        U 5      S:  a  [        U5      e[        R                  " SU 5      (       d  [        U5      eSU ;   a  [        U5      e[        R                  " SU 5      (       a  [        U5      eg )Na  Expected collection name that (1) contains 3-63 characters, (2) starts and ends with an alphanumeric character, (3) otherwise contains only alphanumeric characters, underscores or hyphens (-), (4) contains no two consecutive periods (..) and (5) is not a valid IPv4 address, got    ?   z'^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$z..z0^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$)len
ValueErrorrematch)rW   msgs     V/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/chromadb/api/segment.pycheck_index_namerb   _   s    	 l	  :c*o2o88=zJJozo	xxEzRRo S    funcc                 X   ^  [        T 5      S[        S[        S[        4U 4S jj5       nU$ )NargskwargsrX   c                  P   > U S   nUR                   R                  T5      " U 0 UD6$ )Nr   )_rate_limit_enforcer
rate_limit)rf   rg   selfrd   s      ra   wrapperrate_limit.<locals>.wrappert   s-    Aw((33D94J6JJrc   )rS   rK   )rd   rl   s   ` ra   rj   rj   s   s:    
4[Ks Kc Kc K K Nrc   c                   8  ^  \ rS rSr% Sr\\S'   \\S'   \\S'   \	\S'   \
\S'   \\S'   \\S	'   \\S
'   \\S'   \\S'   S\4U 4S jjr\S\4S j5       r\" S\R,                  5      \\4S\S\SS4S jj5       5       r\" S\R,                  5      \\4S\S\S\R4                  4S jj5       5       r\" S\R,                  5      \\4S\S\SS4S jj5       5       r\" S\R,                  5      \SS\4S\\   S\\   S\S\\R4                     4S jj5       5       r\" S\R,                  5      \S\SS4S j5       5       r \S\!4S  j5       r"\" S!\R,                  5      \S\S\RF                  4S" j5       5       r$\" S#\R,                  5      \\%SSSS$\\&4S\S%\\'   S&\\(   S'\\)   S(\*S\S)\S\+4S* jj5       5       5       r,\" S+\R,                  5      \\%SSS\\&4S\S%\\'   S&\\(   S'\\)   S\S)\S\+4S, jj5       5       5       r-\" S-\R,                  5      \\%S\\&4S\\   S\S)\S\+4S. jj5       5       5       r.\" S/\R,                  5      \\%SS\\&4S\\   S\\   S\S)\S\\+   4
S0 jj5       5       5       r/\" S1\R,                  5      \\%\\&4S\S)\S\4S2 jj5       5       5       r0\" S3\R,                  5      \\%SSS\\&4S4\1S5\\   S6\\)   S7\\2   S\S)\SS4S8 jj5       5       5       r3\\\&4S9\1S5\S\S)\S\+4
S: jj5       r4\\\&4S9\1S\S)\SS;4S< jj5       r5\\\&\6Rn                  4S9\1S=\8\9   S\S)\S>\6S\:4S? jj5       r;\" S@\R,                  5      \\%\\&4S\S\S)\SS4SA jj5       5       5       r<\" SB\R,                  5      \\%SSS\\&4SC\=S9\1SD\>SE\\?   SF\\@   SG\\A   S\S)\S\*4SH jj5       5       5       rB\" SI\R,                  5      \\%SSSS\\&4S9\1SC\=SD\\>   SE\\?   SF\\@   SG\\A   S\S)\S\*4SJ jj5       5       5       rC\" SK\R,                  5      \\%SSS\\&4S9\1SC\=SD\>SE\\?   SF\\@   SG\\A   S\S)\S\*4SL jj5       5       5       rD\" SM\R,                  5      \E" \F" SN 5      \G" SO5      \H" SP5      SQSR9\\%SSSSS\I\\&4S9\1SC\\=   SS\\J   S\\   S\\   ST\\K   SU\LS\S)\S\M4SV jj5       5       5       5       rN\" SW\R,                  5      \\%SSS\\&4S9\1SC\\=   SS\\J   ST\\K   S\S)\SS4SX jj5       5       5       rO\" SY\R,                  5      \E" \F" SZ 5      \G" SO5      \H" SP5      SQSR9\\%\\&4S9\1S\S)\S\4S[ jj5       5       5       5       rP\" S\\R,                  5      \E" \F" S] 5      \G" SO5      \H" SP5      SQSR9\\%SS^SS\Q\\&4S9\1S_\>SC\\=   S`\SS\\J   ST\\K   SU\LS\S)\S\R4Sa jj5       5       5       5       rS\" Sb\R,                  5      \\%S^\\&4S9\1Sc\S\S)\S\M4
Sd jj5       5       5       rT\S\4Se j5       rU\SSf j5       rV\S\*4Sg j5       rW\S\4Sh j5       rX\S\4Si j5       rY\S\\&4Sj\S\Sk\1Sl\Sm\\Z\\[4      S\S)\S\\Sn\*4   4So jj5       r]\\\&4S\Sk\1S\S)\SSn4
Sp jj5       r^\S$\\&4S\Sk\1Sq\*S\S)\S\*4Sr jj5       r_\" Ss\R                  5      St\R                  Su\8\R                     SS4Sv j5       rcSt\R                  Sw\Sx\*SS4Sy jrd\" Sz\R                  5      S9\1S\R                  4S{ j5       re\" S|\R,                  5      S9\1S\f4S} j5       rgS~rhU =ri$ )
SegmentAPI|   zHAPI implementation utilizing the new segment-based internal architecture	_settings_sysdb_manager	_executor	_producer_product_telemetry_client_opentelemetry_client
_tenant_id	_topic_nsri   systemc                   > [         TU ]  U5        UR                  U l        U R	                  [
        5      U l        U R	                  [        5      U l        U R	                  [        5      U l
        U R	                  [        5      U l        U R	                  [        5      U l        U R	                  [        5      U l        U R	                  ["        5      U l        U R&                  R	                  [(        5      U l        g N)super__init__settingsrq   requirer   rr   r   rs   r   rt   r   _quota_enforcerr$   rv   r!   rw   r%   ru   _systemr   ri   )rk   rz   	__class__s     ra   r~   SegmentAPI.__init__   s     ll5)^4h/#||M:)-6L)M&%)\\2E%F"h/$(LL$8$89J$K!rc   rX   c                 >    [        [        R                  " 5       5      $ r|   )inttimetime_nsrk   s    ra   	heartbeatSegmentAPI.heartbeat   s    4<<>""rc   zSegmentAPI.create_databasenametenantNc                     [        U5      S:  a  [        S5      eU R                  R                  [        R
                  UUS9  U R                  R                  [        5       UUS9  g )NrZ   z0Database name must be at least 3 characters long)actionr   r   )idr   r   )	r\   r]   r   enforcer   CREATE_DATABASErr   create_databaserR   rk   r   r   s      ra   r   SegmentAPI.create_database   sg     t9q=OPP$$)) 	% 	
 	##w 	$ 	
rc   zSegmentAPI.get_databasec                 4    U R                   R                  XS9$ N)r   r   )rr   get_databaser   s      ra   r   SegmentAPI.get_database   s     {{''T'AArc   zSegmentAPI.delete_databasec                 6    U R                   R                  XS9  g r   )rr   delete_databaser   s      ra   r   SegmentAPI.delete_database   s     	###=rc   zSegmentAPI.list_databaseslimitoffsetc                 6    U R                   R                  XUS9$ )N)r   r   r   )rr   list_databases)rk   r   r   r   s       ra   r   SegmentAPI.list_databases   s     {{))V)TTrc   zSegmentAPI.create_tenantc                 j    [        U5      S:  a  [        S5      eU R                  R                  US9  g )NrZ   z.Tenant name must be at least 3 characters longr   )r\   r]   rr   create_tenantrk   r   s     ra   r   SegmentAPI.create_tenant   s5     t9q=MNN!! 	" 	
rc   c                 *    [        S[        [        /S9$ )N )user_idr   	databases)r   r   r   r   s    ra   get_user_identitySegmentAPI.get_user_identity   s    !'(
 	
rc   zSegmentAPI.get_tenantc                 4    U R                   R                  US9$ )Nr   )rr   
get_tenantr   s     ra   r   SegmentAPI.get_tenant   s     {{%%4%00rc   zSegmentAPI.create_collectionFschemaconfigurationmetadataget_or_createdatabasec                    Ub  [        U5        [        U5        U R                  R                  [        R
                  UUUS9  [        5       n[        UUUS [        U=(       d
    [        5       U5      UUS S9n	U R                  R                  U	R                  U	R                  UU=(       d
    [        5       / U	R                  S UUUS9
u  pU(       a@  U R                  R!                  U
5      nU H  nU R                  R#                  U5        M      O[$        R'                  SU S35        U R(                  R+                  [-        [/        U5      S95        [1        S[/        U5      05        U
$ )Nr   r   r   r   )r   r   r   serialized_schemaconfiguration_jsonr   r   	dimension)
r   r   r   r   segmentsr   r   r   r   r   Collection z/ already exists, returning existing collection.)collection_uuidr   )r:   rb   r   r   r   CREATE_COLLECTIONrR   CollectionModelr   r
   rr   create_collectionr   r   r   rs   #prepare_segments_for_new_collectioncreate_segmentloggerdebugrv   capturerF   strr    )rk   r   r   r   r   r   r   r   r   modelcollcreatedr   segments                 ra   r   SegmentAPI.create_collection   se    h' 	$$++	 	% 	
 W"F@!>!@(  
 55xx'J+H+J^^' 6 
 }}HHNH#**73 $ LLdV#RS 	&&..' #B	
 	'(93r7'CDrc   z#SegmentAPI.get_or_create_collectionc           
      ,    U R                  UUUUSUUS9$ )NT)r   r   r   r   r   r   r   )r   )rk   r   r   r   r   r   r   s          ra   get_or_create_collection#SegmentAPI.get_or_create_collection&  s1     %%' & 
 	
rc   zSegmentAPI.get_collectionc                 l    U R                   R                  XUS9nU(       a  US   $ [        SU S35      e)Nr   r   r   r   r    does not exist.)rr   get_collectionsr*   rk   r   r   r   existings        ra   get_collectionSegmentAPI.get_collectionA  sF     ;;..x / 
 A;+dV3C DEErc   zSegmentAPI.list_collectionc                     U R                   R                  [        R                  UUS9  U R                  R                  XX4S9$ )N)r   r   r   )r   r   r   r   )r   r   r   LIST_COLLECTIONSrr   r   )rk   r   r   r   r   s        ra   list_collectionsSegmentAPI.list_collectionsS  sO     	$$** 	% 	
 {{**v + 
 	
rc   zSegmentAPI.count_collectionsc                 4    U R                   R                  XS9$ )Nr   r   )rr   count_collections)rk   r   r   s      ra   r   SegmentAPI.count_collectionsg  s     {{,,F,NNrc   zSegmentAPI._modifyr   new_namenew_metadatanew_configurationc                    U(       a  [        U5        U(       a  [        U5        U R                  U5      nU R                  R	                  [
        R                  UUUS9  U(       a+  U(       a$  U(       a  U R                  R                  UUUUS9  g U(       a"  U(       a  U R                  R                  XUS9  g U(       a"  U(       a  U R                  R                  XUS9  g U(       a"  U(       a  U R                  R                  XUS9  g U(       a  U R                  R                  XS9  g U(       a  U R                  R                  XS9  g U(       a  U R                  R                  XS9  g g )	Nr   )r   r   r   )r   r   )r   r   )r   r   r   )r   )r   )	rb   r;   _get_collectionr   r   r   UPDATE_COLLECTIONrr   update_collection)rk   r   r   r   r   r   r   _s           ra   _modifySegmentAPI._modifyq  s9    X&$\2   $$$++!	 	% 	
 ):KK))%/	 *  ,KK))"l)S+KK))1B *  /KK))9J *  KK))")<KK))")DKK))")N rc   collection_idc                     [        S5      e)Nz4Collection forking is not implemented for SegmentAPINotImplementedError)rk   r   r   r   r   s        ra   _forkSegmentAPI._fork  s     "B
 	
rc   IndexingStatusc                     [        S5      e)Nz1Indexing status is not implemented for SegmentAPIr   rk   r   r   r   s       ra   _get_indexing_statusSegmentAPI._get_indexing_status  s     ""UVVrc   searches
read_levelc                     [        S5      e)Nz(Search is not implemented for SegmentAPIr   )rk   r   r   r   r   r   s         ra   _searchSegmentAPI._search  s     ""LMMrc   zSegmentAPI.delete_collectionc                    U R                   R                  XUS9nU(       aP  U R                  R                  US   R                  5        U R                   R                  US   R                  X#S9  g [        SU S35      e)Nr   r   r   r   r   )rr   r   rs   delete_segmentsr   delete_collectionr]   r   s        ra   r   SegmentAPI.delete_collection  s|     ;;..x / 
 MM))(1+..9KK))v *  {4&0@ABBrc   zSegmentAPI._addids
embeddings	metadatas	documentsurisc	                    U R                  U5      n	U R                  R                  U[        R                  R
                  5        [        XXEU4SU R                  5       05        [        [        [        R                  R
                  UUUUUS95      n
U R                  X5        U R                  R                  [        R
                  UUUUUUUS9  U R                  R                  X*5        U R                   R#                  [%        ['        U5      [)        U5      Ub  [)        U5      OSUb  [)        U5      OSUb  [)        U5      OSS95        g)Nmax_batch_sizer   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   
add_amountwith_metadatawith_documents	with_urisT)r   rs   hint_use_collectiont	OperationADDr>   get_max_batch_sizelist_records_validate_embedding_record_setr   r   r   ru   submit_embeddingsrv   r   rA   r   r\   )rk   r   r   r   r   r   r   r   r   r   records_to_submits              ra   _addSegmentAPI._add  s5    ##M2))-IiD9t6689	
 !%##	
 	++DD$$::!' 	% 		
 	((J&&.. #M 2s8*3*?c#hQ+4+@s3xa&*&6#c(A	
 rc   zSegmentAPI._updatec	                    U R                  U5      n	U R                  R                  U[        R                  R
                  5        [        X#XEU4SU R                  5       05        [        [        [        R                  R
                  UUUUUS95      n
U R                  X5        U R                  R                  [        R
                  UUUUUUS9  U R                  R                  X5        U R                   R#                  [%        ['        U5      [)        U5      U(       a  [)        U5      OSU(       a  [)        U5      OSU(       a  [)        U5      OSU(       a  [)        U5      OSS95        g)Nr  r  )r   r   r   r   r   r   r   r   )r   update_amountwith_embeddingsr  r  r  T)r   rs   r	  r
  r  UPDATEr>   r  r  r  r  r   r   r   ru   r  rv   r   rD   r   r\   rk   r   r   r   r   r   r   r   r   r   r  s              ra   _updateSegmentAPI._update  s8    ##M2))-9K9KLiD9t6689	
 !""%##	
 	++DD$$==! 	% 	
 	((J&&..! #M 2!#h3=J109c)nq1:s9~'+#d)		
 rc   zSegmentAPI._upsertc	                    U R                  U5      n	U R                  R                  U[        R                  R
                  5        [        X#XEU4SU R                  5       05        [        [        [        R                  R
                  UUUUUS95      n
U R                  X5        U R                  R                  [        R
                  UUUUUUUS9  U R                  R                  X5        g)Nr  r  r  T)r   rs   r	  r
  r  UPSERTr>   r  r  r  r  r   r   r   ru   r  r  s              ra   _upsertSegmentAPI._upsertN  s     ##M2))-9K9KLiD9t6689	
 !""%##	
 	++DD$$==!' 	% 		
 	((Jrc   zSegmentAPI._getc                 "    [        U [        5      $ r|   
isinstancer+   es    ra   <lambda>SegmentAPI.<lambda>      :a9M+Nrc         T)r   waitstopreraisewherewhere_documentincludec
                    [        [        U5      U(       a  [        U5      OSS.5        U R                  U5      n
Ub  [	        U5        Ub  [        U5        U R                  R                  [        R                  UUUUUS9  U(       a  [        U5      OSnU R                  R                  [        [        U5      UU(       a  UOSSU;   a  UOSSU;   a  UOSSU;   a  UOSS95        U R                  R                  [        U
[!        X#U5      [#        U=(       d    SU5      [%        SU;   SU;   SU;   S	SU;   5      5      5      $ )
Nr   r   	ids_count)r   r   r   r-  r.  r   r   r   r   )r   r2  r   include_metadatainclude_documentsinclude_urisr   F)r    r   r\   _scanr<   r=   r   r   r   GETrv   r   rC   rt   getr   r   r   r   )rk   r   r   r-  r   r   r.  r/  r   r   scan
ids_amounts               ra   _getSegmentAPI._get}  sI   * 	'!$]!3),SX!	
 zz-( 5!%#N3$$::) 	% 	
 "%SX!
&&.. #M 2$$e!/:g/E10;w0F*A+1W+<Z!		
 ~~!!s>2fk5)7* G+7*g%	
 	
rc   zSegmentAPI._deletec           
         [        [        U5      U(       a  [        U5      OSS.5        Ub  [        U5        Ub  [	        U5        Ub  UbD  [        U5      S:X  a5  Ub  Ub/  [        U5      S:X  a   Ub  Ub  [        U5      S:X  a  [        S5      eU R                  U5      nU R                  R                  [        R                  UUUUS9  U R                  R                  U[        R                  R                  5        U(       d  U(       d  U(       d3  U R                  R!                  [#        U[%        X#U5      5      5      S   nOUn[        U5      S:X  a  g ['        [)        [        R                  R                  US95      n	U R+                  UR,                  U	5        U R.                  R1                  X5        U R2                  R5                  [7        [        U5      [        U5      S95        g )Nr   r1  aU  
                You must provide either ids, where, or where_document to delete. If
                you want to delete all data in a collection you can delete the
                collection itself using the delete_collection method. Or alternatively,
                you can get() all the relevant ids and then delete them.
                )r   r   r   r-  r.  r   )	operationr   )r   delete_amount)r    r   r\   r<   r=   r]   r6  r   r   r   DELETErs   r	  r
  r  rt   r8  r   r   r  r  r  
collectionru   r  rv   r   rB   )
rk   r   r   r-  r.  r   r   r9  ids_to_deleter  s
             ra   _deleteSegmentAPI._delete  s    	'!$]!3),SX!	
 5!%#N3 [S_SQ5#4Uq&".3~3F!3K   zz-($$==) 	% 	
 	))-9K9KL^C NN..fS@AM  M}" q{{11}E
 	++DOO=NO((J&&..! #M 2#mBT	
rc   zSegmentAPI._countc                 "    [        U [        5      $ r|   r!  r#  s    ra   r%  r&    r'  rc   c                     [        S[        U5      05        U R                  R                  [	        U R                  U5      5      5      $ )Nr   )r    r   rt   countr   r6  r   s       ra   _countSegmentAPI._count  s9     	']9K'LM~~##Idjj.G$HIIrc   zSegmentAPI._queryc                 "    [        U [        5      $ r|   r!  r#  s    ra   r%  r&  /  r'  rc   
   query_embeddings	n_resultsc
                    [        [        U5      U[        U5      S.5        [        U5      n
U(       a  [        U5      OSnU R                  R	                  [        [        U5      U
UUUb  U
OSUb  U
OSSU;   a  U
OSSU;   a  U
OSSU;   a  U
OSSU;   a  U
OSS9
5        Ub  [        U5        Ub  [        U5        U R                  U5      nU H'  nU R                  UR                  [        U5      SS	9  M)     U R                  R                  [        R                  UUUUUS
9  U R                  R!                  [#        U[%        X$5      ['        S XV5      [)        SU;   SU;   SU;   SU;   SU;   5      5      5      $ )N)r   rM  r-  r   r   r   r   	distances)
r   query_amountfiltered_ids_amountrM  with_metadata_filterwith_document_filterinclude_metadatasr4  r5  include_distancesFupdate)r   r   r-  r.  rL  rM  r   )r    r   r\   rv   r   rE   r<   r=   r6  _validate_dimensionrA  r   r   r   QUERYrt   knnr   r   r   r   )rk   r   rL  r   rM  r-  r.  r/  r   r   rP  r:  r9  	embeddings                 ra   _querySegmentAPI._query&  s   8 	'!$]!3&U	
 +,!$SX!
&&..  #M 2)$.#5:5F\A5C5O\UV2=2H,a2=2H,a-3w->\A2=2H,a	
  5!%#N3zz-()I$$T__c)nU$S * 	$$<<)- 	% 	
 ~~!!$0tU37* G+7*7*g%	
 	
rc   zSegmentAPI._peeknc                 L    [        S[        U5      05        U R                  XS9$ )Nr   )r   )r    r   r;  )rk   r   r^  r   r   s        ra   _peekSegmentAPI._peek}  s'     	']9K'LMyyy00rc   c                     [         $ r|   r'   r   s    ra   get_versionSegmentAPI.get_version  s    rc   c                     g r|    r   s    ra   reset_stateSegmentAPI.reset_state  s    rc   c                 8    U R                   R                  5         g)NT)r   rg  r   s    ra   resetSegmentAPI.reset  s      "rc   c                     U R                   $ r|   )rq   r   s    ra   get_settingsSegmentAPI.get_settings  s    ~~rc   c                 .    U R                   R                  $ r|   )ru   r  r   s    ra   r  SegmentAPI.get_max_batch_size  s    ~~,,,rc   function_idinput_collection_idoutput_collectionparamsr	   c                     [        S5      ezNAttached functions are not supported in the Segment API (local embedded mode).zAttached functions are only supported when connecting to a Chroma server via HttpClient. The Segment API (embedded mode) does not support attached function operations.r   )rk   rq  r   rr  rs  rt  r   r   s           ra   attach_functionSegmentAPI.attach_function  s     "]
 	
rc   c                     [        S5      erv  r   )rk   r   rr  r   r   s        ra   get_attached_function SegmentAPI.get_attached_function  s     "]
 	
rc   delete_outputc                     [        S5      erv  r   )rk   r   rr  r|  r   r   s         ra   detach_functionSegmentAPI.detach_function  s     "]
 	
rc   z)SegmentAPI._validate_embedding_record_setrA  recordsc                     [        S[        US   5      05        U H(  nUS   c  M  U R                  U[        US   5      SS9  M*     g)zQValidate the dimension of an embedding record before submitting it to the system.r   r   r[  NTrV  )r    r   rX  r\   )rk   rA  r  records       ra   r  )SegmentAPI._validate_embedding_record_set  sT     	'Z=M9N'OPFk".((F;$7 8 )  rc   dimrW  c                     US   c2  U(       a*  UR                   nU R                  R                  XBS9  X!S'   ggUS   U:w  a  [        SU SUS    35      eg)zValidate that a collection supports records of the given dimension. If update
is true, update the collection if the collection doesn't already have a
dimension.r   N)r   r   zEmbedding dimension z* does not match collection dimensionality )r   rr   r   r)   )rk   rA  r  rW  r   s        ra   rX  SegmentAPI._validate_dimension  sw     k"*]]---C*-;'  $++&se+UV`alVmUno  rc   zSegmentAPI._get_collectionc                     U R                   R                  US9nU(       a  [        U5      S:X  a  [        SU S35      eUS   $ )N)r   r   r   r   )rr   r   r\   r*   )rk   r   collectionss      ra   r   SegmentAPI._get_collection  sG    kk11]1Cc+.!3+m_<L MNN1~rc   zSegmentAPI._scanc           	      L   U R                   R                  U5      nUS    Vs0 s H  o3S   U_M
     nn[        US   U[        R                  R
                     U[        R                  R                     UR                  [        R                  R                  S 5      S9$ s  snf )Nr   scoperA  )rA  rZ  r   r  )	rr   get_collection_with_segmentsr   r
  SegmentScopeVECTORMETADATAr8  RECORD)rk   r   collection_and_segmentsr   scope_to_segments        ra   r6  SegmentAPI._scan  s    "&++"J"J#
 6MZ5X
5X'Gg%5X 	 
 .|< !6!67%ann&=&=>#''(=(=tD
 	

s   B!)	rt   rs   rw   ru   rv   r   ri   rq   rr   )rX   N)j__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r   r%   r$   r!   r   r   r   r~   rP   r   r   r#   r"   	OPERATIONr   r   r
  Databaser   r   rG   rH   r   r   r   r   Tenantr   rj   r   r2   r
   r,   boolr   r   r   r   r   r   rQ   r   r   r   r   r1   INDEX_AND_WALrJ   rT   r9   r   r   r-   r.   r/   r0   r3   r  r  r  r   r   r   r   r?   r4   r5   r6   r7   r;  rC  rH  r@   r8   r\  r`  rc  rg  rj  rm  r  rL   rK   rO   rw  rz  r~  ALLr&   OperationRecordr  rX  r   r   r6  __static_attributes____classcell__)r   s   @ra   ro   ro   |   s   RM55..ON++
Lv 
L #3 # # .0H0R0RS7E 
C 
 
$ 
  T
  +-E-O-OP4B B Bc Bqzz B  QB .0H0R0RS7E >C > >$ >  T> -/G/Q/QR  $ $$	U}U U 	U
 
!**	U  SU ,.F.P.PQ
# 
$ 
  R
 
< 
 
 )+C+M+MN1s 1qxx 1  O1 02J2T2TU $(AE15#$(GG  G   =>	G
 -.G G G G 
G   VGR -/G/Q/Q  $(AE15$(

  
   =>	

 -.
 
 
 

  

, -/G/Q/QR #$(	FsmF F 	F
 
F   SF .0H0R0RS  $ $$(
}
 
 	

 
 
/	"
   T
" 02J2T2TU %(OO O 
	O   VO &(@(J(JK #'59EI$(2O2O 3-2O 12	2O
 $$AB2O 2O 2O 
2O   L2Oh 
 %(	
	
 	
 		

 	
 
	
 	
  %(	WW W 	W
 
W W 
 %( ) 7 7NN v,N 	N
 N N 
N N 02J2T2TU %(	CC C 	C
 
C   VC$ #%=%G%GH *.)-#$(33 3 	3
 I&3 I&3 tn3 3 3 
3   I3j &(@(J(JK
 ,0)-)-#$(44 4 Z(	4
 I&4 I&4 tn4 4 4 
4   L4l &(@(J(JK *.)-#$(** * 	*
 I&* I&* tn* * * 
*   L*X #%=%G%GH
 !NO]"	  "!%# $263$(>
>
 c]>
 	>

 }>
 >
 !/>
 >
 >
 >
 
>
   I>
@ &(@(J(JK "!%26$(I
I
 c]I
 	I

 !/I
 I
 I
 
I
   LI
V %'?'I'IJ
 !NO]"	  %(	JJ J 	J
 
J   KJ %'?'I'IJ  !NO]"	 
 "!%26<$(E
E
 %E
 c]	E

 E
 E
 !/E
 E
 E
 E
 
E
   K E
N $&>&H&HI $(11 1 	1
 1 
1   J1 S     t   h   -C - -  ,0$(

 
 "	

 
 c3h(
 
 
 
!4'	(
 
  
 %(

 "
 	

 
 

 
 
 $$(

 "
 	

 
 
 

 
$ 35M5Q5Q	,,	15a6G6G1H				,,-0:>	$ .0H0L0LMT all  N $&>&H&HI
4 
D 
 J
rc   ro   r>  r   r   r   r   r   c           	   #   P  #    U/ :X  a  Sn[        U5       H  u  pgSnU(       a  X6   nU(       a  XF   n	U(       a	  0 UESU	0EnOSU	0nU(       a  XV   n
U(       a	  0 UESU
0EnOSU
0n[        R                  " UUb  X&   OS[        R                  R                  UU S9nUv   M     g7f)zeConvert parallel lists of embeddings, metadatas and documents to a sequence of
SubmitEmbeddingRecordsNzchroma:documentz
chroma:uri)r   r[  encodingr   r>  )	enumerater
  r  ScalarEncodingFLOAT32)r>  r   r   r   r   r   ir   r   documenturir  s               ra   r  r    s      R
3 |H |HDhD(98D-x8'C:h:c:(#.""'1'=jm4%%--
 5  s   B$B&)NNNN){typingr   tenacityr   r   r   r   chromadb.apir   $chromadb.api.models.AttachedFunctionr	   %chromadb.api.collection_configurationr
   r   r   chromadb.authr   chromadb.configr   r   r   r   chromadb.db.systemr   chromadb.quotar   r   chromadb.rate_limitr   chromadb.segmentr   $chromadb.execution.executor.abstractr   &chromadb.execution.expression.operatorr   r   r   r   r   "chromadb.execution.expression.planr   r   r    chromadb.telemetry.opentelemetryr    r!   r"   r#   chromadb.telemetry.productr$   chromadb.ingestr%   chromadb.typesr&   r   chromadbr(   chromadb.errorsr)   r*   r+   chromadb.api.typesr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   !chromadb.telemetry.product.eventsrA   rB   rC   rD   rE   rF   typesr
  rG   rH   rI   rJ   rK   rL   rM   rN   rO   	overridesrP   uuidrQ   rR   	functoolsrS   r   loggingr^   rT   rU   	getLoggerr  r   r   rb   rj   ro   r  r  r  rf  rc   ra   <module>r     s     N N "E 
 ' N N $ 0 1 + 9 W W J J  > $ 8   
     .  
 
 
      	 5CxS)*			8	$  (Q 1 N
 N
h (,%)%),{{,	, $, 	"	,
 	", 4., q  $,-,rc   