updated utils.. working on the api
This commit is contained in:
Binary file not shown.
+11
-8
@@ -462,11 +462,14 @@ def add_documents_to_vector_store(embeddings, documents: list, docs_id: list, nu
|
||||
|
||||
|
||||
# A document search function
|
||||
def search(db, query, k=3):
|
||||
docs = db.similarity_search(query, k)
|
||||
all = ""
|
||||
info = []
|
||||
for doc in docs:
|
||||
all += f"{doc.page_content}\n"
|
||||
info.append(dict(doc.metadata))
|
||||
return docs[0].page_content, all, info
|
||||
# loading the embedded data
|
||||
embed_db = load_embedded_data()
|
||||
def search(query, k=4):
|
||||
db = embed_db
|
||||
docs = db.similarity_search(query, k)
|
||||
all = []
|
||||
info = []
|
||||
for doc in docs:
|
||||
all.append({doc.page_content})
|
||||
info.append(dict(doc.metadata))
|
||||
return docs[0].page_content, all, info
|
||||
|
||||
Reference in New Issue
Block a user