Spaces:
Sleeping
Sleeping
File size: 1,142 Bytes
114d818 |
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 32 33 34 |
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() |