nomadicsynth commited on
Commit
0529f34
·
1 Parent(s): 31ab989

Refactor format_search_results to return a dictionary with 'data' and 'headers' keys instead of a DataFrame

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -451,27 +451,27 @@ def find_synergistic_papers(abstract: str, limit=25) -> list[dict]:
451
  return papers
452
 
453
 
454
- def format_search_results(abstract: str) -> tuple[pd.DataFrame, list[dict]]:
455
- """Format search results as a DataFrame for display"""
456
  # Find papers synergistic with the given abstract
457
  papers = find_synergistic_papers(abstract)
458
 
459
  # Convert to DataFrame for display
460
- df = pd.DataFrame(
461
- [
462
- {
463
- "Title": p["title"],
464
- "Authors": p["authors"][:50] + "..." if len(p["authors"]) > 50 else p["authors"],
465
- "Categories": p["categories"],
466
- "Date": p["update_date"],
467
- "Match Score": f"{int(p['synergy_score'] * 100)}%",
468
- "ID": p["id"], # Hidden column for reference
469
- }
470
- for p in papers
471
- ]
472
- )
473
 
474
- return df, papers # Return both DataFrame and original data
475
 
476
 
477
  def format_paper_as_markdown(paper: dict) -> str:
 
451
  return papers
452
 
453
 
454
+ def format_search_results(abstract: str) -> dict:
455
+ """Format search results as a dictionary with 'data' and 'headers' keys"""
456
  # Find papers synergistic with the given abstract
457
  papers = find_synergistic_papers(abstract)
458
 
459
  # Convert to DataFrame for display
460
+ data = [
461
+ {
462
+ "Title": p["title"],
463
+ "Authors": p["authors"][:50] + "..." if len(p["authors"]) > 50 else p["authors"],
464
+ "Categories": p["categories"],
465
+ "Date": p["update_date"],
466
+ "Match Score": f"{int(p['synergy_score'] * 100)}%",
467
+ "ID": p["id"], # Hidden column for reference
468
+ }
469
+ for p in papers
470
+ ]
471
+
472
+ headers = ["Title", "Authors", "Categories", "Date", "Match Score", "ID"]
473
 
474
+ return {"data": data, "headers": headers}
475
 
476
 
477
  def format_paper_as_markdown(paper: dict) -> str: