Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,29 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import json
|
| 4 |
|
| 5 |
-
# Завантаження обох JSON-файлів
|
| 6 |
with open("analysis_explanations_1.json", encoding="utf-8") as f1:
|
| 7 |
data1 = json.load(f1)
|
| 8 |
|
| 9 |
with open("analysis_explanations_2.json", encoding="utf-8") as f2:
|
| 10 |
data2 = json.load(f2)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Побудова словника: {назва аналізу: відповідь}
|
| 16 |
-
analysis_dict = {entry["input"]: entry["output"] for entry in all_data}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
analysis_options = list(analysis_dict.keys())
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
# Інтерфейс
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
-
gr.Markdown("## 🧪 Пояснення до аналізів")
|
| 28 |
with gr.Row():
|
| 29 |
test_dropdown = gr.Dropdown(label="Оберіть аналіз", choices=analysis_options)
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
|
|
|
|
| 4 |
with open("analysis_explanations_1.json", encoding="utf-8") as f1:
|
| 5 |
data1 = json.load(f1)
|
| 6 |
|
| 7 |
with open("analysis_explanations_2.json", encoding="utf-8") as f2:
|
| 8 |
data2 = json.load(f2)
|
| 9 |
|
| 10 |
+
dict1 = {entry["input"]: entry["output"] for entry in data1}
|
| 11 |
+
dict2 = {entry["input"]: entry["output"] for entry in data2}
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
analysis_options = sorted(set(list(dict1.keys()) + list(dict2.keys())))
|
|
|
|
| 14 |
|
| 15 |
+
def explain_analysis_separately(selected_test):
|
| 16 |
+
output1 = dict1.get(selected_test, "Немає у першому джерелі.")
|
| 17 |
+
output2 = dict2.get(selected_test, "Немає у другому джерелі.")
|
| 18 |
+
return output1, output2
|
| 19 |
|
|
|
|
| 20 |
with gr.Blocks() as demo:
|
| 21 |
+
gr.Markdown("## 🧪 Пояснення до аналізів з двох джерел")
|
| 22 |
with gr.Row():
|
| 23 |
test_dropdown = gr.Dropdown(label="Оберіть аналіз", choices=analysis_options)
|
| 24 |
+
with gr.Row():
|
| 25 |
+
output1 = gr.Textbox(label="Варіант 1", lines=8)
|
| 26 |
+
output2 = gr.Textbox(label="Варіант 2", lines=8)
|
| 27 |
+
test_dropdown.change(fn=explain_analysis_separately, inputs=test_dropdown, outputs=[output1, output2])
|
| 28 |
|
| 29 |
demo.launch()
|