Dmang69 commited on
Commit
6556df6
·
verified ·
1 Parent(s): e1a951c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -65,7 +65,11 @@ with gr.Blocks(title="SynapseAI Programming Assistant") as app:
65
  code_input = gr.Textbox(label="Paste code", lines=10)
66
  explain_btn = gr.Button("Explain Code")
67
  explanation_output = gr.Textbox(label="Explanation", lines=10)
68
- explain_btn.click(explain_code, code_input, explanation_output)
 
 
 
 
69
 
70
  # Fix Code
71
  with gr.Tab("Fix Code"):
@@ -79,9 +83,19 @@ with gr.Blocks(title="SynapseAI Programming Assistant") as app:
79
  with gr.Tab("Chat"):
80
  chatbot = gr.Chatbot()
81
  chat_input = gr.Textbox(label="Ask something...")
 
 
 
 
 
 
 
 
 
 
 
82
  clear_btn = gr.Button("Clear Chat")
83
- chat_input.submit(chat_with_ai, [chat_input, chatbot], [chatbot, chat_input])
84
- clear_btn.click(lambda: None, None, chatbot, queue=False)
85
 
86
 
87
  if __name__ == "__main__":
 
65
  code_input = gr.Textbox(label="Paste code", lines=10)
66
  explain_btn = gr.Button("Explain Code")
67
  explanation_output = gr.Textbox(label="Explanation", lines=10)
68
+ +
69
+
70
+
71
+
72
+ explain_btn.click(explain_code, code_input, explanation_output)
73
 
74
  # Fix Code
75
  with gr.Tab("Fix Code"):
 
83
  with gr.Tab("Chat"):
84
  chatbot = gr.Chatbot()
85
  chat_input = gr.Textbox(label="Ask something...")
86
+
87
+ def chat_with_ai(message, history):
88
+ history = history or []
89
+ if not message.strip():
90
+ return history + [["", "Please say something!"]]
91
+ reply = "💬 You said: " + message
92
+ history.append([message, reply])
93
+ return history
94
+
95
+ chat_input.submit(chat_with_ai, [chat_input, chatbot], chatbot)
96
+
97
  clear_btn = gr.Button("Clear Chat")
98
+ clear_btn.click(lambda: [], None, chatbot)
 
99
 
100
 
101
  if __name__ == "__main__":