
    q9i#                     2   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@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ d dlRmSZSmTZTmUZUmVZVmWZWmXZX d dl4mYZZ d dl m[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZb d dlcmdZd d dlemfZfmgZg d dlhmiZi d dljZjd dlkZkd dllZld dl'mmZm  ebdeade_f         Zn ekj                  ep      Zqd erd!dfd"Zsd#end!enfd$Zt G d% d&e      Zu	 	 	 	 d.d'eZj                  d(e?d)e[e@   d*e[eA   d+e[eB   d,e[eD   d!e]eZj                  ddf   fd-Zxy)/    )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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)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)rU   msgs     ]/var/www/html/leadgen/airagagent/rag_env/lib/python3.12/site-packages/chromadb/api/segment.pycheck_index_namer`   ]   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kwargsrV   c                  P    | d   } |j                   j                        | i |S )Nr   )_rate_limit_enforcer
rate_limit)rd   re   selfrb   s      r_   wrapperzrate_limit.<locals>.wrapperr   s/    Aw9t((33D94J6JJra   )rQ   rJ   )rb   rj   s   ` r_   rh   rh   q   s:    
4[Ks Kc Kc K K Nra   c                   t    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:e4e5   ded(ede6f
d;       Z7 ed<ej*                        ee$ee%fdeded(eddfd=                     Z8 ed>ej*                        ee$dddee%fd?e9d8e0d@e:dAee;   dBee<   dCee=   ded(ede)fdD                     Z> edEej*                        ee$ddddee%fd8e0d?e9d@ee:   dAee;   dBee<   dCee=   ded(ede)fdF                     Z? edGej*                        ee$dddee%fd8e0d?e9d@e:dAee;   dBee<   dCee=   ded(ede)fdH                     Z@ edIej*                         eA eBdJ        eCdK       eDdL      dMN      ee$dddddeEee%fd8e0d?ee9   dOeeF   dee   dee   dPeeG   dQeHded(edeIfdR                            ZJ edSej*                        ee$dddee%fd8e0d?ee9   dOeeF   dPeeG   ded(eddfdT                     ZK edUej*                         eA eBdV        eCdK       eDdL      dMN      ee$ee%fd8e0ded(edefdW                            ZL edXej*                         eA eBdY        eCdK       eDdL      dMN      ee$ddZddeMee%fd8e0d[e:d?ee9   d\edOeeF   dPeeG   dQeHded(edeNfd]                            ZO ed^ej*                        ee$dZee%fd8e0d_eded(edeIf
d`                     ZPedefda       ZQedzdb       ZRede)fdc       ZSedefdd       ZTedefde       ZUedee%fdfededge0dhedieeVeeWf      ded(eddjfdk       ZXeee%fdedge0ded(eddjf
dl       ZYed#ee%fdedge0dme)ded(ede)fdn       ZZ edoej                        dpej                  dqe4ej                     ddfdr       Z^dpej                  dsedte)ddfduZ_ edvej                        d8e0dej                  fdw       Z` edxej*                        d8e0deafdy       Zb xZcS ){
SegmentAPIzHAPI implementation utilizing the new segment-based internal architecture	_settings_sysdb_manager	_executor	_producer_product_telemetry_client_opentelemetry_client
_tenant_id	_topic_nsrg   systemc                    t         |   |       |j                  | _        | j	                  t
              | _        | j	                  t              | _        | j	                  t              | _
        | j	                  t              | _        | j	                  t              | _        | j	                  t              | _        | j	                  t"              | _        | j&                  j	                  t(              | _        y N)super__init__settingsrm   requirer   rn   r   ro   r   rp   r   _quota_enforcerr$   rr   r!   rs   r%   rq   _systemr   rg   )ri   rv   	__class__s     r_   rz   zSegmentAPI.__init__   s     ll5)^4h/#||M:)-6L)M&%)\\2E%F"h/$(LL$8$89J$K!ra   rV   c                 <    t        t        j                               S rx   )inttimetime_nsri   s    r_   	heartbeatzSegmentAPI.heartbeat   s    4<<>""ra   zSegmentAPI.create_databasenametenantNc                     t        |      dk  rt        d      | j                  j                  t        j
                  ||       | j                  j                  t               ||       y )NrX   z0Database name must be at least 3 characters long)actionr   r   )idr   r   )	rZ   r[   r}   enforcer   CREATE_DATABASErn   create_databaserP   ri   r   r   s      r_   r   zSegmentAPI.create_database   sg     t9q=OPP$$)) 	% 	
 	##w 	$ 	
