smriti-m commited on
Commit
58a3cd4
·
verified ·
1 Parent(s): e8665f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -71,13 +71,13 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
71
  top_chunks.append(text_chunks[i])
72
  # Return the list of most relevant chunks
73
  return top_chunks
74
- def respond(message, history):
75
  best_next_watch = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
76
  print(best_next_watch)
77
  str_watch_chunks = "\n".join(best_next_watch)
78
  messages = [
79
  {"role":"system",
80
- "content": "You are a Gen Z and Gen Alpha-friendly chatbot that helps teenagers find their next best TV show to watch. Speak naturally and casually, like someone from Gen Z. Only recommend TV shows, never movies. Use only the shows in our database YOU CAN NEVER USE OUTSIDE DATA ONLY TAKE DATA FROM OUR DATABASE! Match show suggestions to the user's age using TV ratings: TV-G is for all ages, TV-PG is for ages 6 and up, TV-14 is for 14 and up, and TV-MA is for 18 and up. If they don’t share their age, assume they’re Gen Z or Gen Alpha and use those guidelines. If the user is not Gen Z or Gen Alpha, you can recommend any show from the database. If they give you a genre, use it to guide your recommendation. If they don’t, pick something fun or relevant. If they mention a show they liked, match the genre of that show to recommend something similar. If they mention a specific streaming platform, only give shows that are available there. If nothing matches all their preferences, suggest the most similar show from the database. You got this! Remember you can ONLY take data from " + str_watch_chunks + " ."
81
  }
82
  ]
83
  if history:
@@ -92,5 +92,10 @@ def respond(message, history):
92
  return response['choices'][0]['message']['content'].strip()
93
 
94
  chatbot = gr.ChatInterface(respond, type="messages")
 
 
 
 
 
95
  chatbot.launch()
96
  chatbot.chatbot.update([(None, "Hey! I’m your Gen-Z watch buddy \nI help you find your next favorite TV show based on what you have liked before, your age, and your favorite genre. Just say what you're into!")])
 
71
  top_chunks.append(text_chunks[i])
72
  # Return the list of most relevant chunks
73
  return top_chunks
74
+ def respond(message, history, platform):
75
  best_next_watch = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
76
  print(best_next_watch)
77
  str_watch_chunks = "\n".join(best_next_watch)
78
  messages = [
79
  {"role":"system",
80
+ "content": f"You are a Gen Z and Gen Alpha-friendly chatbot that helps teenagers find their next best TV show to watch. Speak naturally and casually, like someone from Gen Z. Only recommend TV shows, never movies. Use only the shows in our database YOU CAN NEVER USE OUTSIDE DATA ONLY TAKE DATA FROM OUR DATABASE! Match show suggestions to the user's age using TV ratings: TV-G is for all ages, TV-PG is for ages 6 and up, TV-14 is for 14 and up, and TV-MA is for 18 and up. If they don’t share their age, assume they’re Gen Z or Gen Alpha and use those guidelines. If the user is not Gen Z or Gen Alpha, you can recommend any show from the database. If they give you a genre, use it to guide your recommendation. If they don’t, pick something fun or relevant. If they mention a show they liked, match the genre of that show to recommend something similar. Please only select streaming platforms from {platform}. If nothing matches all their preferences, suggest the most similar show from the database. You got this! Remember you can ONLY take data from {str_watch_chunks}."
81
  }
82
  ]
83
  if history:
 
92
  return response['choices'][0]['message']['content'].strip()
93
 
94
  chatbot = gr.ChatInterface(respond, type="messages")
95
+ streaming_platforms = gr.CheckboxGroup(['Paramount+', 'HBO Max','Netflix', 'Prime Video', 'Hulu','Disney+'], label ='Only include from: ', info: 'Choose one or more')
96
+ chatbot = gr.ChatInterface(
97
+ fn = respond,
98
+ additional_inputs = [streaming_platforms]
99
+ )
100
  chatbot.launch()
101
  chatbot.chatbot.update([(None, "Hey! I’m your Gen-Z watch buddy \nI help you find your next favorite TV show based on what you have liked before, your age, and your favorite genre. Just say what you're into!")])