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
|
||||
|
||||
@@ -208,3 +208,10 @@
|
||||
|
||||
2024-08-13 21:29:28,626 - INFO - Search completed
|
||||
2024-08-13 21:29:28,626 - INFO - Page content: this without any hesitation buy one of these to just get to the work and back and save a lot of money on the gas that's my feeling you please share underneath the video your experience with others because that's why we filming this creating community of Toyota enthusiasts who share their own own experience if you like the video give it a thumb up and be subscribed i will always have a lot of new stuff coming your way thank you for watching and have a great day my friend
|
||||
2024-08-13 22:06:46,533 - INFO - Receiving the search query
|
||||
2024-08-13 22:07:11,060 - INFO - Searching for repairing a toyota
|
||||
2024-08-13 22:07:11,583 - WARNING - C:\Users\timmy_3aupohg\anaconda3\envs\smog_env\Lib\site-packages\transformers\models\bert\modeling_bert.py:439: UserWarning: 1Torch was not compiled with flash attention. (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\transformers\cuda\sdp_utils.cpp:555.)
|
||||
attn_output = torch.nn.functional.scaled_dot_product_attention(
|
||||
|
||||
2024-08-13 22:07:11,760 - INFO - Search completed
|
||||
2024-08-13 22:07:11,762 - INFO - Page content: The image shows a black Toyota truck, likely a Toyota Tacoma, parked in what appears to be a dealership or repair lot. The caption indicates that it is an "accidented car: after repair," suggesting that the vehicle had previously been involved in an accident but has since been repaired. In the background, there’s a gray Jeep vehicle.
|
||||
|
||||
@@ -7,16 +7,13 @@ from loggings.logging_config import logger
|
||||
|
||||
|
||||
|
||||
# loading the embedded data
|
||||
embed_db = load_embedded_data()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("Receiving the search query")
|
||||
query = input("Enter the search query: ")
|
||||
logger.info(f"Searching for {query}")
|
||||
page_content, all, pages = search(embed_db, query)
|
||||
page_content, all, pages = search(query)
|
||||
logger.info("Search completed")
|
||||
logger.info(f"Page content: {page_content}")
|
||||
print(f"Page content: {page_content}")
|
||||
|
||||
Reference in New Issue
Block a user