davidfearne
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -48,10 +48,6 @@ def format_elapsed_time(time):
|
|
48 |
# Format the elapsed time to two decimal places
|
49 |
return "{:.2f}".format(time)
|
50 |
|
51 |
-
def search_knowledgebase(query):
|
52 |
-
results = retriever(query)
|
53 |
-
return results
|
54 |
-
|
55 |
def process_search_results(search_results):
|
56 |
"""
|
57 |
Processes search results to extract and organize metadata and other details.
|
@@ -108,7 +104,7 @@ def lookup_related_chunks(df_chunks, chunk_id):
|
|
108 |
return df_chunks[(df_chunks['Title'] == title) & (df_chunks['PageNumber'].isin(page_range))]
|
109 |
|
110 |
|
111 |
-
def search_and_reconstruct(query, df_chunks):
|
112 |
"""
|
113 |
Combines search, lookup of related chunks, and text reconstruction.
|
114 |
|
@@ -118,7 +114,7 @@ def search_and_reconstruct(query, df_chunks):
|
|
118 |
:param top_k: Number of top search results to retrieve.
|
119 |
:return: A list of dictionaries with document title, page number, and reconstructed text.
|
120 |
"""
|
121 |
-
search_results =
|
122 |
processed_results = process_search_results(search_results)
|
123 |
|
124 |
reconstructed_results = []
|
|
|
48 |
# Format the elapsed time to two decimal places
|
49 |
return "{:.2f}".format(time)
|
50 |
|
|
|
|
|
|
|
|
|
51 |
def process_search_results(search_results):
|
52 |
"""
|
53 |
Processes search results to extract and organize metadata and other details.
|
|
|
104 |
return df_chunks[(df_chunks['Title'] == title) & (df_chunks['PageNumber'].isin(page_range))]
|
105 |
|
106 |
|
107 |
+
def search_and_reconstruct(query, df_chunks, k):
|
108 |
"""
|
109 |
Combines search, lookup of related chunks, and text reconstruction.
|
110 |
|
|
|
114 |
:param top_k: Number of top search results to retrieve.
|
115 |
:return: A list of dictionaries with document title, page number, and reconstructed text.
|
116 |
"""
|
117 |
+
search_results = retriever(query, k)
|
118 |
processed_results = process_search_results(search_results)
|
119 |
|
120 |
reconstructed_results = []
|