File size: 495 Bytes
26d2488
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr
from modules.settings.user_settings import UserSettings

def set_api_key(key: str):
    UserSettings.get_instance().set_api_key(key)
    return "API key set"


def create_settings_ui():
    settings = UserSettings.get_instance()
    api_key = gr.Textbox(label="You OpenAI API key", type="password", default=settings.get_api_key())
    set_status = gr.Text()
    key_button = gr.Button(label="Set Key")
    key_button.click(set_api_key, outputs=[set_status], inputs=[api_key])