Spaces:
Running
on
Zero
Running
on
Zero
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
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) ->
|
455 |
-
"""Format search results as a
|
456 |
# Find papers synergistic with the given abstract
|
457 |
papers = find_synergistic_papers(abstract)
|
458 |
|
459 |
# Convert to DataFrame for display
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
|
474 |
-
return
|
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:
|