donb-hf commited on
Commit
6de6c8c
ยท
1 Parent(s): 86e68be
Files changed (2) hide show
  1. app.py +55 -21
  2. requirements.txt +2 -1
app.py CHANGED
@@ -5,6 +5,7 @@ import requests
5
  import warnings
6
  import logging
7
  import os
 
8
  import pandas as pd
9
  from dotenv import load_dotenv
10
 
@@ -261,29 +262,62 @@ def submit_message(message, history):
261
  print(df) # For console output
262
  return history, "", df
263
 
264
- with gr.Blocks() as demo:
265
- gr.Markdown("# BlackBird Customer Support Chat")
266
- chatbot = gr.Chatbot()
267
- msg = gr.Textbox(label="Your message")
268
- clear = gr.Button("Clear")
269
- df_output = gr.Dataframe(label="Conversation Analysis")
270
 
271
- submit_event = msg.submit(submit_message, [msg, chatbot], [chatbot, msg, df_output]).then(
272
- lambda: "", None, msg
273
- )
 
274
 
275
- example_inputs = [
276
- "What's the status of my orders? My Customer id is 2837622",
277
- "Can you confirm my customer info and order status? My email is [email protected]",
278
- "I'd like to cancel an order",
279
- "Can you update my email address to [email protected]?",
280
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
- examples = gr.Examples(
283
- examples=example_inputs,
284
- inputs=msg
285
- )
286
 
287
- clear.click(lambda: None, None, chatbot, queue=False)
288
 
289
- demo.launch()
 
 
5
  import warnings
6
  import logging
7
  import os
8
+ from datasets import load_dataset
9
  import pandas as pd
10
  from dotenv import load_dotenv
11
 
 
262
  print(df) # For console output
263
  return history, "", df
264
 
265
+ def load_customers_dataset():
266
+ dataset = load_dataset("dwb2023/blackbird-customers", split="train")
267
+ df = pd.DataFrame(dataset)
268
+ return df
 
 
269
 
270
+ def load_orders_dataset():
271
+ dataset = load_dataset("dwb2023/blackbird-orders", split="train")
272
+ df = pd.DataFrame(dataset)
273
+ return df
274
 
275
+ example_inputs = [
276
+ "What's the status of my orders? My Customer id is 2837622",
277
+ "Can you confirm my customer info and order status? My email is [email protected]",
278
+ "I'd like to cancel an order",
279
+ "Can you update my email address to [email protected]?",
280
+ ]
281
+
282
+ # Create Gradio App
283
+ app = gr.Blocks(theme="sudeepshouche/minimalist")
284
+
285
+ with app:
286
+ with gr.Tab("Chatbot"):
287
+ gr.Markdown("# BlackBird Customer Support Chat")
288
+ with gr.Row():
289
+ with gr.Column():
290
+ msg = gr.Textbox(label="Your message")
291
+ submit = gr.Button("Submit", variant="primary")
292
+ clear = gr.Button("Clear", variant="secondary")
293
+ examples = gr.Examples(
294
+ examples=example_inputs,
295
+ inputs=msg
296
+ )
297
+ with gr.Column():
298
+ chatbot = gr.Chatbot()
299
+
300
+ df_output = gr.Dataframe(label="Conversation Analysis")
301
+
302
+ def handle_submit(message, history):
303
+ return submit_message(message, history)
304
+
305
+ submit_event = msg.submit(handle_submit, [msg, chatbot], [chatbot, msg, df_output]).then(
306
+ lambda: "", None, msg
307
+ )
308
+
309
+ submit.click(submit_message, [msg, chatbot], [chatbot, msg, df_output], show_progress="full").then(
310
+ lambda: "", None, msg
311
+ )
312
+
313
+ clear.click(lambda: None, None, chatbot, queue=False)
314
+
315
+ with gr.Tab("Customers"):
316
+ customers_df = gr.Dataframe(load_customers_dataset(), label="Customers Data")
317
 
318
+ with gr.Tab("Orders"):
319
+ orders_df = gr.Dataframe(load_orders_dataset(), label="Orders Data")
 
 
320
 
 
321
 
322
+ if __name__ == "__main__":
323
+ app.launch()
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  anthropic
2
  gradio
3
- requests
 
 
1
  anthropic
2
  gradio
3
+ requests
4
+ datasets