Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,19 +8,28 @@ def execute_code(code):
|
|
| 8 |
except Exception as e:
|
| 9 |
return f"Error: {str(e)}"
|
| 10 |
|
| 11 |
-
|
| 12 |
-
execute_button = gr.Button()
|
| 13 |
-
result_text = gr.Textbox(label="Execution Result")
|
| 14 |
-
|
| 15 |
-
def execute_code_callback(code):
|
| 16 |
return execute_code(code)
|
| 17 |
print("hello")
|
| 18 |
-
iface = gr.Interface(
|
| 19 |
-
fn=execute_code_callback,
|
| 20 |
-
inputs=[code_input, execute_button],
|
| 21 |
-
outputs=result_text,
|
| 22 |
-
title="Code Executor",
|
| 23 |
-
description="Enter your Python code and click 'Execute Code' to run it."
|
| 24 |
-
)
|
| 25 |
|
| 26 |
-
iface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
except Exception as e:
|
| 9 |
return f"Error: {str(e)}"
|
| 10 |
|
| 11 |
+
def execute_code_callback(code, temp, max):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
return execute_code(code)
|
| 13 |
print("hello")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
iface.launch(share=True)
|
| 16 |
+
def gradio_app():
|
| 17 |
+
with gr.Blocks() as demo:
|
| 18 |
+
gr.Markdown(title)
|
| 19 |
+
prompt = gr.Code(label="Enter your code prompt", value="def print_hello_world():")
|
| 20 |
+
with gr.Row():
|
| 21 |
+
temperature = gr.Slider(minimum=0.1, maximum=1.0, step=0.1, value=0.5, label="Temperature")
|
| 22 |
+
max_length = gr.Slider(minimum=100, maximum=1024, step=10, value=450, label="Generate Length")
|
| 23 |
+
generate_btn = gr.Button("Try✨Coding")
|
| 24 |
+
output = gr.Code(label="✨Output:", lines=40)
|
| 25 |
+
|
| 26 |
+
generate_btn.click(
|
| 27 |
+
fn=execute_code_callback,
|
| 28 |
+
inputs=[prompt, temperature, max_length],
|
| 29 |
+
outputs=output
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
demo.launch()
|
| 33 |
+
|
| 34 |
+
if __name__ == "__main__":
|
| 35 |
+
gradio_app()
|