From dbcb8da015675e6f8be59189aeb84dfd66f31c5c Mon Sep 17 00:00:00 2001 From: timothyafolami Date: Tue, 13 Aug 2024 22:16:12 +0100 Subject: [PATCH] updated utils.. working on the api --- .../__pycache__/utils.cpython-311.pyc | Bin 20789 -> 20879 bytes data_ingestion/utils.py | 19 ++++++++++-------- loggings/app.log | 7 +++++++ search.py | 5 +---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/data_ingestion/__pycache__/utils.cpython-311.pyc b/data_ingestion/__pycache__/utils.cpython-311.pyc index 5ce3b2b3b3e34f3f5c6d3ad02e89c17de51c93c5..db9f721a0fd39fcf26dfba372ee6c781f9d8985e 100644 GIT binary patch delta 588 zcmdnGh_Qb$Bj0jfUM>b8IC^S#T9n5`J_$yrjp{XwjHZ*9Flx)2rO34~Mj58aw=hH* zrI@EE0(r(M7AeX=+9btt@;gRxMytteOm0d{45?Pjfaa_Q83qPX_9@mWCP0M_Da^qP znl_uGm~`BYU$OutlbN7uKolDgGXwGGPe5WiLkWZgBHn=a#?3Ex&+uLE%Mi%`4oR4K6phcp996GC&r;@CODaRt+%G!F+>*yPvCz zYl8C?5tR$Vsuwxbu5hSb;8454!PC#(#XZ$!hVUGjiy~@QMAR;Fs9)hwzW_!zxcMhA z_LyJcmgia^yddQQx7Gy~t;uQL#%yXp=V&@^p6~sWk?ASJ5(P? delta 510 zcmeBQ%(!(CBj0jfUM>b8n6qnl+Hd!Xd=iX$8`WzV8BHcHVbqp4O_6J1j517-Z()cs zN-;}O1oDhi%u|$sv`LD^(#oAa1-+?kS@Col9A zVLUO}npf7LhOvfe850A;Y9NMyTILkST9$N%TGkq77lv4~TDBUN8n!G(nEY&p6sEaM zRlE!gwJbHPlM}?m1WMRpk_-$$r7V*Ry~HL@(Bk7@Wau%kVNPM5+{h{t0yKs-4df0M zzoIgrhN21(0kT(<^_F09W^QIqVo_#EWqfgJVo`ENkq$`O2uR#wNy$tuDbfY0WWU9f zl5~r;ur#%(@)l$E zP`b#Xe1%2%0vO%kj=ThwuOZ diff --git a/data_ingestion/utils.py b/data_ingestion/utils.py index f24fd820..bb60facb 100644 --- a/data_ingestion/utils.py +++ b/data_ingestion/utils.py @@ -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 diff --git a/loggings/app.log b/loggings/app.log index 2544e33f..f1043db7 100644 --- a/loggings/app.log +++ b/loggings/app.log @@ -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. diff --git a/search.py b/search.py index 2a46e898..72e1b293 100644 --- a/search.py +++ b/search.py @@ -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}")