AlexDataMedWork commited on
Commit
64a3058
·
verified ·
1 Parent(s): ea9ab8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -1,29 +1,46 @@
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()
 
1
  import gradio as gr
2
  import json
3
 
4
+ # --- зчитування 3 джерел ---
5
  with open("analysis_explanations_1.json", encoding="utf-8") as f1:
6
  data1 = json.load(f1)
7
 
8
  with open("analysis_explanations_2.json", encoding="utf-8") as f2:
9
  data2 = json.load(f2)
10
 
11
+ try:
12
+ with open("analyses_results.json", encoding="utf-8") as f3:
13
+ data3 = json.load(f3)
14
+ except FileNotFoundError:
15
+ data3 = []
16
+
17
+ # --- перетворення у словники: {input -> output} ---
18
  dict1 = {entry["input"]: entry["output"] for entry in data1}
19
  dict2 = {entry["input"]: entry["output"] for entry in data2}
20
+ dict3 = {entry["input"]: entry["output"] for entry in data3}
21
 
22
+ # --- список унікальних аналізів ---
23
+ analysis_options = sorted(set(list(dict1.keys()) + list(dict2.keys()) + list(dict3.keys())))
24
 
25
  def explain_analysis_separately(selected_test):
26
  output1 = dict1.get(selected_test, "Немає у першому джерелі.")
27
  output2 = dict2.get(selected_test, "Немає у другому джерелі.")
28
+ output3 = dict3.get(selected_test, "Немає у третьому джерелі.")
29
+ return output1, output2, output3
30
 
31
  with gr.Blocks() as demo:
32
+ gr.Markdown("## 🧪 Пояснення до аналізів з трьох джерел")
33
  with gr.Row():
34
  test_dropdown = gr.Dropdown(label="Оберіть аналіз", choices=analysis_options)
35
  with gr.Row():
36
+ output1 = gr.Textbox(label="Варіант 1 (analysis_explanations_1.json)", lines=8)
37
+ output2 = gr.Textbox(label="Варіант 2 (analysis_explanations_2.json)", lines=8)
38
+ output3 = gr.Textbox(label="Варіант 3 (analyses_results.json)", lines=8)
39
+
40
+ test_dropdown.change(
41
+ fn=explain_analysis_separately,
42
+ inputs=test_dropdown,
43
+ outputs=[output1, output2, output3]
44
+ )
45
 
46
  demo.launch()