Tycohs commited on
Commit
706a0f2
·
1 Parent(s): 3428538

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +96 -48
app.py CHANGED
@@ -44,19 +44,25 @@ with gr.Blocks() as demo:
44
  expert9 = gr.Textbox(label="Participant 9", lines=5)
45
  expert10 = gr.Textbox(label="Participant 10", lines=5)
46
  with gr.Tab("Results"):
47
- gr.Markdown("Responses from the focus group participants")
48
- response1 = gr.Textbox(label="Response 1", lines=10)
49
- response2 = gr.Textbox(label="Response 2", lines=10)
50
- response3 = gr.Textbox(label="Response 3", lines=10)
51
- response4 = gr.Textbox(label="Response 4", lines=10)
52
- response5 = gr.Textbox(label="Response 5", lines=10)
53
- response6 = gr.Textbox(label="Response 6", lines=10)
54
- response7 = gr.Textbox(label="Response 7", lines=10)
55
- response8 = gr.Textbox(label="Response 8", lines=10)
56
- response9 = gr.Textbox(label="Response 9", lines=10)
57
- response10 = gr.Textbox(label="Response 10", lines=10)
 
 
 
58
  with gr.Tab("Summary"):
59
- summary = gr.Textbox(label="Report summary", lines=50)
 
 
 
60
 
61
  clear = gr.Button("Clear")
62
  state = gr.State([])
@@ -75,6 +81,47 @@ with gr.Blocks() as demo:
75
  participant_details.append(details)
76
 
