ai-canvas / app.py
parrotmaker's picture
Create app.py
114d818 verified
raw
history blame
1.14 kB
import gradio as gr
# Simple AI function β€” replace with a model later
def ai_assistant(message):
return f"πŸ€– AI says: You wrote '{message}'"
# Canvas handler (currently dummy)
def save_drawing(image):
return "βœ… Drawing received!"
with gr.Blocks() as demo:
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("## πŸ’¬ AI Assistant")
chatbot = gr.Chatbot()
user_msg = gr.Textbox(placeholder="Type a message...", label="Your Message")
send_btn = gr.Button("Send")
def handle_chat(msg, chat_history):
reply = ai_assistant(msg)
chat_history.append((msg, reply))
return "", chat_history
send_btn.click(handle_chat, [user_msg, chatbot], [user_msg, chatbot])
with gr.Column(scale=2):
gr.Markdown("## 🎨 Canvas Area")
canvas = gr.Sketchpad(label="Draw something!", brush_radius=10)
save_btn = gr.Button("Save Drawing")
result = gr.Textbox(visible=False)
save_btn.click(save_drawing, inputs=canvas, outputs=result)
demo.launch()