Chad commited on
Commit
46c60b8
·
1 Parent(s): 04accba

profound mode2

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -62,9 +62,12 @@ def generate_reply(user_input, chat_history, profound_state):
62
  chat_history.append({"role": "assistant", "content": reply})
63
  return chat_history, chat_history, ""
64
 
65
- def toggle_profound_mode(current_state):
66
  new_state = not current_state
67
- button_label = "Disable Profound Mode" if new_state else "Enable Profound Mode"
 
 
 
68
  return new_state, button_label
69
 
70
  def generate_quiz(subject, num_questions, chat_history, language_state):
@@ -113,7 +116,9 @@ def toggle_language(language):
113
  "Sujet du quiz",
114
  "Nombre de questions",
115
  "Démarrer le quiz",
116
- "Guide utilisateur"
 
 
117
  )
118
  else:
119
  return (
@@ -126,7 +131,9 @@ def toggle_language(language):
126
  "Quiz Subject",
127
  "Number of Questions",
128
  "Start Quiz",
129
- "User Guide"
 
 
130
  )
131
 
132
  def user_guide(chat_history, language_state):
@@ -174,8 +181,9 @@ with gr.Blocks() as interface:
174
  state = gr.State([])
175
 
176
 
177
- def update_ui(language):
178
- new_language, new_title, new_button_text, new_placeholder, new_send_label, new_reset_label, quiz_sub, quiz_len, quiz_but, help_but = toggle_language(language)
 
179
  return (
180
  new_language, new_title, new_button_text,
181
  gr.update(placeholder=new_placeholder, value=""),
@@ -183,19 +191,20 @@ with gr.Blocks() as interface:
183
  gr.update(label=quiz_sub),
184
  gr.update(label=quiz_len),
185
  gr.update(value=quiz_but),
186
- gr.update(value=help_but)
 
187
  )
188
 
189
  lang_button.click(
190
  fn=update_ui,
191
  inputs=[language_state],
192
- outputs=[language_state, title, lang_button, user_input, send_button, reset_button, quiz_subject, quiz_num_questions, quiz_button, help_button]
193
  )
194
 
195
  profound_button.click(
196
- fn=toggle_profound_mode,
197
- inputs=[profound_state],
198
- outputs=[profound_state, profound_button]
199
  )
200
 
201
  send_button.click(
 
62
  chat_history.append({"role": "assistant", "content": reply})
63
  return chat_history, chat_history, ""
64
 
65
+ def toggle_profound_mode(current_state, language_state):
66
  new_state = not current_state
67
+ if language_state == "english":
68
+ button_label = "Disable Profound Mode" if new_state else "Enable Profound Mode"
69
+ else:
70
+ button_label = "Désactiver le mode approfondi" if new_state else "Activer le mode approfondi"
71
  return new_state, button_label
72
 
73
  def generate_quiz(subject, num_questions, chat_history, language_state):
 
116
  "Sujet du quiz",
117
  "Nombre de questions",
118
  "Démarrer le quiz",
119
+ "Guide utilisateur",
120
+ "Activer le mode approfondi",
121
+ "Désactiver le mode approfondi"
122
  )
123
  else:
124
  return (
 
131
  "Quiz Subject",
132
  "Number of Questions",
133
  "Start Quiz",
134
+ "User Guide",
135
+ "Enable Profound Mode",
136
+ "Disable Profound Mode"
137
  )
138
 
139
  def user_guide(chat_history, language_state):
 
181
  state = gr.State([])
182
 
183
 
184
+ def update_ui(language, profound_state):
185
+ new_language, new_title, new_button_text, new_placeholder, new_send_label, new_reset_label, quiz_sub, quiz_len, quiz_but, help_but, profound_on, profound_off = toggle_language(language)
186
+ profound_label = profound_off if profound_state else profound_on
187
  return (
188
  new_language, new_title, new_button_text,
189
  gr.update(placeholder=new_placeholder, value=""),
 
191
  gr.update(label=quiz_sub),
192
  gr.update(label=quiz_len),
193
  gr.update(value=quiz_but),
194
+ gr.update(value=help_but),
195
+ gr.update(value=profound_label)
196
  )
197
 
198
  lang_button.click(
199
  fn=update_ui,
200
  inputs=[language_state],
201
+ outputs=[language_state, title, lang_button, user_input, send_button, reset_button, quiz_subject, quiz_num_questions, quiz_button, help_button, profound_button]
202
  )
203
 
204
  profound_button.click(
205
+ fn=toggle_profound_mode,
206
+ inputs=[profound_state, language_state],
207
+ outputs=[profound_state, profound_button]
208
  )
209
 
210
  send_button.click(