Spaces:
Sleeping
Sleeping
Mikeplockhart
commited on
Commit
•
5e3cc67
1
Parent(s):
9a04609
Update app.py
Browse files
app.py
CHANGED
@@ -37,17 +37,21 @@ print("printing 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 |
-
|
43 |
ids=[f"id_{idx}" for idx, _ in enumerate(payload)]
|
44 |
)
|
45 |
|
46 |
def search_chroma(query:str):
|
47 |
-
results =
|
48 |
-
query_embeddings=embedding_function([query]),
|
49 |
-
|
|
|
|
|
50 |
)
|
|
|
51 |
text_only= [f"# Dish:\n{item}\n\n" for item in results['documents'][0]]
|
52 |
return "".join(text_only)
|
53 |
|
|
|
37 |
embedding = embedding_function([item['doc'] for item in payload])
|
38 |
print(type(embedding))
|
39 |
collection.add(
|
40 |
+
collection_name="food",
|
41 |
documents=[item['doc'] for item in payload],
|
42 |
+
#embeddings=embedding,
|
43 |
+
metadatas=[{'payload':item} for item in payload],
|
44 |
ids=[f"id_{idx}" for idx, _ in enumerate(payload)]
|
45 |
)
|
46 |
|
47 |
def search_chroma(query:str):
|
48 |
+
results = client.query(
|
49 |
+
#query_embeddings=embedding_function([query]),
|
50 |
+
collection="food",
|
51 |
+
query_text=query
|
52 |
+
#n_results=2
|
53 |
)
|
54 |
+
return results
|
55 |
text_only= [f"# Dish:\n{item}\n\n" for item in results['documents'][0]]
|
56 |
return "".join(text_only)
|
57 |
|