Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Simple AI function — replace with a model later
|
4 |
+
def ai_assistant(message):
|
5 |
+
return f"🤖 AI says: You wrote '{message}'"
|
6 |
+
|
7 |
+
# Canvas handler (currently dummy)
|
8 |
+
def save_drawing(image):
|
9 |
+
return "✅ Drawing received!"
|
10 |
+
|
11 |
+
with gr.Blocks() as demo:
|
12 |
+
with gr.Row():
|
13 |
+
with gr.Column(scale=1):
|
14 |
+
gr.Markdown("## 💬 AI Assistant")
|
15 |
+
chatbot = gr.Chatbot()
|
16 |
+
user_msg = gr.Textbox(placeholder="Type a message...", label="Your Message")
|
17 |
+
send_btn = gr.Button("Send")
|
18 |
+
|
19 |
+
def handle_chat(msg, chat_history):
|
20 |
+
reply = ai_assistant(msg)
|
21 |
+
chat_history.append((msg, reply))
|
22 |
+
return "", chat_history
|
23 |
+
|
24 |
+
send_btn.click(handle_chat, [user_msg, chatbot], [user_msg, chatbot])
|
25 |
+
|
26 |
+
with gr.Column(scale=2):
|
27 |
+
gr.Markdown("## 🎨 Canvas Area")
|
28 |
+
canvas = gr.Sketchpad(label="Draw something!", brush_radius=10)
|
29 |
+
save_btn = gr.Button("Save Drawing")
|
30 |
+
result = gr.Textbox(visible=False)
|
31 |
+
|
32 |
+
save_btn.click(save_drawing, inputs=canvas, outputs=result)
|
33 |
+
|
34 |
+
demo.launch()
|