Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -28,22 +28,20 @@ def embedding_function(items_to_embed: list[str]):
|
|
| 28 |
print(len(embedded_items))
|
| 29 |
print(type(embedded_items[0]))
|
| 30 |
print(type(embedded_items[0][0]))
|
| 31 |
-
return embedded_items
|
| 32 |
|
| 33 |
def chroma_upserting(collection, payload:list[dict]):
|
| 34 |
print('upserting')
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
# print("printing item:")
|
| 38 |
-
# print(type(item))
|
| 39 |
embedding = embedding_function([item['doc'] for item in payload])
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
def search_chroma(collection, query:str):
|
| 49 |
results = collection.query(
|
|
|
|
| 28 |
print(len(embedded_items))
|
| 29 |
print(type(embedded_items[0]))
|
| 30 |
print(type(embedded_items[0][0]))
|
| 31 |
+
return list(embedded_items)
|
| 32 |
|
| 33 |
def chroma_upserting(collection, payload:list[dict]):
|
| 34 |
print('upserting')
|
| 35 |
+
print("printing item:")
|
| 36 |
+
print(type(item))
|
|
|
|
|
|
|
| 37 |
embedding = embedding_function([item['doc'] for item in payload])
|
| 38 |
+
print(type(embedding))
|
| 39 |
+
collection.add(
|
| 40 |
+
documents=[item['doc'] for item in payload],
|
| 41 |
+
embeddings=[embedding],
|
| 42 |
+
#metadatas=item,
|
| 43 |
+
ids=[f"id_{idx}" for idx, _ in enumerate(payload)]
|
| 44 |
+
)
|
| 45 |
|
| 46 |
def search_chroma(collection, query:str):
|
| 47 |
results = collection.query(
|