Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -20,6 +20,8 @@ app.add_middleware(
|
|
20 |
|
21 |
@app.post("/get_n_depth_results")
|
22 |
async def get_n_depth_results(url,input_query):
|
|
|
|
|
23 |
all_content = {}
|
24 |
|
25 |
def add_pdf_content(selected_pdf):
|
@@ -109,31 +111,33 @@ async def get_n_depth_results(url,input_query):
|
|
109 |
futures = [executor.submit(scrapper, input_url) for input_url in (json.loads(input_url)[:2])]
|
110 |
for future in concurrent.futures.as_completed(futures):
|
111 |
next_urls.append(separate_pdf_and_nonPDF_links(future.result()))
|
|
|
|
|
112 |
selected_links_from_llm = call_llm_service(next_urls, input_url, input_query, "")
|
113 |
input_url = selected_links_from_llm
|
114 |
print(json.loads(input_url)[:2])
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
if not pdf_urls:
|
117 |
print(pdf_urls)
|
118 |
#return all_content.keys()
|
119 |
return all_content
|
120 |
else:
|
121 |
-
selected_pdf = json.loads(call_llm_service(pdf_urls, input_url, input_query, "only end with .pdf extension"))
|
122 |
print(pdf_urls)
|
123 |
-
print("selected pdf")
|
124 |
-
print(selected_pdf)
|
125 |
#return all_content.keys()
|
126 |
return all_content
|
127 |
|
128 |
-
# # Start time
|
129 |
-
# start_time = time.time()
|
130 |
|
131 |
-
# print(main("https://www.keells.com/", "Please analyse reports"))
|
132 |
|
133 |
-
#
|
134 |
-
# end_time = time.time()
|
135 |
|
136 |
-
# # Calculate the time taken
|
137 |
-
# time_taken = end_time - start_time
|
138 |
|
139 |
-
# print(f"Time taken: {time_taken} seconds")
|
|
|
20 |
|
21 |
@app.post("/get_n_depth_results")
|
22 |
async def get_n_depth_results(url,input_query):
|
23 |
+
# Start time
|
24 |
+
start_time = time.time()
|
25 |
all_content = {}
|
26 |
|
27 |
def add_pdf_content(selected_pdf):
|
|
|
111 |
futures = [executor.submit(scrapper, input_url) for input_url in (json.loads(input_url)[:2])]
|
112 |
for future in concurrent.futures.as_completed(futures):
|
113 |
next_urls.append(separate_pdf_and_nonPDF_links(future.result()))
|
114 |
+
if step==2:
|
115 |
+
break
|
116 |
selected_links_from_llm = call_llm_service(next_urls, input_url, input_query, "")
|
117 |
input_url = selected_links_from_llm
|
118 |
print(json.loads(input_url)[:2])
|
119 |
+
|
120 |
+
# End time
|
121 |
+
end_time = time.time()
|
122 |
+
|
123 |
+
# Calculate the time taken
|
124 |
+
time_taken = end_time - start_time
|
125 |
+
|
126 |
+
print(f"Time taken: {time_taken} seconds")
|
127 |
if not pdf_urls:
|
128 |
print(pdf_urls)
|
129 |
#return all_content.keys()
|
130 |
return all_content
|
131 |
else:
|
132 |
+
#selected_pdf = json.loads(call_llm_service(pdf_urls, input_url, input_query, "only end with .pdf extension"))
|
133 |
print(pdf_urls)
|
134 |
+
#print("selected pdf")
|
135 |
+
#print(selected_pdf)
|
136 |
#return all_content.keys()
|
137 |
return all_content
|
138 |
|
|
|
|
|
139 |
|
|
|
140 |
|
141 |
+
#print(main("https://www.keells.com/", "Please analyse reports"))
|
|
|
142 |
|
|
|
|
|
143 |
|
|