Spaces:
Sleeping
Sleeping
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 | |