import gradio as gr # Placeholder assistant function def assistant_response(message): return f"🧠 Assistant: You said '{message}'" # (Optional) Run code def run_code(code): try: exec_globals = {} exec(code, exec_globals) return "✅ Code executed successfully (no visible output)" except Exception as e: return f"❌ Error:\n{e}" with gr.Blocks() as demo: with gr.Row(): # LEFT COLUMN - AI CHAT with gr.Column(scale=1): gr.Markdown("### 🤖 AI Assistant") chat = gr.Chatbot() msg = gr.Textbox(placeholder="Ask for help...", label="Your Message") send = gr.Button("Send") def handle_chat(user_message, history): reply = assistant_response(user_message) history.append((user_message, reply)) return "", history send.click(handle_chat, [msg, chat], [msg, chat]) # RIGHT COLUMN - CODE EDITOR with gr.Column(scale=2): gr.Markdown("### 💻 Code Canvas") editor = gr.Code(label="Your Code Here", language="python") run_btn = gr.Button("Run Code") output = gr.Textbox(label="Output") run_btn.click(run_code, inputs=editor, outputs=output) demo.launch()