Spaces:
Running
Running
Updated search function in app.py
Browse filesMade the output response to have better clarity and displayed in a more clean fashion
app.py
CHANGED
@@ -87,14 +87,21 @@ def search_papers(user_input):
|
|
87 |
print(f"DEBUG: Results received - {results}") # Debug function output
|
88 |
|
89 |
if isinstance(results, list) and results and isinstance(results[0], dict):
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
92 |
for paper in results
|
93 |
])
|
|
|
94 |
|
95 |
print("DEBUG: No results found.")
|
96 |
return "No results found. Try different keywords."
|
97 |
|
|
|
98 |
# Create Gradio UI
|
99 |
with gr.Blocks() as demo:
|
100 |
gr.Markdown("# ScholarAgent")
|
|
|
87 |
print(f"DEBUG: Results received - {results}") # Debug function output
|
88 |
|
89 |
if isinstance(results, list) and results and isinstance(results[0], dict):
|
90 |
+
# ✅ Format output for better readability
|
91 |
+
formatted_results = "\n\n".join([
|
92 |
+
f"### **Title:** {paper['title']}\n"
|
93 |
+
f"**Authors:** {paper['authors']}\n"
|
94 |
+
f"**Year:** {paper['year']}\n"
|
95 |
+
f"**Abstract:** {paper['abstract']}\n"
|
96 |
+
f"[🔗 Read More]({paper['link']})"
|
97 |
for paper in results
|
98 |
])
|
99 |
+
return formatted_results
|
100 |
|
101 |
print("DEBUG: No results found.")
|
102 |
return "No results found. Try different keywords."
|
103 |
|
104 |
+
|
105 |
# Create Gradio UI
|
106 |
with gr.Blocks() as demo:
|
107 |
gr.Markdown("# ScholarAgent")
|