
    ug                        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
mZmZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZ  G d de      Z G d	 d
e      Z ede      Z G d de      Z G d de      Z G d de      Zy)    )OptionalSequenceTypeVar)abstractmethod)
CollectionMetadataEmbeddingRecord	OperationRequestVersionContextVectorEmbeddingRecordWhereWhereDocumentVectorQueryVectorQueryResultSegmentSeqIdMetadata)	ComponentSystem)UUID)Enumc                   $    e Zd ZdZdZdZdZdZdZy)SegmentTypez"urn:chroma:segment/metadata/sqlitez+urn:chroma:segment/vector/hnsw-local-memoryz.urn:chroma:segment/vector/hnsw-local-persistedz*urn:chroma:segment/vector/hnsw-distributedz#urn:chroma:segment/record/blockfilez%urn:chroma:segment/metadata/blockfileN)	__name__
__module____qualname__SQLITEHNSW_LOCAL_MEMORYHNSW_LOCAL_PERSISTEDHNSW_DISTRIBUTEDBLOCKFILE_RECORDBLOCKFILE_METADATA     N/var/www/openai/venv/lib/python3.12/site-packages/chromadb/segment/__init__.pyr   r      s%    1FEKC<@r#   r   c                       e Zd Zededefd       Zededefd       Z	ede
fd       Zededee   fd	       Zedd       Zy
)SegmentImplementationsytstemsegmentc                      y Nr"   )selfr'   r(   s      r$   __init__zSegmentImplementation.__init__    s    r#   request_version_contextreturnc                      y)z,Get the number of embeddings in this segmentNr"   )r+   r-   s     r$   countzSegmentImplementation.count$        	r#   c                      y)z7Get the maximum SeqID currently indexed by this segmentNr"   r+   s    r$   	max_seqidzSegmentImplementation.max_seqid)   r1   r#   metadatac                      y)zGiven an arbitrary metadata map (e.g, from a collection), validate it and
        return metadata (if any) that is applicable and should be applied to the
        segment. Validation errors will be reported to the user.Nr"   )r5   s    r$   propagate_collection_metadataz3SegmentImplementation.propagate_collection_metadata.   s    
 r#   Nc                      y)z#Delete the segment and all its dataNr"   r3   s    r$   deletezSegmentImplementation.delete5   s     	r#   )r.   N)r   r   r   r   r   r   r,   r
   intr0   r   r4   staticmethodr   r   r7   r9   r"   r#   r$   r&   r&      s        -B s   5    Xh=O    r#   r&   S)boundc                   z    e Zd ZdZe	 	 	 	 	 	 ddedee   dee   dee	e
      dee   dee   d	ed
e	e   fd       Zy)MetadataReaderz$Embedding Metadata segment interfaceNr-   wherewhere_documentidslimitoffsetinclude_metadatar.   c                      y)zQuery for embedding metadata.Nr"   )r+   r-   r@   rA   rB   rC   rD   rE   s           r$   get_metadatazMetadataReader.get_metadataA   s     	r#   )NNNNNT)r   r   r   __doc__r   r
   r   r   r   r   strr:   boolr   rG   r"   r#   r$   r?   r?   >   s    . "&26'+# $!%!6  !/	
 hsm$ }   
)	* r#   r?   c            	       j    e Zd ZdZe	 d	dedeee      dee	   fd       Z
ededeee      fd       Zy)
VectorReaderz"Embedding Vector segment interfaceNr-   rB   r.   c                      y)z]Get embeddings from the segment. If no IDs are provided, all embeddings are
        returned.Nr"   )r+   r-   rB   s      r$   get_vectorszVectorReader.get_vectorsS   s     	r#   queryc                      y)zYGiven a vector query, return the top-k nearest neighbors for vector in the
        query.Nr"   )r+   rO   s     r$   query_vectorszVectorReader.query_vectors]   s     	r#   r*   )r   r   r   rH   r   r
   r   r   rI   r   rN   r   r   rQ   r"   r#   r$   rL   rL   P   sv    , (,!6 hsm$ 
'	(	   	(,-	. r#   rL   c                   n    e Zd ZdZededee   fd       Zede	dee	   fd       Z
ede	deddfd	       Zy)
SegmentManagerzfInterface for a pluggable strategy for creating, retrieving and instantiating
    segments as required
collectionr.   c                      y)zsReturn the segments required for a new collection. Returns only segment data,
        does not persist to the SysDBNr"   )r+   rT   s     r$   #prepare_segments_for_new_collectionz2SegmentManager.prepare_segments_for_new_collectionj        	r#   collection_idc                      y)zDelete any local state for all the segments associated with a collection, and
        returns a sequence of their IDs. Does not update the SysDB.Nr"   )r+   rX   s     r$   delete_segmentszSegmentManager.delete_segmentsp   rW   r#   	hint_typeNc                      y)zSignal to the segment manager that a collection is about to be used, so that
        it can preload segments as needed. This is only a hint, and implementations are
        free to ignore it.Nr"   )r+   rX   r[   s      r$   hint_use_collectionz"SegmentManager.hint_use_collectionv   s    
 	r#   )r   r   r   rH   r   r   r   r   rV   r   rZ   r	   r]   r"   r#   r$   rS   rS   f   s     j XV]M^  
 T htn  
  ) PT  r#   rS   N) typingr   r   r   abcr   chromadb.typesr   r   r	   r
   r   r   r   r   r   r   r   r   chromadb.configr   r   uuidr   enumr   r   r&   r<   r?   rL   rS   r"   r#   r$   <module>rd      s|    . .     .  A$ AI 8 C,-* $( ,Y r#   