Tycohs commited on
Commit
4e565d4
·
1 Parent(s): dfea164

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -68
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
- apikey = gr.Textbox(label='Paste here your OpenAI - API key', info='No API key is stored and only you will see it.', lines = 1)
15
- openai.api_key = os.getenv('APICode2') # openai.api_key = apikey
16
- with gr.Tab("Enquiry Description"):
17
- with gr.Row():
18
- gr.Markdown("Describe your project or study")
19
- with gr.Row():
20
- title = gr.Textbox(label='Topic you would like to submit to your focus group', lines = 5)
21
- with gr.Row():
22
- gr.Markdown("List all your questions")
23
- with gr.Row():
24
- question1 = gr.Textbox(label="Question 1", lines=2)
25
- with gr.Row():
26
- question2 = gr.Textbox(label="Question 2", lines=2)
27
- with gr.Row():
28
- question3 = gr.Textbox(label="Question 3", lines=2)
29
- with gr.Tab("Focus Group Profiles Generation"):
30
- with gr.Row():
31
- gr.Markdown("Describe types of profiles you want in your focus group")
32
- with gr.Row():
33
- focusgroupdescription = gr.Textbox(label="Describe your focus group desired characteristics", info= "For example: women in their 30s, teenagers, mixed ethnicity from Vietnam, ...", lines=5)
34
- with gr.Row():
35
- generategroup = gr.Button("Generate my focus group")
36
- with gr.Row():
37
- gr.Markdown("Participants")
38
- with gr.Row():
39
- expert1 = gr.Textbox(label="Participant 1", lines=5)
40
- expert2 = gr.Textbox(label="Participant 2", lines=5)
41
- with gr.Row():
42
- expert3 = gr.Textbox(label="Participant 3", lines=5)
43
- expert4 = gr.Textbox(label="Participant 4", lines=5)
44
- with gr.Row():
45
- expert5 = gr.Textbox(label="Participant 5", lines=5)
46
- expert6 = gr.Textbox(label="Participant 6", lines=5)
47
- with gr.Row():
48
- expert7 = gr.Textbox(label="Participant 7", lines=5)
49
- expert8 = gr.Textbox(label="Participant 8", lines=5)
50
- with gr.Row():
51
- expert9 = gr.Textbox(label="Participant 9", lines=5)
52
- expert10 = gr.Textbox(label="Participant 10", lines=5)
53
- with gr.Tab("Results"):
54
- with gr.Row():
55
- generateresults = gr.Button("Generate focus group answers")
56
- with gr.Row():
57
- gr.Markdown("Responses from the focus group participants")
58
- with gr.Row():
59
- response1 = gr.Textbox(label="Response 1", lines=10)
60
- response2 = gr.Textbox(label="Response 2", lines=10)
61
- with gr.Row():
62
- response3 = gr.Textbox(label="Response 3", lines=10)
63
- response4 = gr.Textbox(label="Response 4", lines=10)
64
- with gr.Row():
65
- response5 = gr.Textbox(label="Response 5", lines=10)
66
- response6 = gr.Textbox(label="Response 6", lines=10)
67
- with gr.Row():
68
- response7 = gr.Textbox(label="Response 7", lines=10)
69
- response8 = gr.Textbox(label="Response 8", lines=10)
70
- with gr.Row():
71
- response9 = gr.Textbox(label="Response 9", lines=10)
72
- response10 = gr.Textbox(label="Response 10", lines=10)
73
- with gr.Tab("Summary"):
74
- with gr.Row():
75
- generatesummary = gr.Button("Generate the focus group summary")
76
- with gr.Row():
77
- summary = gr.Textbox(label="Report summary", lines=50)
78
-
79
- clear = gr.Button("Clear")
80
- state = gr.State([])
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()