ra   zSegmentAPI.get_databasec                 <    | j                   j                  ||      S N)r   r   )rn   get_databaser   s      r_   r   zSegmentAPI.get_database   s     {{''T&'AAra   zSegmentAPI.delete_databasec                 >    | j                   j                  ||       y r   )rn   delete_databaser   s      r_   r   zSegmentAPI.delete_database   s     	##f#=ra   zSegmentAPI.list_databaseslimitoffsetc                 >    | j                   j                  |||      S )N)r   r   r   )rn   list_databases)ri   r   r   r   s       r_   r   zSegmentAPI.list_databases   s      {{))fV)TTra   zSegmentAPI.create_tenantc                 n    t        |      dk  rt        d      | j                  j                  |       y )NrX   z.Tenant name must be at least 3 characters longr   )rZ   r[   rn   create_tenantri   r   s     r_   r   zSegmentAPI.create_tenant   s5     t9q=MNN!! 	" 	
ra   c                 0    t        dt        t        g      S )N )user_idr   	databases)r   r   r   r   s    r_   get_user_identityzSegmentAPI.get_user_identity   s    !'(
 	
ra   zSegmentAPI.get_tenantc                 :    | j                   j                  |      S )Nr   )rn   
get_tenantr   s     r_   r   zSegmentAPI.get_tenant   s     {{%%4%00ra   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   )r9   r`   r}   r   r   CREATE_COLLECTIONrP   CollectionModelr   r
   rn   create_collectionr   r   r   ro   #prepare_segments_for_new_collectioncreate_segmentloggerdebugrr   capturerE   strr    )ri   r   r   r   r   r   r   r   r   modelcollcreatedr   segments                 r_   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ra   z#SegmentAPI.get_or_create_collectionc           	      2    | j                  ||||d||      S )NT)r   r   r   r   r   r   r   )r   )ri   r   r   r   r   r   r   s          r_   get_or_create_collectionz#SegmentAPI.get_or_create_collection$  s1     %%' & 
 	
ra   zSegmentAPI.get_collectionc                 j    | j                   j                  |||      }|r|d   S t        d| d      )Nr   r   r   r   r    does not exist.)rn   get_collectionsr*   ri   r   r   r   existings        r_   get_collectionzSegmentAPI.get_collection?  sH     ;;..fx / 
 A;+dV3C DEEra   zSegmentAPI.list_collectionc                     | j                   j                  t        j                  ||       | j                  j                  ||||      S )N)r   r   r   )r   r   r   r   )r}   r   r   LIST_COLLECTIONSrn   r   )ri   r   r   r   r   s        r_   list_collectionszSegmentAPI.list_collectionsQ  sS     	$$** 	% 	
 {{**v + 
 	
ra   zSegmentAPI.count_collectionsc                 <    | j                   j                  ||      S )Nr   r   )rn   count_collections)ri   r   r   s      r_   r   zSegmentAPI.count_collectionse  s     {{,,FX,NNra   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   )	r`   r:   _get_collectionr}   r   r   UPDATE_COLLECTIONrn   update_collection)ri   r   r   r   r   r   r   _s           r_   _modifyzSegmentAPI._modifyo  sF    X&$\2   $$$++!	 	% 	
 ):KK))%/	 *  ,KK))"8l)S+KK))1B *  /KK))\9J *  KK))"8)<KK))"|)DKK))"<M)N ra   collection_idc                     t        d      )Nz4Collection forking is not implemented for SegmentAPINotImplementedError)ri   r   r   r   r   s        r_   _forkzSegmentAPI._fork  s     "B
 	
