Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,74 +11,84 @@ with gr.Blocks() as demo:
|
|
| 11 |
with gr.Row():
|
| 12 |
gr.Markdown("This application generates a focus group to answer your questions.\nFirst list your topic and questions, generate the focus group profile, get their answers and finally access the summary report")
|
| 13 |
with gr.Row():
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
gr.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
gr.
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
def parse_participants(input_string: str) -> list:
|
| 83 |
# Replace <br> tags with newline characters
|
| 84 |
input_string = input_string.replace("<br>", "\n")
|
|
@@ -360,6 +370,7 @@ Now please provide your results.
|
|
| 360 |
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 361 |
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])
|
| 362 |
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)
|
|
|
|
| 363 |
#clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
|
| 364 |
|
| 365 |
demo.launch()
|
|
|
|
| 11 |
with gr.Row():
|
| 12 |
gr.Markdown("This application generates a focus group to answer your questions.\nFirst list your topic and questions, generate the focus group profile, get their answers and finally access the summary report")
|
| 13 |
with gr.Row():
|
| 14 |
+
gr.Column(scale = 6):
|
| 15 |
+
apikey = gr.Textbox(label='Paste here your OpenAI - API key', info='No API key is stored and only you will see it.', lines = 1)
|
| 16 |
+
openai.api_key = os.getenv('APICode2') # openai.api_key = apikey
|
| 17 |
+
gr.Column(scale = 1):
|
| 18 |
+
useapi = gr.Button("Use this API")
|
| 19 |
+
with gr.Row(visible = False) as fullblock:
|
| 20 |
+
with gr.Tab("Enquiry Description"):
|
| 21 |
+
with gr.Row():
|
| 22 |
+
gr.Markdown("Describe your project or study")
|
| 23 |
+
with gr.Row():
|
| 24 |
+
title = gr.Textbox(label='Topic you would like to submit to your focus group', lines = 5)
|
| 25 |
+
with gr.Row():
|
| 26 |
+
gr.Markdown("List all your questions")
|
| 27 |
+
with gr.Row():
|
| 28 |
+
question1 = gr.Textbox(label="Question 1", lines=2)
|
| 29 |
+
with gr.Row():
|
| 30 |
+
question2 = gr.Textbox(label="Question 2", lines=2)
|
| 31 |
+
with gr.Row():
|
| 32 |
+
question3 = gr.Textbox(label="Question 3", lines=2)
|
| 33 |
+
with gr.Tab("Focus Group Profiles Generation"):
|
| 34 |
+
with gr.Row():
|
| 35 |
+
gr.Markdown("Describe types of profiles you want in your focus group")
|
| 36 |
+
with gr.Row():
|
| 37 |
+
focusgroupdescription = gr.Textbox(label="Describe your focus group desired characteristics", info= "For example: women in their 30s, teenagers, mixed ethnicity from Vietnam, ...", lines=5)
|
| 38 |
+
with gr.Row():
|
| 39 |
+
generategroup = gr.Button("Generate my focus group")
|
| 40 |
+
with gr.Row():
|
| 41 |
+
gr.Markdown("Participants")
|
| 42 |
+
with gr.Row():
|
| 43 |
+
expert1 = gr.Textbox(label="Participant 1", lines=5)
|
| 44 |
+
expert2 = gr.Textbox(label="Participant 2", lines=5)
|
| 45 |
+
with gr.Row():
|
| 46 |
+
expert3 = gr.Textbox(label="Participant 3", lines=5)
|
| 47 |
+
expert4 = gr.Textbox(label="Participant 4", lines=5)
|
| 48 |
+
with gr.Row():
|
| 49 |
+
expert5 = gr.Textbox(label="Participant 5", lines=5)
|
| 50 |
+
expert6 = gr.Textbox(label="Participant 6", lines=5)
|
| 51 |
+
with gr.Row():
|
| 52 |
+
expert7 = gr.Textbox(label="Participant 7", lines=5)
|
| 53 |
+
expert8 = gr.Textbox(label="Participant 8", lines=5)
|
| 54 |
+
with gr.Row():
|
| 55 |
+
expert9 = gr.Textbox(label="Participant 9", lines=5)
|
| 56 |
+
expert10 = gr.Textbox(label="Participant 10", lines=5)
|
| 57 |
+
with gr.Tab("Results"):
|
| 58 |
+
with gr.Row():
|
| 59 |
+
generateresults = gr.Button("Generate focus group answers")
|
| 60 |
+
with gr.Row():
|
| 61 |
+
gr.Markdown("Responses from the focus group participants")
|
| 62 |
+
with gr.Row():
|
| 63 |
+
response1 = gr.Textbox(label="Response 1", lines=10)
|
| 64 |
+
response2 = gr.Textbox(label="Response 2", lines=10)
|
| 65 |
+
with gr.Row():
|
| 66 |
+
response3 = gr.Textbox(label="Response 3", lines=10)
|
| 67 |
+
response4 = gr.Textbox(label="Response 4", lines=10)
|
| 68 |
+
with gr.Row():
|
| 69 |
+
response5 = gr.Textbox(label="Response 5", lines=10)
|
| 70 |
+
response6 = gr.Textbox(label="Response 6", lines=10)
|
| 71 |
+
with gr.Row():
|
| 72 |
+
response7 = gr.Textbox(label="Response 7", lines=10)
|
| 73 |
+
response8 = gr.Textbox(label="Response 8", lines=10)
|
| 74 |
+
with gr.Row():
|
| 75 |
+
response9 = gr.Textbox(label="Response 9", lines=10)
|
| 76 |
+
response10 = gr.Textbox(label="Response 10", lines=10)
|
| 77 |
+
with gr.Tab("Summary"):
|
| 78 |
+
with gr.Row():
|
| 79 |
+
generatesummary = gr.Button("Generate the focus group summary")
|
| 80 |
+
with gr.Row():
|
| 81 |
+
summary = gr.Textbox(label="Report summary", lines=50)
|
| 82 |
+
|
| 83 |
+
clear = gr.Button("Clear")
|
| 84 |
+
state = gr.State([])
|
| 85 |
+
|
| 86 |
+
def checkapiinput(apikey):
|
| 87 |
+
if apikey != "" and apikey is not None:
|
| 88 |
+
return gr.update(visible=True)
|
| 89 |
+
else:
|
| 90 |
+
return gr.update(visible=False)
|
| 91 |
+
|
| 92 |
def parse_participants(input_string: str) -> list:
|
| 93 |
# Replace <br> tags with newline characters
|
| 94 |
input_string = input_string.replace("<br>", "\n")
|
|
|
|
| 370 |
generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
|
| 371 |
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])
|
| 372 |
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)
|
| 373 |
+
useapi.click(checkapiinput, apikey, fullblock)
|
| 374 |
#clear.click(lambda: None, None, chatbot, queue=False).success(init_history, [state], [state])
|
| 375 |
|
| 376 |
demo.launch()
|