Spaces:
Running
Running
Daniel Foley
commited on
Commit
·
ea5cbee
1
Parent(s):
148d8c2
added time logging to RAG.py
Browse files
RAG.py
CHANGED
@@ -31,7 +31,7 @@ def retrieve(query: str,vectorstore:PineconeVectorStore, k: int = 1000) -> Tuple
|
|
31 |
for res, score in results:
|
32 |
documents.append(res)
|
33 |
scores.append(score)
|
34 |
-
|
35 |
return documents, scores
|
36 |
|
37 |
def safe_get_json(url: str) -> Optional[Dict]:
|
@@ -87,7 +87,7 @@ def rerank(documents: List[Document], query: str) -> List[Document]:
|
|
87 |
# Create BM25 retriever with the processed documents
|
88 |
reranker = BM25Retriever.from_documents(full_docs, k=min(10, len(full_docs)))
|
89 |
reranked_docs = reranker.invoke(query)
|
90 |
-
|
91 |
return reranked_docs
|
92 |
|
93 |
def parse_xml_and_query(query:str,xml_string:str) -> str:
|
@@ -195,7 +195,7 @@ def RAG(llm: Any, query: str,vectorstore:PineconeVectorStore, top: int = 10, k:
|
|
195 |
|
196 |
# Parse and return response
|
197 |
parsed = parse_xml_and_check(response.content)
|
198 |
-
|
199 |
return parsed, reranked
|
200 |
|
201 |
except Exception as e:
|
|
|
31 |
for res, score in results:
|
32 |
documents.append(res)
|
33 |
scores.append(score)
|
34 |
+
logging.info(f"Finished Retrieval: {time.time() - start}")
|
35 |
return documents, scores
|
36 |
|
37 |
def safe_get_json(url: str) -> Optional[Dict]:
|
|
|
87 |
# Create BM25 retriever with the processed documents
|
88 |
reranker = BM25Retriever.from_documents(full_docs, k=min(10, len(full_docs)))
|
89 |
reranked_docs = reranker.invoke(query)
|
90 |
+
logging.info(f"Finished reranking: {time.time()-start}")
|
91 |
return reranked_docs
|
92 |
|
93 |
def parse_xml_and_query(query:str,xml_string:str) -> str:
|
|
|
195 |
|
196 |
# Parse and return response
|
197 |
parsed = parse_xml_and_check(response.content)
|
198 |
+
logging.info(f"RAG Finished: {time.time()-start}")
|
199 |
return parsed, reranked
|
200 |
|
201 |
except Exception as e:
|