File size: 1,681 Bytes
3a63794
4d5b0bf
3a63794
4d5b0bf
3a63794
 
 
 
 
4d5b0bf
3a63794
e83cec6
3a63794
 
 
 
 
 
 
4d5b0bf
 
 
 
 
 
 
3a63794
 
 
 
 
 
 
 
 
 
 
 
4d5b0bf
 
 
 
3a63794
 
 
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
import gradio as gr
from controllers.config import on_del_btn_click, on_fw_add_btn_click, on_fw_radio_change
from controllers.fw import fetch_fw_options
from utilities.constants import FW_RADIO_CHOICES


def config_interface():
    with gr.Blocks() as ui:
        gr.Markdown("### Forwarding Endpoint")
        radio_btn = gr.Radio(choices=FW_RADIO_CHOICES,
                             label="Select Forwarding Option")
        fw_list = gr.Label(value=fetch_fw_options,
                           label="Current Endpoints", every=2)
        with gr.Column():
            input_box = gr.Textbox(label="Forwarding Endpoint",
                                   placeholder="https://...")
            with gr.Row():
                add_btn = gr.Button(value="Add Endpoint", variant="secondary")
                del_btn = gr.Button(value="Delete Endpoint", variant="stop")
        # gr.Markdown("### OpenAI API Key")
        # with gr.Column():
        #     input_box2 = gr.Textbox(
        #         label="OpenAI API Key", placeholder="sk_...")
        #     with gr.Row():
        #         add_btn2 = gr.Button(value="Add Key", variant="secondary")
        #         del_btn2 = gr.Button(value="Reset Key", variant="stop")

        # Assign actions
        add_btn.click(
            fn=on_fw_add_btn_click,
            inputs=[input_box],
            outputs=[fw_list, input_box]
        )
        del_btn.click(
            fn=on_del_btn_click,
            inputs=[input_box],
            outputs=[fw_list, input_box]
        )
        radio_btn.change(
            fn=on_fw_radio_change,
            inputs=[radio_btn],
        )

    ui.title = "Configuration"
    return ui