Updating to chromadb server's fastAPI
Browse files
main.py
CHANGED
@@ -22,6 +22,21 @@ from chromadb.api.types import (
|
|
22 |
QueryResult,
|
23 |
CollectionMetadata,
|
24 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
from chromadb.api import API
|
26 |
from chromadb.config import System
|
27 |
import chromadb.utils.embedding_functions as ef
|
@@ -60,22 +75,17 @@ def list_collections():
|
|
60 |
@app.post(api_base+"/collections")
|
61 |
def create_collection(
|
62 |
self,
|
63 |
-
|
64 |
-
metadata: Optional[CollectionMetadata] = None,
|
65 |
-
embedding_function: Optional[EmbeddingFunction] = ef.DefaultEmbeddingFunction(),
|
66 |
-
get_or_create: bool = False,
|
67 |
) -> Collection:
|
68 |
print("Received request to create_collection")
|
69 |
-
return bkend.create_collection(name,metadata=metadata,
|
70 |
|
71 |
@app.get(api_base+"/collections")
|
72 |
def get_collection(
|
73 |
self,
|
74 |
-
|
75 |
-
embedding_function: Optional[EmbeddingFunction] = ef.DefaultEmbeddingFunction(),
|
76 |
) -> Collection:
|
77 |
-
return bkend.get_collection(
|
78 |
-
)
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
22 |
QueryResult,
|
23 |
CollectionMetadata,
|
24 |
)
|
25 |
+
from chromadb.errors import (
|
26 |
+
ChromaError,
|
27 |
+
InvalidUUIDError,
|
28 |
+
InvalidDimensionException,
|
29 |
+
)
|
30 |
+
from chromadb.server.fastapi.types import (
|
31 |
+
AddEmbedding,
|
32 |
+
DeleteEmbedding,
|
33 |
+
GetEmbedding,
|
34 |
+
QueryEmbedding,
|
35 |
+
RawSql, # Results,
|
36 |
+
CreateCollection,
|
37 |
+
UpdateCollection,
|
38 |
+
UpdateEmbedding,
|
39 |
+
)
|
40 |
from chromadb.api import API
|
41 |
from chromadb.config import System
|
42 |
import chromadb.utils.embedding_functions as ef
|
|
|
75 |
@app.post(api_base+"/collections")
|
76 |
def create_collection(
|
77 |
self,
|
78 |
+
collection: CreateCollection
|
|
|
|
|
|
|
79 |
) -> Collection:
|
80 |
print("Received request to create_collection")
|
81 |
+
return bkend.create_collection(name=collection.name,metadata=collection.metadata,get_or_create=collection.get_or_create)
|
82 |
|
83 |
@app.get(api_base+"/collections")
|
84 |
def get_collection(
|
85 |
self,
|
86 |
+
collection_name: str,
|
|
|
87 |
) -> Collection:
|
88 |
+
return bkend.get_collection(collection_name)
|
|
|
89 |
|
90 |
if __name__ == "__main__":
|
91 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|