Karthikeyan commited on
Commit
8d34d34
β€’
1 Parent(s): 8557430

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -50
app.py CHANGED
@@ -1,6 +1,14 @@
1
  from pydantic import NoneStr
2
  import os
 
 
 
 
 
 
 
3
  import mimetypes
 
4
  import requests
5
  import tempfile
6
  import gradio as gr
@@ -207,92 +215,92 @@ class LangChain_Document_QA:
207
 
208
 
209
  def gradio_interface(self):
210
- with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
211
- with gr.Row():
212
- gr.HTML("""<img class="leftimage" align="left" src="https://templates.images.credential.net/1612472097627370951721412474196.png" alt="Image" width="210" height="210">
213
  <img align="right" class="rightimage" src="https://download.logo.wine/logo/Vodafone/Vodafone-Logo.wine.png" alt="Image" width="230" height="230" >""")
214
-
215
- with gr.Row():
216
- gr.HTML("""<center><h1>Vodafone Generative AI CRM ChatBot</h1></center>""")
217
- gr.HTML(
218
- """<br style="color:white;">"""
219
- )
220
- chatbot = gr.Chatbot([], elem_id="chatbot").style(height=300)
221
- with gr.Row():
222
- with gr.Column(scale=0.50):
223
  txt = gr.Textbox(
224
  show_label=False,
225
  placeholder="Customer",
226
  ).style(container=False)
227
- with gr.Column(scale=0.50):
228
  txt2 = gr.Textbox(
229
  show_label=False,
230
  placeholder="Agent",
231
  ).style(container=False)
232
-
233
- with gr.Column(scale=0.40):
234
  txt3 =gr.Textbox(
235
  show_label=False,
236
  placeholder="GPT_Suggestion",
237
  ).style(container=False)
238
- with gr.Column(scale=0.10, min_width=0):
239
  button=gr.Button(
240
  value="πŸš€"
241
  )
242
- with gr.Row(scale=0.50):
243
  emptyBtn = gr.Button(
244
  "🧹 New Conversation",
245
  )
246
- with gr.Row():
247
- with gr.Column(scale=0.40):
248
  txt4 =gr.Textbox(
249
  show_label=False,
250
  lines=4,
251
  placeholder="Summary",
252
  ).style(container=False)
253
- with gr.Column(scale=0.10, min_width=0):
254
  end_btn=gr.Button(
255
  value="End"
256
  )
257
- with gr.Column(scale=0.40):
258
  txt5 =gr.Textbox(
259
  show_label=False,
260
  lines=4,
261
  placeholder="Sentiment",
262
  ).style(container=False)
263
-
264
- with gr.Column(scale=0.10, min_width=0):
265
  Sentiment_btn=gr.Button(
266
  value="πŸ“Š",callback=self._on_sentiment_btn_click
267
  )
268
- with gr.Row():
269
- gr.HTML("""<center><h1>Sentiment and Emotion Score Graph</h1></center>""")
270
- with gr.Row():
271
- with gr.Column(scale=0.70, min_width=0):
272
- plot =gr.Plot(label="Customer", size=(500, 600))
273
- with gr.Row():
274
- with gr.Column(scale=0.70, min_width=0):
275
- plot_2 =gr.Plot(label="Agent", size=(500, 600))
276
- with gr.Row():
277
- with gr.Column(scale=0.70, min_width=0):
278
- plot_3 =gr.Plot(label="Customer_Emotion", size=(500, 600))
279
- with gr.Row():
280
- with gr.Column(scale=0.70, min_width=0):
281
- plot_4 =gr.Plot(label="Agent_Emotion", size=(500, 600))
282
-
283
-
284
- txt_msg = txt.submit(self._add_text, [chatbot, txt], [chatbot, txt])
285
- txt_msg.then(lambda: gr.update(interactive=True), None, [txt])
286
- txt.submit(self._suggested_answer,txt,txt3)
287
- button.click(self._agent_text, [chatbot,txt3], chatbot)
288
- txt2.submit(self._agent_text, [chatbot, txt2], chatbot).then(
289
  self._agent_text, [chatbot, txt2], chatbot
290
- )
291
- end_btn.click(self._display_history, [], txt4)
292
- emptyBtn.click(self.clear_func,history_state,[])
293
- emptyBtn.click(lambda: None, None, chatbot, queue=False)
294
-
295
- Sentiment_btn.click(self._on_sentiment_btn_click,[],[txt5,plot,plot_2,plot_3,plot_4])
296
 
297
  demo.title = "Vodafone Generative AI CRM ChatBot"
298
  demo.launch()
 
1
  from pydantic import NoneStr
2
  import os
