8
8
from chromadb .api .types import (
9
9
CollectionMetadata ,
10
10
Documents ,
11
+ Embeddable ,
11
12
EmbeddingFunction ,
13
+ DataLoader ,
12
14
Embeddings ,
13
15
IDs ,
14
16
Include ,
17
+ Loadable ,
15
18
Metadatas ,
19
+ URIs ,
16
20
Where ,
17
21
QueryResult ,
18
22
GetResult ,
@@ -58,7 +62,10 @@ def create_collection(
58
62
self ,
59
63
name : str ,
60
64
metadata : Optional [CollectionMetadata ] = None ,
61
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
65
+ embedding_function : Optional [
66
+ EmbeddingFunction [Embeddable ]
67
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
68
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
62
69
get_or_create : bool = False ,
63
70
) -> Collection :
64
71
"""Create a new collection with the given name and metadata.
@@ -90,9 +97,12 @@ def create_collection(
90
97
@abstractmethod
91
98
def get_collection (
92
99
self ,
93
- name : Optional [ str ] = None ,
100
+ name : str ,
94
101
id : Optional [UUID ] = None ,
95
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
102
+ embedding_function : Optional [
103
+ EmbeddingFunction [Embeddable ]
104
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
105
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
96
106
) -> Collection :
97
107
"""Get a collection with the given name.
98
108
Args:
@@ -119,7 +129,10 @@ def get_or_create_collection(
119
129
self ,
120
130
name : str ,
121
131
metadata : Optional [CollectionMetadata ] = None ,
122
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
132
+ embedding_function : Optional [
133
+ EmbeddingFunction [Embeddable ]
134
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
135
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
123
136
) -> Collection :
124
137
"""Get or create a collection with the given name and metadata.
125
138
Args:
@@ -186,6 +199,7 @@ def _add(
186
199
embeddings : Embeddings ,
187
200
metadatas : Optional [Metadatas ] = None ,
188
201
documents : Optional [Documents ] = None ,
202
+ uris : Optional [URIs ] = None ,
189
203
) -> bool :
190
204
"""[Internal] Add embeddings to a collection specified by UUID.
191
205
If (some) ids already exist, only the new embeddings will be added.
@@ -196,6 +210,7 @@ def _add(
196
210
embedding: The sequence of embeddings to add.
197
211
metadata: The metadata to associate with the embeddings. Defaults to None.
198
212
documents: The documents to associate with the embeddings. Defaults to None.
213
+ uris: URIs of data sources for each embedding. Defaults to None.
199
214
200
215
Returns:
201
216
True if the embeddings were added successfully.
@@ -210,6 +225,7 @@ def _update(
210
225
embeddings : Optional [Embeddings ] = None ,
211
226
metadatas : Optional [Metadatas ] = None ,
212
227
documents : Optional [Documents ] = None ,
228
+ uris : Optional [URIs ] = None ,
213
229
) -> bool :
214
230
"""[Internal] Update entries in a collection specified by UUID.
215
231
@@ -219,7 +235,7 @@ def _update(
219
235
embeddings: The sequence of embeddings to update. Defaults to None.
220
236
metadatas: The metadata to associate with the embeddings. Defaults to None.
221
237
documents: The documents to associate with the embeddings. Defaults to None.
222
-
238
+ uris: URIs of data sources for each embedding. Defaults to None.
223
239
Returns:
224
240
True if the embeddings were updated successfully.
225
241
"""
@@ -233,6 +249,7 @@ def _upsert(
233
249
embeddings : Embeddings ,
234
250
metadatas : Optional [Metadatas ] = None ,
235
251
documents : Optional [Documents ] = None ,
252
+ uris : Optional [URIs ] = None ,
236
253
) -> bool :
237
254
"""[Internal] Add or update entries in the a collection specified by UUID.
238
255
If an entry with the same id already exists, it will be updated,
@@ -244,6 +261,7 @@ def _upsert(
244
261
embeddings: The sequence of embeddings to add
245
262
metadatas: The metadata to associate with the embeddings. Defaults to None.
246
263
documents: The documents to associate with the embeddings. Defaults to None.
264
+ uris: URIs of data sources for each embedding. Defaults to None.
247
265
"""
248
266
pass
249
267
@@ -486,7 +504,10 @@ def create_collection(
486
504
self ,
487
505
name : str ,
488
506
metadata : Optional [CollectionMetadata ] = None ,
489
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
507
+ embedding_function : Optional [
508
+ EmbeddingFunction [Embeddable ]
509
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
510
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
490
511
get_or_create : bool = False ,
491
512
tenant : str = DEFAULT_TENANT ,
492
513
database : str = DEFAULT_DATABASE ,
@@ -497,9 +518,12 @@ def create_collection(
497
518
@override
498
519
def get_collection (
499
520
self ,
500
- name : Optional [ str ] = None ,
521
+ name : str ,
501
522
id : Optional [UUID ] = None ,
502
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
523
+ embedding_function : Optional [
524
+ EmbeddingFunction [Embeddable ]
525
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
526
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
503
527
tenant : str = DEFAULT_TENANT ,
504
528
database : str = DEFAULT_DATABASE ,
505
529
) -> Collection :
@@ -511,7 +535,10 @@ def get_or_create_collection(
511
535
self ,
512
536
name : str ,
513
537
metadata : Optional [CollectionMetadata ] = None ,
514
- embedding_function : Optional [EmbeddingFunction ] = ef .DefaultEmbeddingFunction (),
538
+ embedding_function : Optional [
539
+ EmbeddingFunction [Embeddable ]
540
+ ] = ef .DefaultEmbeddingFunction (), # type: ignore
541
+ data_loader : Optional [DataLoader [Loadable ]] = None ,
515
542
tenant : str = DEFAULT_TENANT ,
516
543
database : str = DEFAULT_DATABASE ,
517
544
) -> Collection :
0 commit comments