Spaces:
Running
Running
File size: 930 Bytes
0f24bef 130172d 076f827 0f24bef 6e75130 0f24bef cc2b0ca 0f24bef 877359c dbd2c54 e37b851 cc2b0ca e37b851 cc2b0ca e37b851 |
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 |
import gradio as gr
import sys
import os
def execute_code(code):
try:
exec(code)
return "Code executed successfully!"
except Exception as e:
return f"Error: {str(e)}"
def execute_code_callback(code, temp, max):
return execute_code(code)
print("hello")
title = """Simple coding Demo"""
with gr.Blocks() as demo:
gr.Markdown(title)
prompt = gr.Code(label="Enter your code prompt", value="def print_hello_world():")
with gr.Row():
temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
max_length = gr.Slider(minimum=100, maximum=1024, step=10, value=450, label="Generate Length")
generate_btn = gr.Button("Try✨Coding")
output = gr.Code(label="✨Output:", lines=40)
generate_btn.click(
fn=execute_code_callback,
inputs=[prompt, temperature, max_length],
outputs=output
)
demo.launch() |