Tycohs commited on
Commit
fc2b768
·
1 Parent(s): e3166ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -1
app.py CHANGED
@@ -48,6 +48,7 @@ with gr.Blocks() as demo:
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)
@@ -82,6 +83,78 @@ with gr.Blocks() as demo:
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 = []
@@ -100,7 +173,8 @@ Question 3: {question3}
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
@@ -214,6 +288,7 @@ Now please provide your results.
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()
 
48
  generateresults = gr.Button("Generate focus group answers")
49
  with gr.Row():
50
  gr.Markdown("Responses from the focus group participants")
51
+ with gr.Row():
52
  response1 = gr.Textbox(label="Response 1", lines=10)
53
  response2 = gr.Textbox(label="Response 2", lines=10)
54
  response3 = gr.Textbox(label="Response 3", lines=10)
 
83
 
84
  return participant_details
85
 
86
+ def summarize(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10):
87
+ prompt = f"""
88
+ You are asked to make a report summarizing the inputs from 10 participants from a focus groups on this topic:
89
+ {title}
90
+
91
+ The questions asked were:
92
+ Question 1: {question1}
93
+ Question 2: {question2}
94
+ Question 3: {question3}
95
+
96
+ The profiles and their answers are:
97
+ Profile 1:
98
+ {expert1}
99
+ His answers were:
100
+ {response1}
101
+
102
+ Profile 2:
103
+ {expert2}
104
+ His answers were:
105
+ {response2}
106
+
107
+ Profile 3:
108
+ {expert3}
109
+ His answers were:
110
+ {response3}
111
+
112
+ Profile 4:
113
+ {expert4}
114
+ His answers were:
115
+ {response4}
116
+
117
+ Profile 5:
118
+ {expert5}
119
+ His answers were:
120
+ {response5}
121
+
122
+ Profile 6:
123
+ {expert6}
124
+ His answers were:
125
+ {response6}
126
+
127
+ Profile 7:
128
+ {expert7}
129
+ His answers were:
130
+ {response7}
131
+
132
+ Profile 8:
133
+ {expert8}
134
+ His answers were:
135
+ {response8}
136
+
137
+ Profile 9:
138
+ {expert9}
139
+ His answers were:
140
+ {response9}
141
+
142
+ Profile 10:
143
+ {expert10}
144
+ His answers were:
145
+ {response10}
146
+
147
+ Follow these rules:
148
+ - Summarize the answers per question, start with 'Question 1:' and repeat the question then provide the summary below
149
+ - Provide your summary per question, breaking down the nuance per demographic or profession or any social / profiling category you see fit
150
+ - Keep only the key points in a rational and professional way
151
+ - Provide a recommendation for action to address the needs expressed in the answers for each question.
152
+
153
+ Now please provide your summary.
154
+ """
155
+ formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
156
+ result = answer(formattedprompt)
157
+
158
  def generateanswers(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10):
159
  personalities = [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10]
160
  results = []
 
173
  Follow these rules:
174
  - Repeat the question first starting with "Question 1: ... then provide the answer at the line
175
  - Answer as the personality specified would, don't give answers that would not match this persona
176
+ - Answer in minimum 5 sentences and maximum 10 sentences
177
+ - Don't be too moralizing (environment safety, social impact...)
178
  - Use the style and vernacular language or the age and location (in English though)
179
 
180
  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
 
288
 
289
  generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
290
  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])
291
+ generatesummary.click(summarize, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10], summary)
292
  #clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
293
 
294
  demo.launch()