File size: 1,122 Bytes
407dc6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c343e35
 
407dc6a
 
c343e35
407dc6a
8ce772a
 
 
 
 
 
 
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
# ui/common.py
import gradio as gr

# --- Callback to update the exercise format dropdown based on LLM selection ---
def update_exercise_format(selected_model: str):
    """
    When the user picks a new model:
    - If it has 'Claude' in the name, default format to XML.
    - Otherwise, default to Plaintext.
    """
    if "Claude" in selected_model:
        return gr.update(value="XML")
    else:
        return gr.update(value="Plaintext")


def update_response_textboxes_amount(sampling_count: str):
    """
    Dynamically show/hide Response textboxes based on sampling count.
    """
    # Convert string to integer
    num = int(sampling_count)

    # We'll return a list of 10 updates, one for each textbox.
    updates = []
    for i in range(10):
        if i < num:
            # Show and label (i+1)
            updates.append(gr.update(visible=True, label=f"Response {i+1}"))
        else:
            # Hide the rest
            updates.append(gr.update(visible=False, label=f"Response {i + 1}"))
    return updates


def log_dropdown_choice(choice):
    print(f"A dropdown menu changed to: {choice}")