minato56 commited on
Commit
7446d2a
·
verified ·
1 Parent(s): 5e4262b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -124,26 +124,23 @@ You are Pixel, a happy, lively, and funny AI assistant.
124
 
125
  # ---------------- Gradio UI ----------------
126
  with gr.Blocks(title="Pixel AI — Friendly Coding Teacher") as demo:
127
- with gr.Row():
128
- chatbot = gr.ChatInterface(
129
- respond,
130
- type="messages",
131
- additional_inputs=[
132
- gr.Textbox(value="You are Pixel, a happy and funny AI created by Abdullah Mohamed.", label="System message"),
133
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
134
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
135
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
136
- ],
137
- )
138
- with gr.Row():
139
- dev_button = gr.Button("Activate Developer Mode")
140
- hidden_input = gr.Textbox(value="", visible=False)
141
-
142
  def activate_dev():
143
  return "__activate_dev_mode__"
144
 
145
- dev_button.click(fn=activate_dev, inputs=[], outputs=hidden_input)
146
- hidden_input.change(fn=respond, inputs=[hidden_input, chatbot.state, "", 512, 0.7, 0.95, gr.OAuthToken()], outputs=[chatbot, chatbot])
147
 
148
  if __name__ == "__main__":
149
  demo.launch()
 
124
 
125
  # ---------------- Gradio UI ----------------
126
  with gr.Blocks(title="Pixel AI — Friendly Coding Teacher") as demo:
127
+ chatbot = gr.ChatInterface(
128
+ respond,
129
+ type="messages",
130
+ additional_inputs=[
131
+ gr.Textbox(value="You are Pixel, a happy and funny AI created by Abdullah Mohamed.", label="System message"),
132
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
133
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
134
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
135
+ ],
136
+ )
137
+ dev_button = gr.Button("Activate Developer Mode")
138
+
139
+ # عند الضغط على الزر، نرسل رسالة "__activate_dev_mode__" مباشرة للـ ChatInterface
 
 
140
  def activate_dev():
141
  return "__activate_dev_mode__"
142
 
143
+ dev_button.click(fn=activate_dev, inputs=[], outputs=chatbot.input_text)
 
144
 
145
  if __name__ == "__main__":
146
  demo.launch()