Karthikeyan commited on
Commit
06c32b9
β€’
1 Parent(s): 7b9ee38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -81,7 +81,7 @@ class Summarizer:
81
  message = completions.choices[0].text.strip()
82
  return message
83
 
84
- history_state = gr.State()
85
  summarizer = Summarizer()
86
  sentiment = SentimentAnalyzer()
87
 
@@ -202,7 +202,8 @@ class LangChain_Document_QA:
202
 
203
  return scores,customer_fig,agent_fig,customer_emotion_fig,agent_emotion_fig
204
 
205
-
 
206
 
207
  def gradio_interface(self):
208
  with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
@@ -234,6 +235,10 @@ class LangChain_Document_QA:
234
  button=gr.Button(
235
  value="πŸš€"
236
  )
 
 
 
 
237
  with gr.Row():
238
  with gr.Column(scale=0.40):
239
  txt4 =gr.Textbox(
@@ -280,7 +285,8 @@ class LangChain_Document_QA:
280
  self._agent_text, [chatbot, txt2], chatbot
281
  )
282
  end_btn.click(self._display_history, [], txt4)
283
-
 
284
  Sentiment_btn.click(self._on_sentiment_btn_click,[],[txt5,plot,plot_2,plot_3,plot_4])
285
 
286
  demo.title = "Vodafone Generative AI CRM ChatBot"
 
81
  message = completions.choices[0].text.strip()
82
  return message
83
 
84
+ history_state = gr.State([])
85
  summarizer = Summarizer()
86
  sentiment = SentimentAnalyzer()
87
 
 
202
 
203
  return scores,customer_fig,agent_fig,customer_emotion_fig,agent_emotion_fig
204
 
205
+ def clear_func(self,history_state):
206
+ history_state.clear()
207
 
208
  def gradio_interface(self):
209
  with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
 
235
  button=gr.Button(
236
  value="πŸš€"
237
  )
238
+ with gr.Column(scale=0.10, min_width=0):
239
+ clear_btn=gr.Button(
240
+ value="Clear"
241
+ )
242
  with gr.Row():
243
  with gr.Column(scale=0.40):
244
  txt4 =gr.Textbox(
 
285
  self._agent_text, [chatbot, txt2], chatbot
286
  )
287
  end_btn.click(self._display_history, [], txt4)
288
+ clear_btn.click(self.clear_func, [history_state],[])
289
+ clear_btn.click(lambda: None, None, chatbot, queue=False)
290
  Sentiment_btn.click(self._on_sentiment_btn_click,[],[txt5,plot,plot_2,plot_3,plot_4])
291
 
292
  demo.title = "Vodafone Generative AI CRM ChatBot"