Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,41 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
def
|
5 |
-
return f"
|
6 |
-
|
7 |
-
#
|
8 |
-
def
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
with gr.Blocks() as demo:
|
12 |
with gr.Row():
|
|
|
13 |
with gr.Column(scale=1):
|
14 |
-
gr.Markdown("
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
def handle_chat(
|
20 |
-
reply =
|
21 |
-
|
22 |
-
return "",
|
23 |
|
24 |
-
|
25 |
|
|
|
26 |
with gr.Column(scale=2):
|
27 |
-
gr.Markdown("
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
|
34 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Placeholder assistant function
|
4 |
+
def assistant_response(message):
|
5 |
+
return f"π§ Assistant: You said '{message}'"
|
6 |
+
|
7 |
+
# (Optional) Run code
|
8 |
+
def run_code(code):
|
9 |
+
try:
|
10 |
+
exec_globals = {}
|
11 |
+
exec(code, exec_globals)
|
12 |
+
return "β
Code executed successfully (no visible output)"
|
13 |
+
except Exception as e:
|
14 |
+
return f"β Error:\n{e}"
|
15 |
|
16 |
with gr.Blocks() as demo:
|
17 |
with gr.Row():
|
18 |
+
# LEFT COLUMN - AI CHAT
|
19 |
with gr.Column(scale=1):
|
20 |
+
gr.Markdown("### π€ AI Assistant")
|
21 |
+
chat = gr.Chatbot()
|
22 |
+
msg = gr.Textbox(placeholder="Ask for help...", label="Your Message")
|
23 |
+
send = gr.Button("Send")
|
24 |
|
25 |
+
def handle_chat(user_message, history):
|
26 |
+
reply = assistant_response(user_message)
|
27 |
+
history.append((user_message, reply))
|
28 |
+
return "", history
|
29 |
|
30 |
+
send.click(handle_chat, [msg, chat], [msg, chat])
|
31 |
|
32 |
+
# RIGHT COLUMN - CODE EDITOR
|
33 |
with gr.Column(scale=2):
|
34 |
+
gr.Markdown("### π» Code Canvas")
|
35 |
+
editor = gr.Code(label="Your Code Here", language="python")
|
36 |
+
run_btn = gr.Button("Run Code")
|
37 |
+
output = gr.Textbox(label="Output")
|
38 |
|
39 |
+
run_btn.click(run_code, inputs=editor, outputs=output)
|
40 |
|
41 |
demo.launch()
|