Spaces:
Sleeping
Sleeping
Commit
·
269bf9a
1
Parent(s):
ad883ad
Refactor code formatting for improved readability and consistency in analysis and interface functions
Browse files
app.py
CHANGED
@@ -303,9 +303,9 @@ def analyse_abstracts(query_abstract: str, compare_abstract: dict) -> str:
|
|
303 |
return "Invalid compare_abstract format. Expected a non-empty string."
|
304 |
|
305 |
messages = [
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
|
310 |
Paper 1 Abstract:
|
311 |
{query_abstract}
|
@@ -364,8 +364,8 @@ Return a valid JSON object in the following structure:
|
|
364 |
|
365 |
Return only the JSON object. All key names and string values must be in double quotes.
|
366 |
""",
|
367 |
-
|
368 |
-
]
|
369 |
|
370 |
# Generate analysis
|
371 |
try:
|
@@ -635,7 +635,9 @@ def create_interface():
|
|
635 |
show_copy_button=True,
|
636 |
key="analysis_output",
|
637 |
)
|
638 |
-
with gr.Accordion(
|
|
|
|
|
639 |
gr.Markdown(
|
640 |
"""
|
641 |
This connection analysis was generated by an AI model trained to reason about conceptual links between research papers.
|
@@ -652,7 +654,7 @@ def create_interface():
|
|
652 |
|
653 |
# Hidden UI elements for API endpoint
|
654 |
abstract_input_hidden = gr.Textbox(visible=False, key="abstract_hidden")
|
655 |
-
synergistic_papers_output = gr.JSON(visible=False, key="synergistic_papers_output")
|
656 |
search_btn_hidden = gr.Button(visible=False, key="search_hidden")
|
657 |
|
658 |
# API endpoint for find_synergistic_papers
|
@@ -674,7 +676,14 @@ def create_interface():
|
|
674 |
data_path + "/flagged_paper_matches",
|
675 |
)
|
676 |
analysis_logger.setup(
|
677 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
data_path + "/flagged_analyses",
|
679 |
)
|
680 |
|
@@ -704,7 +713,11 @@ def create_interface():
|
|
704 |
outputs=[selected_paper_state],
|
705 |
api_name=False,
|
706 |
).then(
|
707 |
-
lambda: (
|
|
|
|
|
|
|
|
|
708 |
outputs=[analyze_btn, paper_feedback_accordion, analysis_feedback_accordion],
|
709 |
api_name=False,
|
710 |
).then(
|
@@ -748,7 +761,14 @@ def create_interface():
|
|
748 |
|
749 |
flag_analysis_btn.click(
|
750 |
lambda *args: analysis_logger.flag(list(args)),
|
751 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
preprocess=False,
|
753 |
api_name=False,
|
754 |
)
|
|
|
303 |
return "Invalid compare_abstract format. Expected a non-empty string."
|
304 |
|
305 |
messages = [
|
306 |
+
{
|
307 |
+
"role": "user",
|
308 |
+
"content": f"""You are trained in evaluating conceptual and methodological connections between research papers. Please **identify and analyze the reasoning-based links** between the following two papers:
|
309 |
|
310 |
Paper 1 Abstract:
|
311 |
{query_abstract}
|
|
|
364 |
|
365 |
Return only the JSON object. All key names and string values must be in double quotes.
|
366 |
""",
|
367 |
+
},
|
368 |
+
]
|
369 |
|
370 |
# Generate analysis
|
371 |
try:
|
|
|
635 |
show_copy_button=True,
|
636 |
key="analysis_output",
|
637 |
)
|
638 |
+
with gr.Accordion(
|
639 |
+
label="Feedback and Flagging", open=True, visible=False
|
640 |
+
) as analysis_feedback_accordion:
|
641 |
gr.Markdown(
|
642 |
"""
|
643 |
This connection analysis was generated by an AI model trained to reason about conceptual links between research papers.
|
|
|
654 |
|
655 |
# Hidden UI elements for API endpoint
|
656 |
abstract_input_hidden = gr.Textbox(visible=False, key="abstract_hidden")
|
657 |
+
synergistic_papers_output = gr.JSON(visible=False, label="Synergistic Papers", key="synergistic_papers_output")
|
658 |
search_btn_hidden = gr.Button(visible=False, key="search_hidden")
|
659 |
|
660 |
# API endpoint for find_synergistic_papers
|
|
|
676 |
data_path + "/flagged_paper_matches",
|
677 |
)
|
678 |
analysis_logger.setup(
|
679 |
+
[
|
680 |
+
abstract_input,
|
681 |
+
paper_details_output,
|
682 |
+
analysis_output,
|
683 |
+
analysis_feedback,
|
684 |
+
analysis_expert,
|
685 |
+
analysis_comment,
|
686 |
+
],
|
687 |
data_path + "/flagged_analyses",
|
688 |
)
|
689 |
|
|
|
713 |
outputs=[selected_paper_state],
|
714 |
api_name=False,
|
715 |
).then(
|
716 |
+
lambda: (
|
717 |
+
gr.update(visible=False),
|
718 |
+
gr.update(visible=False),
|
719 |
+
gr.update(visible=False),
|
720 |
+
), # Hide analyze button and feedback accordions
|
721 |
outputs=[analyze_btn, paper_feedback_accordion, analysis_feedback_accordion],
|
722 |
api_name=False,
|
723 |
).then(
|
|
|
761 |
|
762 |
flag_analysis_btn.click(
|
763 |
lambda *args: analysis_logger.flag(list(args)),
|
764 |
+
inputs=[
|
765 |
+
abstract_input,
|
766 |
+
paper_details_output,
|
767 |
+
analysis_output,
|
768 |
+
analysis_feedback,
|
769 |
+
analysis_expert,
|
770 |
+
analysis_comment,
|
771 |
+
],
|
772 |
preprocess=False,
|
773 |
api_name=False,
|
774 |
)
|