
    3iH                         S SK JrJrJrJrJr  S SKJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S SKJr  \(       a  S SKJr   " S S\S	   5      r g
)    )TYPE_CHECKINGOptionalUnionListcast)URICollectionMetadata	EmbeddingPyEmbeddingIncludeMetadataDocumentImageWhereIDs	GetResultQueryResultID	OneOrManyWhereDocumentSearchResultmaybe_cast_one_to_many)CollectionCommon)UpdateCollectionConfiguration)Search)AsyncServerAPIc                   b   \ rS rSr     S'S\\   S\\\\   \\	   4      S\\\
      S\\\      S\\\      S\\\      S	S4S
 jjrS	\4S jrSSSSSSS/4S\\\      S\\   S\\   S\\   S\\   S\S	\4S jjrS(S\S	\4S jjrSSSSSSSS/ SQ4	S\\\\   \\	   4      S\\\      S\\\      S\\\      S\\\      S\S\\   S\\   S\S	\4S jjr   S)S\\   S\\   S\\   S	S4S jjrS\S	S 4S  jrS!\\   S	\4S" jr      S'S\\   S\\\\   \\	   4      S\\\
      S\\\      S\\\      S\\\      S	S4S# jjr!     S'S\\   S\\\\   \\	   4      S\\\
      S\\\      S\\\      S\\\      S	S4S$ jjr"   S)S\\#   S\\   S\\   S	S4S% jjr$S&r%g)*AsyncCollection   Nids
embeddings	metadatas	documentsimagesurisreturnc                    #    U R                  UUUUUUS9nU R                  R                  U R                  US   US   US   US   US   U R                  U R
                  S9I Sh  vN   g N7f)	a  Add embeddings to the data store.
Args:
    ids: The ids of the embeddings you wish to add
    embeddings: The embeddings to add. If None, embeddings will be computed based on the documents or images using the embedding_function set for the Collection. Optional.
    metadatas: The metadata to associate with the embeddings. When querying, you can filter on this metadata. Optional.
    documents: The documents to associate with the embeddings. Optional.
    images: The images to associate with the embeddings. Optional.
    uris: The uris of the images to associate with the embeddings. Optional.

Returns:
    None

Raises:
    ValueError: If you don't provide either embeddings or documents
    ValueError: If the length of ids, embeddings, metadatas, or documents don't match
    ValueError: If you don't provide an embedding function and don't provide embeddings
    ValueError: If you provide both embeddings and documents
    ValueError: If you provide an id that already exists

r    r!   r"   r#   r$   r%   r    r!   r"   r#   r%   collection_idr    r!   r"   r#   r%   tenantdatabaseN)!_validate_and_prepare_add_request_client_addidr+   r,   )selfr    r!   r"   r#   r$   r%   add_requests           ]/home/james-whalen/.local/lib/python3.13/site-packages/chromadb/api/models/AsyncCollection.pyaddAsyncCollection.add    s     D <<! = 
 ll''E""<0!+.!+.V$;;]]   	
 		
 		
   A%A/'A-(A/c                    #    U R                   R                  U R                  U R                  U R                  S9I Sh  vN $  N7f)z~The total number of embeddings added to the database

Returns:
    int: The total number of embeddings added to the database

)r*   r+   r,   N)r.   _countr0   r+   r,   )r1   s    r3   countAsyncCollection.countV   sB      \\(('';;]] ) 
 
 	
 
s   =AA Awherelimitoffsetwhere_documentincludec                    #    U R                  UUUUS9nU R                  R                  U R                  US   US   US   US   UUU R                  U R
                  S9	I Sh  vN nU R                  XS   S9$  N7f)	at  Get embeddings and their associate data from the data store. If no ids or where filter is provided returns
all embeddings up to limit starting at offset.

