Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
b6c2057
1
Parent(s):
44cca0e
Add JSON formatting for search results in find_synergistic_papers
Browse files
app.py
CHANGED
|
@@ -451,6 +451,16 @@ 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
|
|
@@ -659,7 +669,7 @@ def create_interface():
|
|
| 659 |
|
| 660 |
# API endpoint for find_synergistic_papers
|
| 661 |
search_btn_hidden.click(
|
| 662 |
-
|
| 663 |
inputs=[abstract_input_hidden],
|
| 664 |
outputs=[synergistic_papers_output],
|
| 665 |
api_name="find_synergistic_papers",
|
|
|
|
| 451 |
return papers
|
| 452 |
|
| 453 |
|
| 454 |
+
def format_search_results_json(abstract: str) -> str:
|
| 455 |
+
"""Format search results as JSON for display"""
|
| 456 |
+
# Find papers synergistic with the given abstract
|
| 457 |
+
papers = find_synergistic_papers(abstract)
|
| 458 |
+
|
| 459 |
+
# Convert to JSON for display
|
| 460 |
+
json_output = json.dumps(papers, indent=2)
|
| 461 |
+
return json_output
|
| 462 |
+
|
| 463 |
+
|
| 464 |
def format_search_results(abstract: str) -> tuple[pd.DataFrame, list[dict]]:
|
| 465 |
"""Format search results as a DataFrame for display"""
|
| 466 |
# Find papers synergistic with the given abstract
|
|
|
|
| 669 |
|
| 670 |
# API endpoint for find_synergistic_papers
|
| 671 |
search_btn_hidden.click(
|
| 672 |
+
format_search_results_json,
|
| 673 |
inputs=[abstract_input_hidden],
|
| 674 |
outputs=[synergistic_papers_output],
|
| 675 |
api_name="find_synergistic_papers",
|