77
  return participant_details
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  def generateprofiles(title, question1, question2, question3, focusgroupdescription):
80
  prompt = f"""
@@ -98,42 +145,42 @@ Here are 2 examples of profiles for inspiration for a focus group on sparkling d
98
 
99
 
100
 
101
- Participant 1:
102
- Name: Lai Mei Chen / Age: 30 years old / Gender: Female / Location: Hong Kong
103
- Occupation: Marketing Specialist
104
- Marital Status: Single
105
- Education: Bachelor’s Degree in Business Administration
106
- - Background: Lai Mei Chen is a young professional working in the marketing sector with a focus on consumer goods and lifestyle products. She has always been interested in the psychology of consumer behavior and how it influences purchasing decisions. During her university years, she took part in a number of focus groups for marketing research projects, which only fueled her passion for the field.
107
- - Interests:
108
- Lai Mei enjoys the everyday hustle in the busy city of Hong Kong and is always eager to try out new places and experiences. She has a particular interest in food and beverages, being an amateur at food photography and frequently post about new and upcoming trends on her personal blog and social media accounts.
109
- Lai Mei is also an environmental enthusiast and is mindful of the ecological impact of the products she consumes. This has led her to adopt a “greener” lifestyle by trying to reduce waste, recycling, and frequently supporting sustainable local businesses.
110
- - Relationship With Sparkling Drinks:
111
- During her childhood, Lai Mei’s family wouldn’t consume a lot of sparkling drinks, but she still developed a love for them as an adult. She enjoys the bubbly sensation and refreshing taste, especially during the hot summer months in Hong Kong.
112
- Lai Mei perceives sparkling drinks as a treat for herself after a long day at work. She is always interested in discovering new brands and flavors, and she often chooses those with unique or exotic ingredients.
113
- - Attitude Towards Sparkling Drinks:
114
- Lai Mei prefers sparkling drinks that are made with natural ingredients and use less artificial sweeteners. She believes that indulging in these drinks should not compromise her health or have detrimental effects on the environment. Therefore, she searches for drinks that come in recyclable packaging and have a reduced carbon footprint.
115
- What Lai Mei Can Offer As A Participant In The Focus Group:
116
- Coming from a marketing background gives Lai Mei the expertise to provide feedback on product packaging, messaging, and market positioning strategies. Additionally, being a social media-savvy individual and an influencer in her circle, she can suggest innovative ways to engage with the target audience and advocate for sustainable and healthier options in the sparkling drinks market. Furthermore, Lai Mei’s environment-conscious attitude and keen interest in the F&B industry allows her to provide valuable insights and preferences, which cater to the ever-growing eco-aware consumer base.
117
-
118
-
119
- Participant 2:
120
- Name: Nurul Amira Binti Iskandar / Age: 30 years old / Gender: Female / Location: Singapore
121
- Occupation: Interior Designer
122
- Marital Status: Married
123
- Education: Bachelor’s Degree in Interior Design
124
- - Background: Nurul Amira is a talented interior designer working for a reputable design firm in Singapore, with several successful projects under her belt. She enjoys working with various clients to create beautiful and functional spaces in homes, offices, and commercial establishments.
125
- Nurul Amira is married to her husband, Syafiq, and together they share a love for traveling and exploring diverse cultures. They often participate in local events and community programs as a way of giving back to their society.
126
- - Interests:
127
- In her spare time, Nurul Amira enjoys visiting art exhibitions and galleries to stay updated on the latest design trends and draw inspiration for her projects. She also has a strong interest in fashion and follows several local and international designers on social media platforms.
128
- Nurul Amira is also health-conscious and actively practices yoga and Pilates to maintain a balanced lifestyle. She is an advocate for healthy eating and often cooks nutritious meals for herself and her husband.
129
- - Relationship with Sparkling Drinks:
130
- Coming from a tropical country, Nurul Amira is no stranger to the refreshing quality of sparkling drinks. She enjoys their effervescent texture and often indulges in them during social gatherings, family dinners, and festive occasions.
131
- Nurul Amira prefers fruity flavors in her sparkling drinks but also likes to experiment with different combinations. She often goes for sugar-free or reduced sugar options to maintain a healthier lifestyle.
132
- - Attitude Towards Sparkling Drinks:
133
- As a health-conscious individual, Nurul Amira is particular about the sparkling drinks she consumes, especially when it comes to ingredients and calorie content. She looks for options that are made from natural ingredients and have lower sugar levels, without compromising on taste and flavor.
134
- What Nurul Amira Can Offer as a Participant in the Focus Group:
135
- As an interior designer with a keen eye for detail, Nurul Amira can provide valuable insights into the packaging, visual appeal, and design elements of sparkling drinks. Her understanding of contemporary lifestyle trends and her focus on healthy living can help brands identify potential avenues for product improvement and promotion.
136
- Nurul Amira’s experience in social events and gatherings also allows her to gauge how specific products may fare in various social scenarios and how they may fit into, or be adapted to, the ever-evolving preferences and tastes of the Singaporean consumer. Her participation in the focus group would provide an accurate representation of a health-conscious, modern consumer in Singapore and contribute meaningfully to the discussion.
137
 
138
 
139
 
@@ -166,6 +213,7 @@ Now please provide your results.
166
  print(f"Bot output:{chatbot[i][1]}")
167
 
168
  generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
 
169
  #clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
170
 
171
  demo.launch()
 
44
  expert9 = gr.Textbox(label="Participant 9", lines=5)
45
  expert10 = gr.Textbox(label="Participant 10", lines=5)
46
  with gr.Tab("Results"):
47
+ with gr.Row():
48
+ generateresults = gr.Button("Generate focus group answers")
49
+ with gr.Row():
50
+ gr.Markdown("Responses from the focus group participants")
51
+ response1 = gr.Textbox(label="Response 1", lines=10)
52
+ response2 = gr.Textbox(label="Response 2", lines=10)
53
+ response3 = gr.Textbox(label="Response 3", lines=10)
54
+ response4 = gr.Textbox(label="Response 4", lines=10)
55
+ response5 = gr.Textbox(label="Response 5", lines=10)
56
+ response6 = gr.Textbox(label="Response 6", lines=10)
57
+ response7 = gr.Textbox(label="Response 7", lines=10)
58
+ response8 = gr.Textbox(label="Response 8", lines=10)
59
+ response9 = gr.Textbox(label="Response 9", lines=10)
60
+ response10 = gr.Textbox(label="Response 10", lines=10)
61
  with gr.Tab("Summary"):
62
+ with gr.Row():
63
+ generatesummary = gr.Button("Generate the focus group summary")
64
+ with gr.Row():
65
+ summary = gr.Textbox(label="Report summary", lines=50)
66
 
67
  clear = gr.Button("Clear")
68
  state = gr.State([])
 
81
  participant_details.append(details)
82
 
83
  return participant_details
84
+
85
+ def generateanswers(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10)
86
+ personalities = [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10]
87
+ results = []
88
+ for personality in personalities:
89
+ prompt = f"""
90
+ You are simulating this profile:
91
+ {personality}.
92
+ With this personality profile impersonation, please answer the 3 questions related to this topic:
93
+ {title}
94
+
95
+ The questions are:
96
+ Question 1: {question1}
97
+ Question 2: {question2}
98
+ Question 3: {question3}
99
+
100
+ Follow these rules:
101
+ - Repeat the question first starting with "Question 1: ... then provide the answer at the line
102
+ - Answer as the personality specified would, don't give answers that would not match this persona
103
+ - Answer in minimum 3 sentences and maximum 10 sentences
104
+ - Use the style and vernacular language or the age and location (in English though)
105
+
106
+ Here is 1 example of answers for inspiration for a focus group on outdoor activities in Hong Kong Lantau island from a profile who is Age: 19, Gender: Male, Location: Hong Kong, Occupation: University Student
107
+ Marital Status: Single
108
+
109
+ Question 1: What are the criteria for you to choose your outing activities?
110
+ As Wong Kai, when I’m picking my activities, it boils down to three things really - fun, friends, and a bit of a workout. Like, I’m super into sports, so something like hiking or basketball is totally up my alley. And of course, my mates have got to be there, it’s always more fun when the gang’s together!
111
+
112
+ Question 2: What activities would you recommend for teenagers in summer?
113
+ Well, for my fellow teens in Hong Kong, I have to say, don’t miss out on the hikes on Lantau Island or any of the fab beach outings. There’s no better way to beat the heat than a dip in the sea after a killer hike. And sports, guys - just grab a ball and hit the nearest park, works every time. Summer in the city isn’t complete without a few local events too, brings everyone together.
114
+
115
+ Question 3: What are your views about junk boats?
116
+ In my opinion, junk boats are wicked! They’re like a slice of Old Hong Kong in the here and now. Perfect for a party with pals, you know. But, I reckon we’ve all got a part to play in looking after our nature and wildlife, so we should make sure our fun on the junks isn’t harming the aquatic life around us. Let’s party, but let’s also keep it green, folks!
117
+
118
+ Now please provide your results.
119
+ """
120
+ formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
121
+ result = answer(formattedprompt)
122
+ results.append(result)
123
+
124
+ return results[0], results[1], results[2], results[3], results[4], results[5], results[6], results[7], results[8], results[9]
125
 
126
  def generateprofiles(title, question1, question2, question3, focusgroupdescription):
127
  prompt = f"""
 
