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

Updated search function

Browse files

Made the response more readable

Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -87,13 +87,14 @@ 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
- # ✅ 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
@@ -102,6 +103,7 @@ def search_papers(user_input):
102
  return "No results found. Try different keywords."
103
 
104
 
 
105
  # Create Gradio UI
106
  with gr.Blocks() as demo:
107
  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 with spacing and line breaks
91
  formatted_results = "\n\n".join([
92
+ f"---\n\n"
93
+ f"📌 **Title:**\n{paper['title']}\n\n"
94
+ f"👨‍🔬 **Authors:**\n{paper['authors']}\n\n"
95
+ f"📅 **Year:** {paper['year']}\n\n"
96
+ f"📖 **Abstract:**\n{paper['abstract'][:500]}... *(truncated for readability)*\n\n"
97
+ f"[🔗 Read Full Paper]({paper['link']})\n\n"
98
  for paper in results
99
  ])
100
  return formatted_results
 
103
  return "No results found. Try different keywords."
104
 
105
 
106
+
107
  # Create Gradio UI
108
  with gr.Blocks() as demo:
109
  gr.Markdown("# ScholarAgent")