Args:
    ids: The ids of the embeddings to get. Optional.
    where: A Where type dict used to filter results by. E.g. `{"$and": [{"color" : "red"}, {"price": {"$gte": 4.20}}]}`. Optional.
    limit: The number of documents to return. Optional.
    offset: The offset to start returning results from. Useful for paging results with limit. Optional.
    where_document: A WhereDocument type dict used to filter by the documents. E.g. `{"$contains": "hello"}`. Optional.
    include: A list of what to include in the results. Can contain `"embeddings"`, `"metadatas"`, `"documents"`. Ids are always included. Defaults to `["metadatas", "documents"]`. Optional.

Returns:
    GetResult: A GetResult object containing the results.

)r    r;   r>   r?   r    r;   r>   r?   )	r*   r    r;   r>   r?   r<   r=   r+   r,   Nresponser?   )!_validate_and_prepare_get_requestr.   _getr0   r+   r,   _transform_get_response)	r1   r    r;   r<   r=   r>   r?   get_requestget_resultss	            r3   getAsyncCollection.getc   s     0 <<)	 = 
 !LL--''E"g&&'78	*;;]] . 

 

 ++ i*@ , 
 	


s   A!A<#A:$A<
   c           	         #    U R                  U R                  R                  U R                  UU R                  U R
                  S9I Sh  vN 5      $  N7f)zGet the first few results in the database up to limit

Args:
    limit: The number of results to return.

Returns:
    GetResult: A GetResult object containing the results.
)r*   nr+   r,   N)_transform_peek_responser.   _peekr0   r+   r,   )r1   r<   s     r3   peekAsyncCollection.peek   sS      ,,,,$$"gg{{	 %  
 	
s   A	AA	A)r"   r#   	distancesquery_embeddingsquery_textsquery_images
query_uris	n_resultsc
                   #    U R                  UUUUUUUUU	S9	n
U R                  R                  U R                  U
S   U
S   U
S   U
S   U
S   U
S   U R                  U R
                  S9	I S	h  vN nU R                  XS   S
9$  N7f)a.  Get the n_results nearest neighbor embeddings for provided query_embeddings or query_texts.

Args:
    query_embeddings: The embeddings to get the closes neighbors of. Optional.
    query_texts: The document texts to get the closes neighbors of. Optional.
    query_images: The images to get the closes neighbors of. Optional.
    ids: A subset of ids to search within. Optional.
    n_results: The number of neighbors to return for each query_embedding or query_texts. Optional.
    where: A Where type dict used to filter results by. E.g. `{"$and": [{"color" : "red"}, {"price": {"$gte": 4.20}}]}`. Optional.
    where_document: A WhereDocument type dict used to filter by the documents. E.g. `{"$contains": "hello"}`. Optional.
    include: A list of what to include in the results. Can contain `"embeddings"`, `"metadatas"`, `"documents"`, `"distances"`. Ids are always included. Defaults to `["metadatas", "documents", "distances"]`. Optional.

Returns:
    QueryResult: A QueryResult object containing the results.

Raises:
    ValueError: If you don't provide either query_embeddings, query_texts, or query_images
    ValueError: If you provide both query_embeddings and query_texts
    ValueError: If you provide both query_embeddings and query_images
    ValueError: If you provide both query_texts and query_images

)	rR   rS   rT   rU   r    rV   r;   r>   r?   r    r!   rV   r;   r>   r?   )	r*   r    rR   rV   r;   r>   r?   r+   r,   NrA   )#_validate_and_prepare_query_requestr.   _queryr0   r+   r,   _transform_query_response)r1   rR   rS   rT   rU   r    rV   r;   r>   r?   query_requestquery_resultss               r3   queryAsyncCollection.query   s     X @@-#%!) A 

 #ll11''e$*<8#K0(()9:!),;;]] 2 

 

 --"),D . 
 	


s   A,B.B/Bnamemetadataconfigurationc           	         #    U R                  U5        U R                  R                  U R                  UUUU R                  U R
                  S9I Sh  vN   U R                  XU5        g N7f)zModify the collection name or metadata

Args:
    name: The updated name for the collection. Optional.
    metadata: The updated metadata for the collection. Optional.

