Spaces:
Sleeping
Sleeping
Shreyas094
commited on
Commit
•
4e8e1c0
1
Parent(s):
ad77a7a
Update app.py
Browse files
app.py
CHANGED
@@ -220,19 +220,19 @@ def create_gradio_interface():
|
|
220 |
results = gr.Markdown("### Search Results and Summary will appear here...")
|
221 |
|
222 |
def perform_search_and_summarize(q, url, cats, num, use_traf, t_range, lang, safe, engines, sort, chars):
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
|
237 |
search_button.click(
|
238 |
perform_search_and_summarize,
|
|
|
220 |
results = gr.Markdown("### Search Results and Summary will appear here...")
|
221 |
|
222 |
def perform_search_and_summarize(q, url, cats, num, use_traf, t_range, lang, safe, engines, sort, chars):
|
223 |
+
logger.debug(f"Performing search for query: {q}")
|
224 |
+
try:
|
225 |
+
search_results = search_searx(q, instance_url=url, categories=cats, num_results=int(num),
|
226 |
+
use_trafilatura=use_traf, time_range=t_range, language=lang, safesearch=int(safe),
|
227 |
+
search_engines=engines, sort_by=sort, max_chars=chars)
|
228 |
+
|
229 |
+
logger.debug("Search completed, attempting to summarize")
|
230 |
+
summary = summarize_with_llm(q, search_results)
|
231 |
+
|
232 |
+
return f"## AI-Generated Summary\n\n{summary}\n\n## Original Search Results\n\n{search_results}"
|
233 |
+
except Exception as e:
|
234 |
+
logger.exception(f"Error in perform_search_and_summarize: {str(e)}")
|
235 |
+
return f"An error occurred: {str(e)}"
|
236 |
|
237 |
search_button.click(
|
238 |
perform_search_and_summarize,
|