ra   searchesc                     t        d      )Nz(Search is not implemented for SegmentAPIr   )ri   r   r   r   r   s        r_   _searchzSegmentAPI._search  s     ""LMMra   zSegmentAPI.delete_collectionc                    | j                   j                  |||      }|rT| j                  j                  |d   j                         | j                   j                  |d   j                  ||       y t        d| d      )Nr   r   r   r   r   )rn   r   ro   delete_segmentsr   delete_collectionr[   r   s        r_   r   zSegmentAPI.delete_collection  s     ;;..fx / 
 MM))(1+..9KK))v *  {4&0@ABBra   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   ro   hint_use_collectiont	OperationADDr=   get_max_batch_sizelist_records_validate_embedding_record_setr}   r   r   rq   submit_embeddingsrr   r   r@   r   rZ   )ri   r   r   r   r   r   r   r   r   r   records_to_submits              r_   _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	
 ra   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   ro   r   r   r   UPDATEr=   r   r   r   r   r}   r   r   rq   r   rr   r   rC   r   rZ   ri   r   r   r   r   r   r   r   r   r   r   s              r_   _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)		
 ra   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   ro   r   r   r   UPSERTr=   r   r   r   r   r}   r   r   rq   r   r   s              r_   _upsertzSegmentAPI._upsertB  s     ##M2))-9K9KL*iD9t6689	
 !""%##	
 	++D2CD$$==!' 	% 		
 	((8IJra   zSegmentAPI._getc                 "    t        | t              S rx   
isinstancer+   es    r_   <lambda>zSegmentAPI.<lambda>s      :a9M+N ra         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   rZ   _scanr;   r<   r}   r   r   GETrr   r   rB   rp   getr   r   r   r   )ri   r   r   r  r   r   r  r  r   r   scan
ids_amounts               r_   _getzSegmentAPI._getq  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%	
 	
ra   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   rZ   r;   r<   r[   r  r}   r   r   DELETEro   r   r   r   rp   r  r   r   r   r   r   
collectionrq   r   rr   r   rA   )
ri   r   r   r  r  r   r   r  ids_to_deleter   s
             r_   _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	
ra   zSegmentAPI._countc                 "    t        | t              S rx   r  r  s    r_   r  zSegmentAPI.<lambda>
  r  ra   c                     t        dt        |      i       | j                  j                  t	        | j                  |                  S )Nr   )r    r   rp   countr   r  )ri   r   r   r   s       r_   _countzSegmentAPI._count  s9     	']9K'LM~~##Idjj.G$HIIra   zSegmentAPI._queryc                 "    t        | t              S rx   r  r  s    r_   r  zSegmentAPI.<lambda>#  r  ra   
   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   r*  r  r   r   r   r   	distances)
r   query_amountfiltered_ids_amountr*  with_metadata_filterwith_document_filterinclude_metadatasr  r  include_distancesFupdate)r   r   r  r  r)  r*  r   )r    r   rZ   rr   r   rD   r;   r<   r  _validate_dimensionr   r}   r   r   QUERYrp   knnr   r   r   r   )ri   r   r)  r   r*  r  r  r  r   r   r-  r  r  	embeddings                 r_   _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%	
 	
