Spaces:
Runtime error
Runtime error
import gradio as gr | |
from controllers.config import on_del_btn_click, on_fw_add_btn_click | |
from controllers.fw import fetch_fw_options | |
from utilities.constants import FW_RADIO_CHOICES, FW_DEFAULT_OPTION | |
def config_interface(): | |
with gr.Blocks() as ui: | |
gr.Markdown("### Forwarding Endpoint") | |
radio_btn = gr.Radio(choices=FW_RADIO_CHOICES, value=FW_DEFAULT_OPTION, | |
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] | |
) | |
ui.title = "Configuration" | |
return ui | |