Tycohs commited on
Commit
478ab9e
·
1 Parent(s): 4ab8135

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -68
app.py CHANGED
@@ -17,77 +17,75 @@ with gr.Blocks() as demo:
17
  with gr.Column(scale = 1):
18
  useapi = gr.Button("Use this API key")
19
  with gr.Row(visible = False) as fullblock:
20
- with gr.Row():
21
- with gr.Tab("Enquiry Description"):
22
- with gr.Row():
23
- gr.Markdown("Describe your project or study")
24
- with gr.Row():
25
- title = gr.Textbox(label='Topic you would like to submit to your focus group', lines = 5)
26
- with gr.Row():
27
- gr.Markdown("List all your questions")
28
- with gr.Row():
29
- question1 = gr.Textbox(label="Question 1", lines=2)
30
- with gr.Row():
31
- question2 = gr.Textbox(label="Question 2", lines=2)
32
- with gr.Row():
33
- question3 = gr.Textbox(label="Question 3", lines=2)
34
- with gr.Tab("Focus Group Profiles Generation"):
35
- with gr.Row():
36
- gr.Markdown("Describe types of profiles you want in your focus group")
37
- with gr.Row():
38
- focusgroupdescription = gr.Textbox(label="Describe your focus group desired characteristics", info= "For example: women in their 30s, teenagers, mixed ethnicity from Vietnam, ...", lines=5)
39
- with gr.Row():
40
- generategroup = gr.Button("Generate my focus group")
41
- with gr.Row():
42
- gr.Markdown("Participants")
43
- with gr.Row():
44
- expert1 = gr.Textbox(label="Participant 1", lines=5)
45
- expert2 = gr.Textbox(label="Participant 2", lines=5)
46
- with gr.Row():
47
- expert3 = gr.Textbox(label="Participant 3", lines=5)
48
- expert4 = gr.Textbox(label="Participant 4", lines=5)
49
- with gr.Row():
50
- expert5 = gr.Textbox(label="Participant 5", lines=5)
51
- expert6 = gr.Textbox(label="Participant 6", lines=5)
52
- with gr.Row():
53
- expert7 = gr.Textbox(label="Participant 7", lines=5)
54
- expert8 = gr.Textbox(label="Participant 8", lines=5)
55
- with gr.Row():
56
- expert9 = gr.Textbox(label="Participant 9", lines=5)
57
- expert10 = gr.Textbox(label="Participant 10", lines=5)
58
- with gr.Tab("Results"):
59
- with gr.Row():
60
- generateresults = gr.Button("Generate focus group answers")
61
- with gr.Row():
62
- gr.Markdown("Responses from the focus group participants")
63
- with gr.Row():
64
- response1 = gr.Textbox(label="Response 1", lines=10)
65
- response2 = gr.Textbox(label="Response 2", lines=10)
66
- with gr.Row():
67
- response3 = gr.Textbox(label="Response 3", lines=10)
68
- response4 = gr.Textbox(label="Response 4", lines=10)
69
- with gr.Row():
70
- response5 = gr.Textbox(label="Response 5", lines=10)
71
- response6 = gr.Textbox(label="Response 6", lines=10)
72
- with gr.Row():
73
- response7 = gr.Textbox(label="Response 7", lines=10)
74
- response8 = gr.Textbox(label="Response 8", lines=10)
75
- with gr.Row():
76
- response9 = gr.Textbox(label="Response 9", lines=10)
77
- response10 = gr.Textbox(label="Response 10", lines=10)
78
- with gr.Tab("Summary"):
79
- with gr.Row():
80
- generatesummary = gr.Button("Generate the focus group summary")
81
- with gr.Row():
82
- summary = gr.Textbox(label="Report summary", lines=50)
83
- with gr.Row():
84
- clear = gr.Button("Clear")
85
 
86
  def checkapiinput(apikey):
87
  if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
88
- return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
89
  else:
90
- return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key")
91
 
92
  def parse_participants(input_string: str) -> list:
93
  # Replace <br> tags with newline characters
@@ -362,7 +360,7 @@ Now please provide your results.
362
  generategroup.click(generateprofiles, [title, question1, question2, question3, focusgroupdescription], [expert1, expert2, expert3, expert4, expert5, expert6, expert7, expert8, expert9, expert10])
363
  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])
364
  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)
365
- useapi.click(checkapiinput, apikey, [fullblock, apicheck, apikey])
366
  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])
367
 
368
  demo.launch()
 
17
  with gr.Column(scale = 1):
18
  useapi = gr.Button("Use this API key")
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
+ clear = gr.Button("Clear", visible = False)
 
 
83
 
84
  def checkapiinput(apikey):
85
  if apikey != "" and apikey is not None and len(apikey) >=25 and len(apikey) <= 130:
86
+ return gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
87
  else:
88
+ return gr.update(visible=False), gr.update(visible=True), gr.update(value="", placeholder="Use a valid API key"), gr.update(visible=False)
89
 
90
  def parse_participants(input_string: str) -> list:
91
  # Replace <br> tags with newline characters
 
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
+ useapi.click(checkapiinput, apikey, [fullblock, apicheck, apikey, clear])
364
  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])
365
 
366
  demo.launch()