UserInterface / app.py
nadiamaqbool81's picture
Update app.py
0e84598
raw
history blame
1.18 kB
import gradio as gr
models=[
"nadiamaqbool81/starcoderbase-1b-hf",
"nadiamaqbool81/starcoderbase-1b-hf_python",
"nadiamaqbool81/starcoderbase-1b-hf_python",
]
model_box=[
gr.Interface.load(f"models/{models[0]}",preprocess=True),
gr.Interface.load(f"models/{models[1]}",preprocess=True),
gr.Interface.load(f"models/{models[2]}",preprocess=True),
]
current_model=model_box[0]
def the_process(input_text, model_choice):
a_variable = model_box[model_choice]
output = a_variable(input_text)
return(output)
with gr.Blocks() as demo:
gr.HTML("""<h1 style="font-weight:600;font-size:50;margin-top:4px;margin-bottom:4px;text-align:center;">Text to Code Generation</h1></div>""")
with gr.Row():
with gr.Column():
model_choice = gr.Dropdown(label="Select Model", choices=[m for m in models], type="index", interactive=True)
input_text = gr.Textbox(label="Input Prompt")
the_button = gr.Button()
with gr.Column():
output_window = gr.Code(label="Generated Code")
the_button.click(the_process, inputs=[input_text, model_choice], outputs=[output_window])
demo.launch()