minato56 commited on
Commit
7be107d
·
verified ·
1 Parent(s): 7446d2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,5 +1,5 @@
1
  # app.py
2
- # Pixel AI — Friendly Coding Teacher with 3 Methods & Developer Mode + Button
3
 
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
@@ -134,13 +134,18 @@ with gr.Blocks(title="Pixel AI — Friendly Coding Teacher") as demo:
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()
 
1
  # app.py
2
+ # Pixel AI — Friendly Coding Teacher with 3 Methods & Developer Mode + Safe Button
3
 
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
 
134
  gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
135
  ],
136
  )
137
+
138
+ # Button to activate Developer Mode
139
  dev_button = gr.Button("Activate Developer Mode")
140
+ hidden_input = gr.Textbox(value="", visible=False)
141
 
142
+ # عند الضغط على الزر، نرسل "__activate_dev_mode__" إلى Textbox المخفي
143
  def activate_dev():
144
  return "__activate_dev_mode__"
145
 
146
+ dev_button.click(fn=activate_dev, inputs=[], outputs=hidden_input)
147
+ # إرسال Textbox المخفي إلى ChatInterface عبر submit
148
+ hidden_input.submit(fn=lambda x: x, inputs=[hidden_input], outputs=[chatbot])
149
 
150
  if __name__ == "__main__":
151
  demo.launch()