File size: 1,915 Bytes
d0f716d
 
 
 
 
 
 
4aa0743
 
d0f716d
4aa0743
 
d0f716d
 
 
 
 
 
 
4aa0743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
File: practical_subtasks.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Event handler for Gradio app to filter practical subtasks based on selected practical subtasks.
License: MIT License
"""

import gradio as gr

# Importing necessary components for the Gradio app
from app.config import config_data
from app.components import threshold_create_ui, dropdown_create_ui


def event_handler_practical_subtasks(
    practical_tasks, practical_subtasks, practical_subtasks_selected
):
    practical_subtasks_selected[practical_tasks] = practical_subtasks

    if practical_subtasks.lower() == "professional skills":
        return (
            practical_subtasks_selected,
            gr.Column(visible=True),
            threshold_create_ui(
                value=0.5,
                minimum=0.0,
                maximum=1.0,
                step=0.01,
                label=config_data.Labels_THRESHOLD_PROFESSIONAL_SKILLS_LABEL,
                info=config_data.InformationMessages_THRESHOLD_PROFESSIONAL_SKILLS_INFO,
                show_label=True,
                interactive=True,
                visible=True,
                render=True,
                elem_classes="number-container",
            ),
            dropdown_create_ui(
                label=f"Professional skills ({len(config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS)})",
                info=config_data.InformationMessages_DROPDOWN_PROFESSIONAL_SKILLS_INFO,
                choices=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS,
                value=config_data.Settings_DROPDOWN_PROFESSIONAL_SKILLS[0],
                visible=True,
                elem_classes="dropdown-container",
            ),
        )
    else:
        return (
            practical_subtasks_selected,
            gr.Column(visible=False),
            threshold_create_ui(visible=False),
            dropdown_create_ui(visible=False),
        )