pdx97 commited on
Commit
148309a
·
verified ·
1 Parent(s): af62f46

Updated search function in app.py

Browse files

Made the output response to have better clarity and displayed in a more clean fashion

Files changed (1) hide show
  1. app.py +9 -2
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
- return "\n\n".join([
91
- f"**Title:** {paper['title']}\n**Authors:** {paper['authors']}\n**Year:** {paper['year']}\n**Abstract:** {paper['abstract']}\n[Read More]({paper['link']})"
 
 
 
 
 
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")