Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,6 +21,7 @@ with gr.Blocks() as demo:
|
|
| 21 |
with gr.Column(scale = 1):
|
| 22 |
useapi = gr.Button("Use this API key")
|
| 23 |
with gr.Row(visible = False) as fullblock:
|
|
|
|
| 24 |
with gr.Tab("Enquiry Description"):
|
| 25 |
with gr.Row():
|
| 26 |
gr.Markdown("Describe your project or study")
|
|
@@ -115,7 +116,7 @@ with gr.Blocks() as demo:
|
|
| 115 |
else:
|
| 116 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
| 117 |
|
| 118 |
-
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):
|
| 119 |
prompt = f"""
|
| 120 |
You are asked to make a report summarizing the inputs from 10 participants from a focus groups on this topic:
|
| 121 |
{title}
|
|
@@ -196,7 +197,7 @@ Follow these rules:
|
|
| 196 |
- For each question, provide a recommendation for action to address the needs expressed in the answers for each question, start it with "Recommendation:" then add your prespecriptions on bullet points just asfter
|
| 197 |
|
| 198 |
|
| 199 |
-
Now please provide your summary and recommendations for each of the questions
|
| 200 |
"""
|
| 201 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 202 |
result = answer(formattedprompt, "gpt-3.5-turbo-16k")
|
|
@@ -290,7 +291,7 @@ Participant answers:
|
|
| 290 |
"""
|
| 291 |
return result
|
| 292 |
|
| 293 |
-
def generateanswers(title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10):
|
| 294 |
personalities = [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10]
|
| 295 |
results = []
|
| 296 |
for personality in personalities:
|
|
@@ -326,7 +327,7 @@ Marital Status: Single
|
|
| 326 |
Question 3: What are your views about junk boats?
|
| 327 |
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!
|
| 328 |
|
| 329 |
-
Now please provide your results
|
| 330 |
"""
|
| 331 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 332 |
result = answer(formattedprompt, "gpt-4")
|
|
@@ -349,7 +350,7 @@ Now please provide your results.
|
|
| 349 |
|
| 350 |
return participant_details
|
| 351 |
|
| 352 |
-
def generateprofiles(title, question1, question2, question3, focusgroupdescription):
|
| 353 |
prompt = f"""
|
| 354 |
Please generate 10 profiles for a focus group that would have the following features:
|
| 355 |
- Title: {title}
|
|
@@ -410,7 +411,7 @@ Here are 2 examples of profiles for inspiration (for a focus group on sparkling
|
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
-
Now please provide your results.
|
| 414 |
"""
|
| 415 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 416 |
list = []
|
|
@@ -441,9 +442,9 @@ Now please provide your results.
|
|
| 441 |
def init_history(title):
|
| 442 |
return "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
|
| 443 |
|
| 444 |
-
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 445 |
-
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])
|
| 446 |
-
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)
|
| 447 |
useapi.click(checkapiinput, apikey, [fullblock, apicheck, apikey, clear])
|
| 448 |
restore.click(uploaddetailsfromreport, summary, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
|
| 449 |
clear.click(init_history, title, [title, question1, question2, question3, focusgroupdescription, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10, summary])
|
|
|
|
| 21 |
with gr.Column(scale = 1):
|
| 22 |
useapi = gr.Button("Use this API key")
|
| 23 |
with gr.Row(visible = False) as fullblock:
|
| 24 |
+
language = gr.Textbox(label='Choose your output language', lines = 1, value = 'English')
|
| 25 |
with gr.Tab("Enquiry Description"):
|
| 26 |
with gr.Row():
|
| 27 |
gr.Markdown("Describe your project or study")
|
|
|
|
| 116 |
else:
|
| 117 |
return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
|
| 118 |
|
| 119 |
+
def summarize(title, language, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10):
|
| 120 |
prompt = f"""
|
| 121 |
You are asked to make a report summarizing the inputs from 10 participants from a focus groups on this topic:
|
| 122 |
{title}
|
|
|
|
| 197 |
- For each question, provide a recommendation for action to address the needs expressed in the answers for each question, start it with "Recommendation:" then add your prespecriptions on bullet points just asfter
|
| 198 |
|
| 199 |
|
| 200 |
+
Now please provide your summary and recommendations for each of the questions using the following language: {language}
|
| 201 |
"""
|
| 202 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 203 |
result = answer(formattedprompt, "gpt-3.5-turbo-16k")
|
|
|
|
| 291 |
"""
|
| 292 |
return result
|
| 293 |
|
| 294 |
+
def generateanswers(title, language, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10):
|
| 295 |
personalities = [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10]
|
| 296 |
results = []
|
| 297 |
for personality in personalities:
|
|
|
|
| 327 |
Question 3: What are your views about junk boats?
|
| 328 |
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!
|
| 329 |
|
| 330 |
+
Now please provide your results using the following language: {language}
|
| 331 |
"""
|
| 332 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 333 |
result = answer(formattedprompt, "gpt-4")
|
|
|
|
| 350 |
|
| 351 |
return participant_details
|
| 352 |
|
| 353 |
+
def generateprofiles(title, language, question1, question2, question3, focusgroupdescription):
|
| 354 |
prompt = f"""
|
| 355 |
Please generate 10 profiles for a focus group that would have the following features:
|
| 356 |
- Title: {title}
|
|
|
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
+
Now please provide your results using the following language: {language}.
|
| 415 |
"""
|
| 416 |
formattedprompt = [{'role':'system','content':system_message},{'role':'user','content':prompt}]
|
| 417 |
list = []
|
|
|
|
| 442 |
def init_history(title):
|
| 443 |
return "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
|
| 444 |
|
| 445 |
+
generategroup.click(generateprofiles, [title, language, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 446 |
+
generateresults.click(generateanswers, [title, language, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10], [response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
|
| 447 |
+
generatesummary.click(summarize, [title, language, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10], summary)
|
| 448 |
useapi.click(checkapiinput, apikey, [fullblock, apicheck, apikey, clear])
|
| 449 |
restore.click(uploaddetailsfromreport, summary, [title, question1, question2, question3, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10])
|
| 450 |
clear.click(init_history, title, [title, question1, question2, question3, focusgroupdescription, expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10, response1, response2, response3, response4, response5, response6, response7, response8, response9, response10, summary])
|