Spaces:
Sleeping
Sleeping
test logs output
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
import re
|
|
@@ -574,7 +575,19 @@ def format_result_string(result):
|
|
| 574 |
{result['GDC-QAG results']['Question']}
|
| 575 |
```
|
| 576 |
```
|
| 577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 578 |
{result['GDC-QAG results']['Query augmented generation']}
|
| 579 |
```
|
| 580 |
|
|
@@ -592,7 +605,19 @@ def format_result_string_multi(result):
|
|
| 592 |
{result['GDC-QAG results']['Question']}
|
| 593 |
```
|
| 594 |
```
|
| 595 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
{multi_result}
|
| 597 |
```
|
| 598 |
|
|
@@ -603,6 +628,11 @@ def format_result_string_multi(result):
|
|
| 603 |
|
| 604 |
@utilities.timeit
|
| 605 |
def execute_pipeline(question: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
df = pd.DataFrame({"questions": [question]})
|
| 607 |
print(f"\n\nQuestion received: {question}\n")
|
| 608 |
|
|
@@ -672,7 +702,15 @@ def execute_pipeline(question: str):
|
|
| 672 |
except Exception as e:
|
| 673 |
result_string = format_error_string()
|
| 674 |
|
| 675 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
|
| 677 |
|
| 678 |
def visible_component(input_text):
|
|
@@ -721,17 +759,13 @@ with gr.Blocks(title="GDC QAG MCP server", css="""
|
|
| 721 |
"""
|
| 722 |
)
|
| 723 |
|
| 724 |
-
|
| 725 |
-
# label="Query Result",
|
| 726 |
-
# lines=10,
|
| 727 |
-
# max_lines=25,
|
| 728 |
-
# info="The Result of the Query will appear here",
|
| 729 |
-
#)
|
| 730 |
|
|
|
|
| 731 |
execute_button.click(
|
| 732 |
fn=execute_pipeline,
|
| 733 |
inputs=[query_input],
|
| 734 |
-
outputs=output,
|
| 735 |
)
|
| 736 |
|
| 737 |
|
|
|
|
| 1 |
+
import io
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
import re
|
|
|
|
| 575 |
{result['GDC-QAG results']['Question']}
|
| 576 |
```
|
| 577 |
```
|
| 578 |
+
QAG gene entities:
|
| 579 |
+
{result['GDC-QAG results']['Gene entities']}
|
| 580 |
+
```
|
| 581 |
+
```
|
| 582 |
+
QAG mutation entities:
|
| 583 |
+
{result['GDC-QAG results']['Mutation entities']}
|
| 584 |
+
```
|
| 585 |
+
```
|
| 586 |
+
QAG cancer entities:
|
| 587 |
+
{result['GDC-QAG results']['Cancer entities']}
|
| 588 |
+
```
|
| 589 |
+
```
|
| 590 |
+
QAG final response:
|
| 591 |
{result['GDC-QAG results']['Query augmented generation']}
|
| 592 |
```
|
| 593 |
|
|
|
|
| 605 |
{result['GDC-QAG results']['Question']}
|
| 606 |
```
|
| 607 |
```
|
| 608 |
+
QAG gene entities:
|
| 609 |
+
{result['GDC-QAG results']['Gene entities']}
|
| 610 |
+
```
|
| 611 |
+
```
|
| 612 |
+
QAG mutation entities:
|
| 613 |
+
{result['GDC-QAG results']['Mutation entities']}
|
| 614 |
+
```
|
| 615 |
+
```
|
| 616 |
+
QAG cancer entities:
|
| 617 |
+
{result['GDC-QAG results']['Cancer entities']}
|
| 618 |
+
```
|
| 619 |
+
```
|
| 620 |
+
QAG final response:
|
| 621 |
{multi_result}
|
| 622 |
```
|
| 623 |
|
|
|
|
| 628 |
|
| 629 |
@utilities.timeit
|
| 630 |
def execute_pipeline(question: str):
|
| 631 |
+
# redirect stdout to logs
|
| 632 |
+
buffer = io.StringIO()
|
| 633 |
+
sys_stdout = sys.stdout
|
| 634 |
+
sys.stdout = buffer
|
| 635 |
+
|
| 636 |
df = pd.DataFrame({"questions": [question]})
|
| 637 |
print(f"\n\nQuestion received: {question}\n")
|
| 638 |
|
|
|
|
| 702 |
except Exception as e:
|
| 703 |
result_string = format_error_string()
|
| 704 |
|
| 705 |
+
|
| 706 |
+
# Restore stdout
|
| 707 |
+
sys.stdout = sys_stdout
|
| 708 |
+
logs = buffer.getvalue()
|
| 709 |
+
|
| 710 |
+
# Format logs for Markdown
|
| 711 |
+
logs_string = f"```bash\n{logs}\n```"
|
| 712 |
+
|
| 713 |
+
return result_string, logs_string
|
| 714 |
|
| 715 |
|
| 716 |
def visible_component(input_text):
|
|
|
|
| 759 |
"""
|
| 760 |
)
|
| 761 |
|
| 762 |
+
logs = gr.Markdown()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 763 |
|
| 764 |
+
|
| 765 |
execute_button.click(
|
| 766 |
fn=execute_pipeline,
|
| 767 |
inputs=[query_input],
|
| 768 |
+
outputs=[output, logs],
|
| 769 |
)
|
| 770 |
|
| 771 |
|