ra   zSegmentAPI._peeknc                 T    t        dt        |      i       | j                  ||      S )Nr   )r   )r    r   r  )ri   r   r:  r   r   s        r_   _peekzSegmentAPI._peekq  s)     	']9K'LMyyay00ra   c                     t         S rx   r'   r   s    r_   get_versionzSegmentAPI.get_version~  s    ra   c                      y rx    r   s    r_   reset_statezSegmentAPI.reset_state  s    ra   c                 8    | j                   j                          y)NT)r~   rA  r   s    r_   resetzSegmentAPI.reset  s      "ra   c                     | j                   S rx   )rm   r   s    r_   get_settingszSegmentAPI.get_settings  s    ~~ra   c                 .    | j                   j                  S rx   )rq   r   r   s    r_   r   zSegmentAPI.get_max_batch_size  s    ~~,,,ra   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   )ri   rG  r   rH  rI  rJ  r   r   s           r_   attach_functionzSegmentAPI.attach_function  s     "]
 	
ra   c                     t        d      rL  r   )ri   r   rH  r   r   s        r_   get_attached_functionz SegmentAPI.get_attached_function  s     "]
 	
ra   delete_outputc                     t        d      rL  r   )ri   r   rH  rP  r   r   s         r_   detach_functionzSegmentAPI.detach_function  s     "]
 	
ra   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   r8  NTr3  )r    r   r5  rZ   )ri   r   rS  records       r_   r   z)SegmentAPI._validate_embedding_record_set  sY     	'Z=M9N'OP 	Fk".((F;$7 8 ) 	ra   dimr4  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   rn   r   r)   )ri   r   rV  r4  r   s        r_   r5  zSegmentAPI._validate_dimension  s{     k"*]]--s-C*-
;'  $++&se+UV`alVmUno  ra   zSegmentAPI._get_collectionc                     | j                   j                  |      }|rt        |      dk(  rt        d| d      |d   S )N)r   r   r   r   )rn   r   rZ   r*   )ri   r   collectionss      r_   r   zSegmentAPI._get_collection  sG    kk11]1Cc+.!3+m_<L MNN1~ra   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   r7  r   rU  )	rn   get_collection_with_segmentsr   r   SegmentScopeVECTORMETADATAr  RECORD)ri   r   collection_and_segmentsr   scope_to_segments        r_   r  zSegmentAPI._scan  s    "&++"J"J#
 6MZ5X
*1GGg%
 
 .|< !6!67%ann&=&=>#''(=(=tD
 	

s   B")rV   N)d__name__
__module____qualname____doc__r   __annotations__r   r   r   r%   r$   r!   r   r   r   rz   rN   r   r   r#   r"   	OPERATIONr   r   r   Databaser   r   rF   rG   r   r   r   r   Tenantr   rh   r   r1   r
   r,   boolr   r   r   r   r   r   rO   r   r   r   rI   rR   r8   r   r   r-   r.   r/   r0   r2   r   r   r   r   r   r   r   r>   r3   r4   r5   r6   r  r"  r&  r?   r7   r9  r<  r>  rA  rC  rE  r   rK   rJ   rM  rO  rR  ALLr&   OperationRecordr   r5  r   r   r  __classcell__)r   s   @r_   rl   rl   z   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 
 %(	
	
 	
 		

 	
 
	
 	
 
 %(NN v,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(
 
 
 

 
  
 %(

 "
 	

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

 
 
 

 
$ 35M5Q5Q	,,	15a6G6G1H				,,-0:>	$ .0H0L0LMT all  N $&>&H&HI
4 
D 
 J
ra   rl   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   r8  encodingr   r  )	enumerater   rm  ScalarEncodingFLOAT32)r  r   r   r   r   r   ir   r   documenturirU  s               r_   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)y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?   !chromadb.telemetry.product.eventsr@   rA   rB   rC   rD   rE   typesr   rF   rG   rH   rI   rJ   rK   rL   rM   	overridesrN   uuidrO   rP   	functoolsrQ   r   loggingr\   rR   rS   	getLoggerrc  r   r   r`   rh   rl   r   rm  r   r@  ra   r_   <module>r     s     N N "E 
 ' N N $ 0 1 + 9 W W J J  > $ 8   
     ,  	 	 	      	 5CxS)*			8	$  (Q 1 D
 D
T (,%)%),{{,	, $, 	"	,
 	", 4., q  $,-,ra   