coder_debugger / app.py
K00B404's picture
Update app.py
69a1506 verified
raw
history blame
1.21 kB
import gradio as gr
# Define the main chat response function.
def chat_response(user_input):
# Your chat response logic here.
return "Hello, I am a chatbot. How can I help you?"
# Create the Gradio interface.
iface = gr.Interface(
fn=chat_response,
inputs=gr.Textbox(label="User Input"),
outputs=gr.Textbox(label="Chatbot Response"),
)
# Add the code editor and debug screen.
code_editor = gr.Code(label="Code Editor")
debug_screen = gr.Textbox(label="Debug Screen")
# Define the function to execute the Python code.
def execute_code(code):
try:
# Execute the code and capture the output.
output = eval(code)
debug_screen.update(f"Code executed successfully.\nOutput: {output}")
except Exception as e:
debug_screen.update(f"Error executing code: {e}")
# Create the Gradio interface for the code execution.
code_execution_iface = gr.Interface(
fn=execute_code,
inputs=code_editor,
outputs=debug_screen,
)
# Add the screens to the main interface.
iface.cache_examples(
[
("What is the capital of France?", "Paris"),
("What is the square root of 16?", 4),
]
)
# Launch the Gradio interface.
iface.launch()