jed-tiotuico commited on
Commit
01c683d
1 Parent(s): d47ab3c

fixed form

Browse files
Files changed (1) hide show
  1. app.py +60 -14
app.py CHANGED
@@ -60,6 +60,9 @@ def write_stream_user_chat_message(user_chat, model, token, prompt):
60
  return new_customer_msg
61
 
62
  def get_mistral_model_tokenizer(sota_model_name):
 
 
 
63
  model, tokenizer = FastLanguageModel.from_pretrained(
64
  model_name = "unsloth/mistral-7b-instruct-v0.2-bnb-4bit",
65
  max_seq_length = max_seq_length,
@@ -259,15 +262,6 @@ if user_chat:
259
  else:
260
  st.error("Please enter a customer message, or generate one for the ai to respond")
261
 
262
- # main ui prompt
263
- # - text box
264
- # - submit
265
- with st.form(key="my_form"):
266
- prompt = st.text_area("Customer Message")
267
- write_user_chat_message(user_chat, prompt)
268
- if st.form_submit_button("Submit"):
269
- assistant_chat.write("Hi, Human.")
270
-
271
  # below ui prompt
272
  # - examples
273
  # st.markdown("<b>Example:</b>", unsafe_allow_html=True)
@@ -289,10 +283,6 @@ if st.button("your website is straight up garbage. how do you sell high end tech
289
 
290
  # - Generate Customer Tweet
291
  if st.button("Generate Customer Message using Few Shots"):
292
- max_seq_length = 2048
293
- dtype = torch.float16
294
- load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
295
-
296
  model, tokenizer = get_mistral_model_tokenizer(sota_model_name)
297
 
298
  noun_picker = DeckPicker(nouns)
@@ -318,7 +308,28 @@ st.markdown("""Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois,
318
  Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto
319
  - [Alpaca: A Strong, Replicable Instruction-Following Model](https://crfm.stanford.edu/2023/03/13/alpaca.html)""")
320
 
321
- if device == "cuda":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  gpu_stats = torch.cuda.get_device_properties(0)
323
  max_memory = gpu_stats.total_memory / 1024 ** 3
324
  start_gpu_memory = torch.cuda.memory_reserved(0) / 1024 ** 3
@@ -327,3 +338,38 @@ if device == "cuda":
327
 
328
  st.write("Packages:")
329
  st.write(f"pytorch: {torch.__version__}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  return new_customer_msg
61
 
62
  def get_mistral_model_tokenizer(sota_model_name):
63
+ max_seq_length = 2048
64
+ dtype = torch.float16
65
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
66
  model, tokenizer = FastLanguageModel.from_pretrained(
67
  model_name = "unsloth/mistral-7b-instruct-v0.2-bnb-4bit",
68
  max_seq_length = max_seq_length,
 
262
  else:
263
  st.error("Please enter a customer message, or generate one for the ai to respond")
264
 
 
 
 
 
 
 
 
 
 
265
  # below ui prompt
266
  # - examples
267
  # st.markdown("<b>Example:</b>", unsafe_allow_html=True)
 
283
 
284
  # - Generate Customer Tweet
285
  if st.button("Generate Customer Message using Few Shots"):
 
 
 
 
286
  model, tokenizer = get_mistral_model_tokenizer(sota_model_name)
287
 
288
  noun_picker = DeckPicker(nouns)
 
308
  Xuechen Li, Carlos Guestrin, Percy Liang, Tatsunori B. Hashimoto
309
  - [Alpaca: A Strong, Replicable Instruction-Following Model](https://crfm.stanford.edu/2023/03/13/alpaca.html)""")
310
 
311
+ # main ui prompt
312
+ # - text box
313
+ # - submit
314
+ with st.form(key="my_form"):
315
+ customer_msg = st.text_area("Customer Message")
316
+ write_user_chat_message(user_chat, customer_msg)
317
+ if st.form_submit_button("Submit"):
318
+ st.session_state["user_msg_as_prompt"] = customer_msg
319
+ write_user_chat_message(user_chat, customer_msg)
320
+ model, tokenizer = get_model_tokenizer(sota_model_name)
321
+ input_text = alpaca_input_text_format.format(customer_msg)
322
+ st.write(f"```\n{input_text}```")
323
+ assistant_chat.write_stream(
324
+ stream_generation(
325
+ input_text,
326
+ show_prompt=False,
327
+ tokenizer=tokenizer,
328
+ model=model,
329
+ )
330
+ )
331
+
332
+ if True:
333
  gpu_stats = torch.cuda.get_device_properties(0)
334
  max_memory = gpu_stats.total_memory / 1024 ** 3
335
  start_gpu_memory = torch.cuda.memory_reserved(0) / 1024 ** 3
 
338
 
339
  st.write("Packages:")
340
  st.write(f"pytorch: {torch.__version__}")
341
+
342
+ st.markdown("""
343
+ ## ReplyCaddy
344
+
345
+ Small business owners, app developers, and freelance talent professionals need more time and money to compete for social media presence. Social media apps provide excellent reach on X, FaceBook, and Instagram, so customers sometimes request initial support from those. The correct response has always been to redirect them to the proper support funnels, such as account validation, issue classification, and prioritization.
346
+
347
+ However, composing the right tone for the first response message has been challenging and time-consuming, especially when the business owner has yet to experience customer support in public. One has to match the right tone and clarity and instruct the customer to redirect to the proper support channels.
348
+
349
+ By providing diverse responses, we can ensure each support message feels unique and tailored to the customer's message, avoiding the impersonal feel of a canned response.
350
+
351
+ ## Problems with existing solutions
352
+
353
+ We prompted ChatGPT to respond an irate, emotionally charged, and informal tone to match generation criteria which we will provide below.
354
+
355
+ "You are a customer support representative. compose a customer response to this tweet:
356
+ Your website is straight up garbage. how do you sell high end technology but you cant get a website right?"
357
+
358
+ [GenerationCriteria]
359
+
360
+ "Thank you for reaching out and sharing your feedback. We apologize for the trouble you're experiencing with our website. Please DM us or contact our support team at [support link] so we can help resolve any issues you're encountering."
361
+
362
+ First, the response is wordily composed and does not contain a request to DM; second, it has an apology and its context. Third, from our experience, ChatGPT values politeness more than a human would.
363
+
364
+ As a business, we want our brands to hold a high standard for these responses.
365
+
366
+ We present ReplyCaddy, an AI-powered first-response text message generator that will help us compose the right first-response message that composes personal messages and matches the customer's tone.
367
+
368
+ We tested the prompt above to ReplyCaddy, and it generated these examples:
369
+
370
+ "hi! let's talk about it."
371
+
372
+ "we'd love to help. we're here to help!"
373
+
374
+ "we understand that you are not happy with the website. please send us an email at <|url|>"
375
+ """)