ElouarnLC commited on
Commit
fe44686
·
1 Parent(s): e32eb03

clear history

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -91,29 +91,26 @@ mychatbot = gr.Chatbot(
91
  )
92
 
93
 
94
- def reset_history():
95
- global global_iteration
96
- global_iteration = 0
97
- return []
98
 
99
 
100
- clear_button = gr.ClearButton(
101
- value="Effacer l'historique", func=reset_history, inputs=[], outputs=["chatbot"]
102
- )
103
 
104
 
105
- # Créer une interface pour le chatbot avec un champ de texte pour le contexte caché
106
  chatbot_interface = gr.ChatInterface(
107
  fn=generate,
108
  chatbot=mychatbot,
109
  title="Tavernier 🍺",
110
  retry_btn=None,
111
  undo_btn=None,
112
- clear_button=gr.ClearButton(
113
- value="Effacer l'historique", func=reset_history, inputs=[], outputs=["chatbot"]
114
- ),
115
  )
116
 
 
 
 
117
 
118
  # Ajouter le champ de texte pour le contexte caché à l'interface
119
  context_interface = gr.Interface(
 
91
  )
92
 
93
 
94
+ # Créer une interface pour le chatbot avec un champ de texte pour le contexte caché
 
 
 
95
 
96
 
97
+ def reset_history(chatbot):
98
+ chatbot.history = []
99
+ return []
100
 
101
 
 
102
  chatbot_interface = gr.ChatInterface(
103
  fn=generate,
104
  chatbot=mychatbot,
105
  title="Tavernier 🍺",
106
  retry_btn=None,
107
  undo_btn=None,
108
+ clear_button=gr.ClearButton(value="Effacer l'historique"),
 
 
109
  )
110
 
111
+ clear_button = chatbot_interface.clear_button
112
+ clear_button.click(reset_history, inputs=[mychatbot], outputs=[mychatbot])
113
+
114
 
115
  # Ajouter le champ de texte pour le contexte caché à l'interface
116
  context_interface = gr.Interface(