Returns:
    None
)r0   new_namenew_metadatanew_configurationr+   r,   N)_validate_modify_requestr.   _modifyr0   r+   r,   "_update_model_after_modify_success)r1   r_   r`   ra   s       r3   modifyAsyncCollection.modify   sm       	%%h/
 ll""ww!+;;]] # 
 	
 	
 	//N	
s   AA-A+A-rc   c                    #    U R                   R                  U R                  UU R                  U R                  S9I Sh  vN n[        U R                   UU R                  U R                  S9$  N.7f)ax  Fork the current collection under a new name. The returning collection should contain identical data to the current collection.
This is an experimental API that only works for Hosted Chroma for now.

Args:
    new_name: The name of the new collection.

Returns:
    Collection: A new collection with the specified name and containing identical data to the current collection.
)r*   rc   r+   r,   N)clientmodelembedding_functiondata_loader)r.   _forkr0   r+   r,   r   _embedding_function_data_loader)r1   rc   rm   s      r3   forkAsyncCollection.fork  sm      ll(('';;]]	 ) 
 
 <<#77))	
 	

s   >A1 A//A1searchesc                 &  #    [        U5      nUc  / nU Vs/ s H  o0R                  U5      PM     nnU R                  R                  U R                  [        [        [           U5      U R                  U R                  S9I Sh  vN $ s  snf  N	7f)a%  Perform hybrid search on the collection.
This is an experimental API that only works for Hosted Chroma for now.

Args:
    searches: A single Search object or a list of Search objects, each containing:
        - where: Where expression for filtering
        - rank: Ranking expression for hybrid search (defaults to Val(0.0))
        - limit: Limit configuration for pagination (defaults to no limit)
        - select: Select configuration for keys to return (defaults to empty)

Returns:
    SearchResult: Column-major format response with:
        - ids: List of result IDs for each search payload
        - documents: Optional documents for each payload
        - embeddings: Optional embeddings for each payload
        - metadatas: Optional metadata for each payload
        - scores: Optional scores for each payload
        - select: List of selected keys for each payload

Raises:
    NotImplementedError: For local/segment API implementations

Examples:
    # Using builder pattern with Key constants
    from chromadb.execution.expression import (
        Search, Key, K, Knn, Val
    )

    # Note: K is an alias for Key, so K.DOCUMENT == Key.DOCUMENT
    search = (Search()
        .where((K("category") == "science") & (K("score") > 0.5))
        .rank(Knn(query=[0.1, 0.2, 0.3]) * 0.8 + Val(0.5) * 0.2)
        .limit(10, offset=0)
        .select(K.DOCUMENT, K.SCORE, "title"))

    # Direct construction
    from chromadb.execution.expression import (
        Search, Eq, And, Gt, Knn, Limit, Select, Key
    )

    search = Search(
        where=And([Eq("category", "science"), Gt("score", 0.5)]),
        rank=Knn(query=[0.1, 0.2, 0.3]),
        limit=Limit(offset=0, limit=10),
        select=Select(keys={Key.DOCUMENT, Key.SCORE, "title"})
    )

    # Single search
    result = await collection.search(search)

    # Multiple searches at once
    searches = [
        Search().where(K("type") == "article").rank(Knn(query=[0.1, 0.2])),
        Search().where(K("type") == "paper").rank(Knn(query=[0.3, 0.4]))
    ]
    results = await collection.search(searches)
N)r*   ru   r+   r,   )
r   _embed_search_string_queriesr.   _searchr0   r   r   r   r+   r,   )r1   ru   searches_listsearchembedded_searchess        r3   rz   AsyncCollection.search&  s     | /x8 M ER
DQ&--f5M 	 
 \\))''$v,(9:;;]]	 * 
 
 	
	

s   BB
ABB
Bc                    #    U R                  UUUUUUS9nU R                  R                  U R                  US   US   US   US   US   U R                  U R
                  S9I Sh  vN   g N7f)	a:  Update the embeddings, metadatas or documents for provided ids.