3
+ from langchain.chains.question_answering import load_qa_chain
4
+ from langchain.document_loaders import UnstructuredFileLoader
5
+ from langchain.embeddings.openai import OpenAIEmbeddings
6
+ from langchain.llms import OpenAI
7
+ from langchain.text_splitter import CharacterTextSplitter
8
+ from langchain.vectorstores import FAISS
9
+ from pypdf import PdfReader
10
  import mimetypes
11
+ import validators
12
  import requests
13
  import tempfile
14
  import gradio as gr
 
215
 
216
 
217
  def gradio_interface(self):
218
+ with gr.Blocks(css="style.css",theme=gr.themes.Soft()) as demo:
219
+ with gr.Row():
220
+ gr.HTML("""<img class="leftimage" align="left" src="https://templates.images.credential.net/1612472097627370951721412474196.png" alt="Image" width="210" height="210">
221
  <img align="right" class="rightimage" src="https://download.logo.wine/logo/Vodafone/Vodafone-Logo.wine.png" alt="Image" width="230" height="230" >""")
222
+
223
+ with gr.Row():
224
+ gr.HTML("""<center><h1>Vodafone Generative AI CRM ChatBot</h1></center>""")
225
+ gr.HTML(
226
+ """<br style="color:white;">"""
227
+ )
228
+ chatbot = gr.Chatbot([], elem_id="chatbot").style(height=300)
229
+ with gr.Row():
230
+ with gr.Column(scale=0.50):
231
  txt = gr.Textbox(
232
  show_label=False,
233
  placeholder="Customer",
234
  ).style(container=False)
235
+ with gr.Column(scale=0.50):
236
  txt2 = gr.Textbox(
237
  show_label=False,
238
  placeholder="Agent",
239
  ).style(container=False)
240
+
241
+ with gr.Column(scale=0.40):
242
  txt3 =gr.Textbox(
243
  show_label=False,
244
  placeholder="GPT_Suggestion",
245
  ).style(container=False)
246
+ with gr.Column(scale=0.10, min_width=0):
247
  button=gr.Button(
248
  value="πŸš€"
249
  )
250
+ with gr.Row(scale=0.50):
251
  emptyBtn = gr.Button(
252
  "🧹 New Conversation",
253
  )
254
+ with gr.Row():
255
+ with gr.Column(scale=0.40):
256
  txt4 =gr.Textbox(
257
  show_label=False,
258
  lines=4,
259
  placeholder="Summary",
260
  ).style(container=False)
261
+ with gr.Column(scale=0.10, min_width=0):
262
  end_btn=gr.Button(
263
  value="End"
264
  )
265
+ with gr.Column(scale=0.40):
266
  txt5 =gr.Textbox(
267
  show_label=False,
268
  lines=4,
269
  placeholder="Sentiment",
270
  ).style(container=False)
271
+
272
+ with gr.Column(scale=0.10, min_width=0):
273
  Sentiment_btn=gr.Button(
274
  value="πŸ“Š",callback=self._on_sentiment_btn_click
275
  )
276
+ with gr.Row():
277
+ gr.HTML("""<center><h1>Sentiment and Emotion Score Graph</h1></center>""")
278
+ with gr.Row():
279
+ with gr.Column(scale=0.70, min_width=0):
280
+ plot =gr.Plot(label="Customer", size=(500, 600))
281
+ with gr.Row():
282
+ with gr.Column(scale=0.70, min_width=0):
283
+ plot_2 =gr.Plot(label="Agent", size=(500, 600))
284
+ with gr.Row():
285
+ with gr.Column(scale=0.70, min_width=0):
286
+ plot_3 =gr.Plot(label="Customer_Emotion", size=(500, 600))
287
+ with gr.Row():
288
+ with gr.Column(scale=0.70, min_width=0):
289
+ plot_4 =gr.Plot(label="Agent_Emotion", size=(500, 600))
290
+
291
+
292
+ txt_msg = txt.submit(self._add_text, [chatbot, txt], [chatbot, txt])
293
+ txt_msg.then(lambda: gr.update(interactive=True), None, [txt])
294
+ txt.submit(self._suggested_answer,txt,txt3)
295
+ button.click(self._agent_text, [chatbot,txt3], chatbot)
296
+ txt2.submit(self._agent_text, [chatbot, txt2], chatbot).then(
297
  self._agent_text, [chatbot, txt2], chatbot
298
+ )
299
+ end_btn.click(self._display_history, [], txt4)
300
+ emptyBtn.click(self.clear_func,history_state,[])
301
+ emptyBtn.click(lambda: None, None, chatbot, queue=False)
302
+
303
+ Sentiment_btn.click(self._on_sentiment_btn_click,[],[txt5,plot,plot_2,plot_3,plot_4])
304
 
305
  demo.title = "Vodafone Generative AI CRM ChatBot"
306
  demo.launch()