
    ei                     :   d dl mZ d dlmZmZmZmZ d dlmZ erd dl	m
Z
 d dlmZmZmZ d dlmZ d dlmZmZmZmZ d dlmZ d d	lmZmZ d d
lmZ d dlmZ d dlm Z  d dl!m"Z"m#Z#m$Z$m%Z%m&Z& d dl'm(Z(m)Z)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z6 d dl7m8Z8 d dl9m:Z:m;Z;m<Z< d dl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZR d dlSmTZTmUZUmVZVmWZWmXZXmYZY d dl4mZZ[ d dl m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZd d dlemfZf d dlgmhZhmiZi d dljmkZk d dllZld dlmZmd dlnZnd dl'moZo  ecdebde`f         Zp emj                  er      Zsd etd!dfd"Zud#epd!epfd$Zv G d% d&e      Zw	 	 	 	 d.d'e[j                  d(e?d)e\e@   d*e\eA   d+e\eB   d,e\eE   d!e^e[j                  ddf   fd-Zzy)/    )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                     d|  }t        |       dk  st        |       dkD  rt        |      t        j                  d|       st        |      d| v rt        |      t        j                  d|       rt        |      y )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     ^/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/chromadb/api/segment.pycheck_index_namerb   _   s    	 l	  :c*o2o88=zJozo	xxEzRo S    funcc                 T     t               dt        dt        dt        f fd       }|S )NargskwargsrX   c                  P    | d   } |j                   j                        | i |S )Nr   )_rate_limit_enforcer
rate_limit)rf   rg   selfrd   s      ra   wrapperzrate_limit.<locals>.wrappert   s/    Aw9t((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                       e Zd ZU dZeed<   eed<   eed<   eed<   e	ed<   e
ed<   eed<   eed	<   eed
<   eed<   def fdZedefd       Z edej*                        eefdededdfd              Z edej*                        eefdededej2                  fd              Z edej*                        eefdededdfd              Z edej*                        eddefdee   dee   dedeej2                     fd              Z edej*                        ededdfd              Zede fd       Z! ed ej*                        ededejD                  fd!              Z# ed"ej*                        ee$dddd#ee%fded$ee&   d%ee'   d&ee(   d'e)ded(ede*fd)                     Z+ ed*ej*                        ee$dddee%fded$ee&   d%ee'   d&ee(   ded(ede*fd+                     Z, ed,ej*                        ee$dee%fdee   ded(ede*fd-                     Z- ed.ej*                        ee$ddee%fdee   dee   ded(edee*   f
d/                     Z. ed0ej*                        ee$ee%fded(edefd1                     Z/ ed2ej*                        ee$dddee%fd3e0d4ee   d5ee(   d6ee1   ded(eddfd7                     Z2eee%fd8e0d4eded(ede*f
d9       Z3eee%fd8e0ded(edd:fd;       Z4eee%e5jl                  fd8e0d<e7e8   ded(ed=e5de9fd>       Z: ed?ej*                        ee$ee%fdeded(eddfd@                     Z; edAej*                        ee$dddee%fdBe<d8e0dCe=dDee>   dEee?   dFee@   ded(ede)fdG                     ZA edHej*                        ee$ddddee%fd8e0dBe<dCee=   dDee>   dEee?   dFee@   ded(ede)fdI                     ZB edJej*                        ee$dddee%fd8e0dBe<dCe=dDee>   dEee?   dFee@   ded(ede)fdK                     ZC edLej*                         eD eEdM        eFdN       eGdO      dPQ      ee$dddddeHee%fd8e0dBee<   dReeI   dee   dee   dSeeJ   dTeKded(edeLfdU                            ZM edVej*                        ee$dddee%fd8e0dBee<   dReeI   dSeeJ   ded(eddfdW                     ZN edXej*                         eD eEdY        eFdN       eGdO      dPQ      ee$ee%fd8e0ded(edefdZ                            ZO ed[ej*                         eD eEd\        eFdN       eGdO      dPQ      ee$dd]ddePee%fd8e0d^e=dBee<   d_edReeI   dSeeJ   dTeKded(edeQfd`                            ZR edaej*                        ee$d]ee%fd8e0dbeded(edeLf
dc                     ZSedefdd       ZTed}de       ZUede)fdf       ZVedefdg       ZWedefdh       ZXedee%fdiededje0dkedleeYeeZf      ded(ede[dme)f   fdn       Z\eee%fdedje0ded(eddmf
do       Z]ed#ee%fdedje0dpe)ded(ede)fdq       Z^ edrej                        dsej                  dte7ej                     ddfdu       Zbdsej                  dvedwe)ddfdxZc edyej                        d8e0dej                  fdz       Zd ed{ej*                        d8e0deefd|       Zf xZgS )~
SegmentAPIzHAPI implementation utilizing the new segment-based internal architecture	_settings_sysdb_manager	_executor	_producer_product_telemetry_client_opentelemetry_client
_tenant_id	_topic_nsri   systemc                    t         |   |       |j                  | _        | j	                  t
              | _        | j	                  t              | _        | j	                  t              | _
        | j	                  t              | _        | j	                  t              | _        | j	                  t              | _        | j	                  t"              | _        | j&                  j	                  t(              | _        y N)super__init__settingsro   requirer   rp   r   rq   r   rr   r   _quota_enforcerr$   rt   r!   ru   r%   rs   _systemr   ri   )rk   rx   	__class__s     ra   r|   zSegmentAPI.__init__   s     ll5)^4h/#||M:)-6L)M&%)\\2E%F"h/$(LL$8$89J$K!rc   rX   c                 <    t        t        j                               S rz   )inttimetime_nsrk   s    ra   	heartbeatzSegmentAPI.heartbeat   s    4<<>""rc   zSegmentAPI.create_databasenametenantNc                     t        |      dk  rt        d      | j                  j                  t        j
                  ||       | j                  j                  t               ||       y )NrZ   z0Database name must be at least 3 characters long)actionr   r   )idr   r   )	r\   r]   r   enforcer   CREATE_DATABASErp   create_databaserR   rk   r   r   s      ra   r   zSegmentAPI.create_database   sg     t9q=OPP$$)) 	% 	
 	##w 	$ 	
rc   zSegmentAPI.get_databasec                 <    | j                   j                  ||      S N)r   r   )rp   get_databaser   s      ra   r   zSegmentAPI.get_database   s     {{''T&'AArc   zSegmentAPI.delete_databasec                 >    | j                   j                  ||       y r   )rp   delete_databaser   s      ra   r   zSegmentAPI.delete_database   s     	##f#=rc   zSegmentAPI.list_databaseslimitoffsetc                 >    | j                   j                  |||      S )N)r   r   r   )rp   list_databases)rk   r   r   r   s       ra   r   zSegmentAPI.list_databases   s      {{))fV)TTrc   zSegmentAPI.create_tenantc                 n    t        |      dk  rt        d      | j                  j                  |       y )NrZ   z.Tenant name must be at least 3 characters longr   )r\   r]   rp   create_tenantrk   r   s     ra   r   zSegmentAPI.create_tenant   s5     t9q=MNN!! 	" 	
rc   c                 0    t        dt        t        g      S )N )user_idr   	databases)r   r   r   r   s    ra   get_user_identityzSegmentAPI.get_user_identity   s    !'(
 	
rc   zSegmentAPI.get_tenantc                 :    | j                   j                  |      S )Nr   )rp   
get_tenantr   s     ra   r   zSegmentAPI.get_tenant   s     {{%%4%00rc   zSegmentAPI.create_collectionFschemaconfigurationmetadataget_or_createdatabasec                    |t        |       t        |       | j                  j                  t        j
                  |||       t               }t        |||d t        |xs
 t               |      ||d       }	| j                  j                  |	j                  |	j                  ||xs
 t               g |	j                  d |||
      \  }
}|r>| j                  j!                  |
      }|D ]  }| j                  j#                  |        nt$        j'                  d| d       | j(                  j+                  t-        t/        |                   t1        dt/        |      i       |
S )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
   rp   create_collectionr   r   r   rq   #prepare_segments_for_new_collectioncreate_segmentloggerdebugrt   capturerF   strr    )rk   r   r   r   r   r   r   r   r   modelcollcreatedr   segments                 ra   r   zSegmentAPI.create_collection   sl    h' 	$$++	 	% 	
 W"F@!>!@(  
 55xx'J+H+J^^' 6 
g }}HHNH# 4**734 LLdV#RS 	&&..' #B	
 	'(93r7'CDrc   z#SegmentAPI.get_or_create_collectionc           	      2    | j                  ||||d||      S )NT)r   r   r   r   r   r   r   )r   )rk   r   r   r   r   r   r   s          ra   get_or_create_collectionz#SegmentAPI.get_or_create_collection&  s1     %%' & 
 	
rc   zSegmentAPI.get_collectionc                 j    | j                   j                  |||      }|r|d   S t        d| d      )Nr   r   r   r   r    does not exist.)rp   get_collectionsr*   rk   r   r   r   existings        ra   get_collectionzSegmentAPI.get_collectionA  sH     ;;..fx / 
 A;+dV3C DEErc   zSegmentAPI.list_collectionc                     | j                   j                  t        j                  ||       | j                  j                  ||||      S )N)r   r   r   )r   r   r   r   )r   r   r   LIST_COLLECTIONSrp   r   )rk   r   r   r   r   s        ra   list_collectionszSegmentAPI.list_collectionsS  sS     	$$** 	% 	
 {{**v + 
 	
rc   zSegmentAPI.count_collectionsc                 <    | j                   j                  ||      S )Nr   r   )rp   count_collections)rk   r   r   s      ra   r   zSegmentAPI.count_collectionsg  s     {{,,FX,NNrc   zSegmentAPI._modifyr   new_namenew_metadatanew_configurationc                    |rt        |       |rt        |       | j                  |      }| j                  j	                  t
        j                  |||       |r$|r"|r | j                  j                  ||||       y |r!|r| j                  j                  |||       y |r!|r| j                  j                  |||       y |r!|r| j                  j                  |||       y |r| j                  j                  ||       y |r| j                  j                  ||       y |r| j                  j                  ||       y y )	Nr   )r   r   r   )r   r   )r   r   )r   r   r   )r   )r   )	rb   r;   _get_collectionr   r   r   UPDATE_COLLECTIONrp   update_collection)rk   r   r   r   r   r   r   _s           ra   _modifyzSegmentAPI._modifyq  sF    X&$\2   $$$++!	 	% 	
 ):KK))%/	 *  ,KK))"8l)S+KK))1B *  /KK))\9J *  KK))"8)<KK))"|)DKK))"<M)N rc   collection_idc                     t        d      )Nz4Collection forking is not implemented for SegmentAPINotImplementedError)rk   r   r   r   r   s        ra   _forkzSegmentAPI._fork  s     "B
 	
rc   IndexingStatusc                     t        d      )Nz1Indexing status is not implemented for SegmentAPIr   rk   r   r   r   s       ra   _get_indexing_statuszSegmentAPI._get_indexing_status  s     ""UVVrc   searches
read_levelc                     t        d      )Nz(Search is not implemented for SegmentAPIr   )rk   r   r   r   r   r   s         ra   _searchzSegmentAPI._search  s     ""LMMrc   zSegmentAPI.delete_collectionc                    | j                   j                  |||      }|rT| j                  j                  |d   j                         | j                   j                  |d   j                  ||       y t        d| d      )Nr   r   r   r   r   )rp   r   rq   delete_segmentsr   delete_collectionr]   r   s        ra   r   zSegmentAPI.delete_collection  s     ;;..fx / 
 MM))(1+..9KK))v *  {4&0@ABBrc   zSegmentAPI._addids
embeddings	metadatas	documentsurisc	                    | j                  |      }	| j                  j                  |t        j                  j
                         t        |||||fd| j                         i       t        t        t        j                  j
                  |||||            }
| j                  |	|
       | j                  j                  t        j
                  |||||||       | j                  j                  ||
       | j                   j#                  t%        t'        |      t)        |      |t)        |      nd|t)        |      nd|t)        |      nd             y)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   rq   hint_use_collectiont	OperationADDr>   get_max_batch_sizelist_records_validate_embedding_record_setr   r   r   rs   submit_embeddingsrt   r   rA   r   r\   )rk   r   r   r   r   r   r   r   r   r   records_to_submits              ra   _addzSegmentAPI._add  s?    ##M2))-I*iD9t6689	
 !%##	
 	++D2CD$$::!' 	% 		
 	((8IJ&&.. #M 2s8*3*?c#hQ+4+@s3xa&*&6#c(A	
 rc   zSegmentAPI._updatec	                    | j                  |      }	| j                  j                  |t        j                  j
                         t        |||||fd| j                         i       t        t        t        j                  j
                  |||||            }
| j                  |	|
       | j                  j                  t        j
                  ||||||       | j                  j                  ||
       | j                   j#                  t%        t'        |      t)        |      |rt)        |      nd|rt)        |      nd|rt)        |      nd|rt)        |      nd             y)Nr   r   )r   r   r   r   r   r   r   r   )r   update_amountwith_embeddingsr   r   r   T)r   rq   r   r   r   UPDATEr>   r   r   r   r   r   r   r   rs   r   rt   r   rD   r   r\   rk   r   r   r   r   r   r   r   r   r   r   s              ra   _updatezSegmentAPI._update  sB    ##M2))-9K9KL*iD9t6689	
 !""%##	
 	++D2CD$$==! 	% 	
 	((8IJ&&..! #M 2!#h3=J109c)nq1:s9~'+#d)		
 rc   zSegmentAPI._upsertc	           
         | j                  |      }	| j                  j                  |t        j                  j
                         t        |||||fd| j                         i       t        t        t        j                  j
                  |||||            }
| j                  |	|
       | j                  j                  t        j
                  |||||||       | j                  j                  ||
       y)Nr   r   r   T)r   rq   r   r   r   UPSERTr>   r   r   r   r   r   r   r   rs   r   r  s              ra   _upsertzSegmentAPI._upsertN  s     ##M2))-9K9KL*iD9t6689	
 !""%##	
 	++D2CD$$==!' 	% 		
 	((8IJrc   zSegmentAPI._getc                 "    t        | t              S rz   
isinstancer+   es    ra   <lambda>zSegmentAPI.<lambda>      :a9M+N rc         T)r   waitstopreraisewherewhere_documentincludec
                 X   t        t        |      |rt        |      ndd       | j                  |      }
|t	        |       |t        |       | j                  j                  t        j                  |||||       |rt        |      nd}| j                  j                  t        t        |      ||r|ndd|v r|ndd|v r|ndd|v r|nd             | j                  j                  t        |
t!        |||      t#        |xs d|      t%        d|v d|v d|v d	d|v                   S )
Nr   r   	ids_count)r   r   r   r  r  r   r   r   r   )r   r  r   include_metadatainclude_documentsinclude_urisr   F)r    r   r\   _scanr<   r=   r   r   r   GETrt   r   rC   rr   getr   r   r   r   )rk   r   r   r  r   r   r  r  r   r   scan
ids_amounts               ra   _getzSegmentAPI._get}  sK   * 	'!$]!3),SX!	
 zz-( 5!%#N3$$::) 	% 	
 "%SX!
&&.. #M 2$$e!/:g/E10;w0F*A+1W+<Z!		
 ~~!!sE>2fk5)7* G+7*g%	
 	
rc   zSegmentAPI._deletec           
         t        t        |      |rt        |      ndd       |t        |       |t	        |       ||=t        |      dk(  r/||+t        |      dk(  r||t        |      dk(  rt        d      | j                  |      }| j                  j                  t        j                  ||||       | j                  j                  |t        j                  j                         |s|s|s4| j                  j!                  t#        |t%        |||                  d   }n|}t        |      dk(  ry t'        t)        t        j                  j                  |            }	| j+                  |j,                  |	       | j.                  j1                  ||	       | j2                  j5                  t7        t        |      t        |                   y )Nr   r  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]   r  r   r   r   DELETErq   r   r   r   rr   r  r   r   r   r   r   
collectionrs   r   rt   r   rB   )
rk   r   r   r  r  r   r   r   ids_to_deleter   s
             ra   _deletez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((8IJ&&..! #M 2#mBT	
rc   zSegmentAPI._countc                 "    t        | t              S rz   r	  r  s    ra   r  zSegmentAPI.<lambda>  r  rc   c                     t        dt        |      i       | j                  j                  t	        | j                  |                  S )Nr   )r    r   rr   countr   r  r   s       ra   _countzSegmentAPI._count  s9     	']9K'LM~~##Idjj.G$HIIrc   zSegmentAPI._queryc                 "    t        | t              S rz   r	  r  s    ra   r  zSegmentAPI.<lambda>/  r  rc   
   query_embeddings	n_resultsc
                    t        t        |      |t        |      d       t        |      }
|rt        |      nd}| j                  j	                  t        t        |      |
||||
nd||
ndd|v r|
ndd|v r|
ndd|v r|
ndd|v r|
nd
             |t        |       |t        |       | j                  |      }|D ])  }| j                  |j                  t        |      d	       + | j                  j                  t        j                  |||||
       | j                  j!                  t#        |t%        ||      t'        d ||      t)        d|v d|v d|v d|v d|v                   S )N)r   r1  r  r   r   r   r   	distances)
r   query_amountfiltered_ids_amountr1  with_metadata_filterwith_document_filterinclude_metadatasr  r  include_distancesFupdate)r   r   r  r  r0  r1  r   )r    r   r\   rt   r   rE   r<   r=   r  _validate_dimensionr'  r   r   r   QUERYrr   knnr   r   r   r   )rk   r   r0  r   r1  r  r  r  r   r   r4  r!  r   	embeddings                 ra   _queryz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-() 	TI$$T__c)nU$S	T 	$$<<)- 	% 	
 ~~!!$i0tUN37* G+7*7*g%	
 	
rc   zSegmentAPI._peeknc                 T    t        dt        |      i       | j                  ||      S )Nr   )r   )r    r   r"  )rk   r   rA  r   r   s        ra   _peekzSegmentAPI._peek}  s)     	']9K'LMyyay00rc   c                     t         S rz   r'   r   s    ra   get_versionzSegmentAPI.get_version  s    rc   c                      y rz    r   s    ra   reset_statezSegmentAPI.reset_state  s    rc   c                 8    | j                   j                          y)NT)r   rH  r   s    ra   resetzSegmentAPI.reset  s      "rc   c                     | j                   S rz   )ro   r   s    ra   get_settingszSegmentAPI.get_settings  s    ~~rc   c                 .    | j                   j                  S rz   )rs   r   r   s    ra   r   zSegmentAPI.get_max_batch_size  s    ~~,,,rc   function_idinput_collection_idoutput_collectionparamsr	   c                     t        d      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   rN  r   rO  rP  rQ  r   r   s           ra   attach_functionzSegmentAPI.attach_function  s     "]
 	
rc   c                     t        d      rS  r   )rk   r   rO  r   r   s        ra   get_attached_functionz SegmentAPI.get_attached_function  s     "]
 	
rc   delete_outputc                     t        d      rS  r   )rk   r   rO  rW  r   r   s         ra   detach_functionzSegmentAPI.detach_function  s     "]
 	
rc   z)SegmentAPI._validate_embedding_record_setr'  recordsc                     t        dt        |d         i       |D ](  }|d   	| j                  |t        |d         d       * y)zQValidate the dimension of an embedding record before submitting it to the system.r   r   r?  NTr:  )r    r   r<  r\   )rk   r'  rZ  records       ra   r   z)SegmentAPI._validate_embedding_record_set  sY     	'Z=M9N'OP 	Fk".((F;$7 8 ) 	rc   dimr;  c                     |d   2|r/|j                   }| j                  j                  ||       ||d<   yy|d   |k7  rt        d| d|d          y)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   rp   r   r)   )rk   r'  r]  r;  r   s        ra   r<  zSegmentAPI._validate_dimension  s{     k"*]]--s-C*-
;'  $++&se+UV`alVmUno  rc   zSegmentAPI._get_collectionc                     | j                   j                  |      }|rt        |      dk(  rt        d| d      |d   S )N)r   r   r   r   )rp   r   r\   r*   )rk   r   collectionss      ra   r   zSegmentAPI._get_collection  sG    kk11]1Cc+.!3+m_<L MNN1~rc   zSegmentAPI._scanc           	      N   | j                   j                  |      }|d   D ci c]  }|d   |
 }}t        |d   |t        j                  j
                     |t        j                  j                     |j                  t        j                  j                  d             S c c}w )Nr   scoper'  )r'  r>  r   r\  )	rp   get_collection_with_segmentsr   r   SegmentScopeVECTORMETADATAr  RECORD)rk   r   collection_and_segmentsr   scope_to_segments        ra   r  zSegmentAPI._scan  s    "&++"J"J#
 6MZ5X
*1GGg%
 
 .|< !6!67%ann&=&=>#''(=(=tD
 	

s   B")rX   N)h__name__
__module____qualname____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"  r)  r-  r@   r8   r@  rC  rE  rH  rJ  rL  r   rL   rK   rO   rT  rV  rY  ALLr&   OperationRecordr   r<  r   r   r  __classcell__)r   s   @ra   rn   rn   |   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   rn   r$  r   r   r   r   r   c              #   $  K   |g k(  rd}t        |      D ]w  \  }}d}|r||   }|r||   }	|r	i |d|	i}nd|	i}|r||   }
|r	i |d|
i}nd|
i}t        j                  ||||   ndt        j                  j                  ||       }| y yw)ziConvert parallel lists of embeddings, metadatas and documents to a sequence of
    SubmitEmbeddingRecordsNzchroma:documentz
chroma:uri)r   r?  encodingr   r$  )	enumerater   ru  ScalarEncodingFLOAT32)r$  r   r   r   r   r   ir   r   documenturir\  s               ra   r   r     s      R
3 2 |H |HDhD(98D-x8q'C:h:c:(#.""'1'=jm4%%--
 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   	getLoggerrj  r   r   rb   rj   rn   r   ru  r   rG  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   