Args:
    ids: The ids of the embeddings to update
    embeddings: The embeddings to update. If None, embeddings will be computed based on the documents or images using the embedding_function set for the Collection. Optional.
    metadatas:  The metadata to associate with the embeddings. When querying, you can filter on this metadata. Optional.
    documents: The documents to associate with the embeddings. Optional.
    images: The images to associate with the embeddings. Optional.
Returns:
    None
r(   r    r!   r"   r#   r%   r)   N)$_validate_and_prepare_update_requestr.   _updater0   r+   r,   )r1   r    r!   r"   r#   r$   r%   update_requests           r3   updateAsyncCollection.updatet       2 BB! C 
 ll""''u%%l3$[1$[1';;]] # 	
 		
 		
r6   c                    #    U R                  UUUUUUS9nU R                  R                  U R                  US   US   US   US   US   U R                  U R
                  S9I Sh  vN   g N7f)	a  Update the embeddings, metadatas or documents for provided ids, or create them if they don't exist.

Args:
    ids: The ids of the embeddings to update
    embeddings: The embeddings to add. If None, embeddings will be computed based on the documents using the embedding_function set for the Collection. Optional.
    metadatas:  The metadata to associate with the embeddings. When querying, you can filter on this metadata. Optional.
    documents: The documents to associate with the embeddings. Optional.

Returns:
    None
r(   r    r!   r"   r#   r%   r)   N)$_validate_and_prepare_upsert_requestr.   _upsertr0   r+   r,   )r1   r    r!   r"   r#   r$   r%   upsert_requests           r3   upsertAsyncCollection.upsert  r   r6   c           	         #    U R                  XU5      nU R                  R                  U R                  US   US   US   U R                  U R
                  S9I Sh  vN   g N7f)a  Delete the embeddings based on ids and/or a where filter

Args:
    ids: The ids of the embeddings to delete
    where: A Where type dict used to filter the delection by. E.g. `{"$and": [{"color" : "red"}, {"price": {"$gte": 4.20}}]}`. Optional.
    where_document: A WhereDocument type dict used to filter the deletion by the document content. E.g. `{"$contains": "hello"}`. Optional.

Returns:
    None

Raises:
    ValueError: If you don't provide either ids, where, or where_document
r    r;   r>   )r*   r    r;   r>   r+   r,   N)$_validate_and_prepare_delete_requestr.   _deleter0   r+   r,   )r1   r    r;   r>   delete_requests        r3   deleteAsyncCollection.delete  sm     & BB
 ll""''u% ))*:;;;]] # 
 	
 	
s   AA%A#A% )NNNNN)rJ   )NNN)&__name__
__module____qualname____firstlineno__r   r   r   r   r
   r   r   r   r   r   r4   intr9   r   r   r   r   rH   rO   r   r]   strr	   r   ri   rs   r   r   rz   r   r   r   r   __static_attributes__r       r3   r   r      sD    3737-1)-4
r]4
 )$+&(
4
 Ih/04
 Ih/04
 5)*4
 y~&4
 
4
l
S 
 (,!%# $26'5-
im$-
 -
 }	-

 -
 !/-
 -
 
-
^
 
Y 
2 5937/3'+!%26
F
")$+&(
F
 i12F
 y/0F
 Ys^,F
 im$F
 F
 F
 !/F
 F
( 
)F
T #15AE	OsmO -.O   =>	O
 
O@

 

4L
F#L
 
L
l 3737-1)-+
r]+
 )$+&(
+
 Ih/0+
 Ih/0+
 5)*+
 y~&+
 
+
j 3737-1)-+
r]+
 )$+&(
+
 Ih/0+
 Ih/0+
 5)*+
 y~&+
 
+
^ "!%26	
c]
 
 !/	

 

 
r   r   r   N)!typingr   r   r   r   r   chromadb.api.typesr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   $chromadb.api.models.CollectionCommonr   %chromadb.api.collection_configurationr   "chromadb.execution.expression.planr   chromadb.apir   r   r   r   r3   <module>r      sK    = =    ( B O 5+M
&'78 M
r   