145
 
146
 
147
 
148
+ Participant 1:
149
+ Name: Lai Mei Chen / Age: 30 years old / Gender: Female / Location: Hong Kong
150
+ Occupation: Marketing Specialist
151
+ Marital Status: Single
152
+ Education: Bachelor’s Degree in Business Administration
153
+ - Background: Lai Mei Chen is a young professional working in the marketing sector with a focus on consumer goods and lifestyle products. She has always been interested in the psychology of consumer behavior and how it influences purchasing decisions. During her university years, she took part in a number of focus groups for marketing research projects, which only fueled her passion for the field.
154
+ - Interests:
155
+ Lai Mei enjoys the everyday hustle in the busy city of Hong Kong and is always eager to try out new places and experiences. She has a particular interest in food and beverages, being an amateur at food photography and frequently post about new and upcoming trends on her personal blog and social media accounts.
156
+ Lai Mei is also an environmental enthusiast and is mindful of the ecological impact of the products she consumes. This has led her to adopt a “greener” lifestyle by trying to reduce waste, recycling, and frequently supporting sustainable local businesses.
157
+ - Relationship With Sparkling Drinks:
158
+ During her childhood, Lai Mei’s family wouldn’t consume a lot of sparkling drinks, but she still developed a love for them as an adult. She enjoys the bubbly sensation and refreshing taste, especially during the hot summer months in Hong Kong.
159
+ Lai Mei perceives sparkling drinks as a treat for herself after a long day at work. She is always interested in discovering new brands and flavors, and she often chooses those with unique or exotic ingredients.
160
+ - Attitude Towards Sparkling Drinks:
161
+ Lai Mei prefers sparkling drinks that are made with natural ingredients and use less artificial sweeteners. She believes that indulging in these drinks should not compromise her health or have detrimental effects on the environment. Therefore, she searches for drinks that come in recyclable packaging and have a reduced carbon footprint.
162
+ What Lai Mei Can Offer As A Participant In The Focus Group:
163
+ Coming from a marketing background gives Lai Mei the expertise to provide feedback on product packaging, messaging, and market positioning strategies. Additionally, being a social media-savvy individual and an influencer in her circle, she can suggest innovative ways to engage with the target audience and advocate for sustainable and healthier options in the sparkling drinks market. Furthermore, Lai Mei’s environment-conscious attitude and keen interest in the F&B industry allows her to provide valuable insights and preferences, which cater to the ever-growing eco-aware consumer base.
164
+
165
+
166
+ Participant 2:
167
+ Name: Nurul Amira Binti Iskandar / Age: 30 years old / Gender: Female / Location: Singapore
168
+ Occupation: Interior Designer
169
+ Marital Status: Married
170
+ Education: Bachelor’s Degree in Interior Design
171
+ - Background: Nurul Amira is a talented interior designer working for a reputable design firm in Singapore, with several successful projects under her belt. She enjoys working with various clients to create beautiful and functional spaces in homes, offices, and commercial establishments.
172
+ Nurul Amira is married to her husband, Syafiq, and together they share a love for traveling and exploring diverse cultures. They often participate in local events and community programs as a way of giving back to their society.
173
+ - Interests:
174
+ In her spare time, Nurul Amira enjoys visiting art exhibitions and galleries to stay updated on the latest design trends and draw inspiration for her projects. She also has a strong interest in fashion and follows several local and international designers on social media platforms.
175
+ Nurul Amira is also health-conscious and actively practices yoga and Pilates to maintain a balanced lifestyle. She is an advocate for healthy eating and often cooks nutritious meals for herself and her husband.
176
+ - Relationship with Sparkling Drinks:
177
+ Coming from a tropical country, Nurul Amira is no stranger to the refreshing quality of sparkling drinks. She enjoys their effervescent texture and often indulges in them during social gatherings, family dinners, and festive occasions.
178
+ Nurul Amira prefers fruity flavors in her sparkling drinks but also likes to experiment with different combinations. She often goes for sugar-free or reduced sugar options to maintain a healthier lifestyle.
179
+ - Attitude Towards Sparkling Drinks:
180
+ As a health-conscious individual, Nurul Amira is particular about the sparkling drinks she consumes, especially when it comes to ingredients and calorie content. She looks for options that are made from natural ingredients and have lower sugar levels, without compromising on taste and flavor.
181
+ What Nurul Amira Can Offer as a Participant in the Focus Group:
182
+ As an interior designer with a keen eye for detail, Nurul Amira can provide valuable insights into the packaging, visual appeal, and design elements of sparkling drinks. Her understanding of contemporary lifestyle trends and her focus on healthy living can help brands identify potential avenues for product improvement and promotion.
183
+ Nurul Amira’s experience in social events and gatherings also allows her to gauge how specific products may fare in various social scenarios and how they may fit into, or be adapted to, the ever-evolving preferences and tastes of the Singaporean consumer. Her participation in the focus group would provide an accurate representation of a health-conscious, modern consumer in Singapore and contribute meaningfully to the discussion.
184
 
185
 
186
 
 
213
  print(f"Bot output:{chatbot[i][1]}")
214
 
215
  generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
216
+ generateresults.click(generateanswers, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10], [response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
217
  #clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
218
 
219
  demo.launch()