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