Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -461,23 +461,35 @@ with gr.Blocks() as demo:
|
|
461 |
output_display = gr.Markdown()
|
462 |
search_button = gr.Button("Search")
|
463 |
|
464 |
-
def search_papers(user_input):
|
465 |
keywords = [kw.strip() for kw in user_input.split(",") if kw.strip()]
|
466 |
-
|
467 |
-
|
468 |
-
if
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
f"📌 **Title:** {paper['title']}\n\n"
|
474 |
f"👨🔬 **Authors:** {paper['authors']}\n\n"
|
475 |
f"📅 **Year:** {paper['year']}\n\n"
|
476 |
-
f"📖 **Summary:** {paper
|
477 |
-
f"🔢 **Citations:** {paper
|
478 |
f"[🔗 Read Full Paper]({paper['link']})\n\n"
|
479 |
for paper in results
|
480 |
])
|
|
|
|
|
|
|
481 |
|
482 |
search_button.click(search_papers, inputs=[keyword_input], outputs=[output_display])
|
483 |
print("DEBUG: Gradio UI is running. Waiting for user input...")
|
|
|
461 |
output_display = gr.Markdown()
|
462 |
search_button = gr.Button("Search")
|
463 |
|
464 |
+
def search_papers(user_input, year_range, min_citations):
|
465 |
keywords = [kw.strip() for kw in user_input.split(",") if kw.strip()]
|
466 |
+
print(f"DEBUG: Received input keywords - {keywords}")
|
467 |
+
|
468 |
+
if not keywords:
|
469 |
+
print("DEBUG: No valid keywords provided.")
|
470 |
+
return "Error: Please enter at least one valid keyword."
|
471 |
+
|
472 |
+
results = fetch_latest_arxiv_papers(keywords, num_results=5, year_range=year_range, min_citations=int(min_citations))
|
473 |
+
print(f"DEBUG: Results received - {results}")
|
474 |
+
|
475 |
+
# If results are empty or an error occurred, display an error message
|
476 |
+
if not results or isinstance(results, list) and "error" in results[0]:
|
477 |
+
print(f"DEBUG: Error in fetching results - {results[0]['error']}")
|
478 |
+
return results[0]["error"] if results else "No results found. Try different keywords."
|
479 |
+
|
480 |
+
# Format output
|
481 |
+
formatted_results = "\n\n".join([
|
482 |
f"📌 **Title:** {paper['title']}\n\n"
|
483 |
f"👨🔬 **Authors:** {paper['authors']}\n\n"
|
484 |
f"📅 **Year:** {paper['year']}\n\n"
|
485 |
+
f"📖 **Summary:** {paper['summary'] if 'summary' in paper else 'No summary available'}\n\n"
|
486 |
+
f"🔢 **Citations:** {paper['citations']}\n\n"
|
487 |
f"[🔗 Read Full Paper]({paper['link']})\n\n"
|
488 |
for paper in results
|
489 |
])
|
490 |
+
print(f"DEBUG: Formatted Results - {formatted_results}")
|
491 |
+
return formatted_results
|
492 |
+
|
493 |
|
494 |
search_button.click(search_papers, inputs=[keyword_input], outputs=[output_display])
|
495 |
print("DEBUG: Gradio UI is running. Waiting for user input...")
|