Ridealist commited on
Commit
69c6981
β€’
1 Parent(s): 298e0dc

feat: Add home, previous buttom

Browse files
Files changed (1) hide show
  1. app.py +72 -37
app.py CHANGED
@@ -16,7 +16,6 @@ from bots.judgement_bot import debate_judgement
16
  from collections import Counter
17
  import time
18
  from time import strftime
19
- from time import localtime
20
 
21
  from audiorecorder import audiorecorder
22
 
@@ -171,13 +170,16 @@ def page_6_7_controller():
171
  def page_2_7_controller():
172
  st.session_state.page = "Page 7"
173
 
 
 
 
174
  #########################################################
175
  # Page 1
176
  #########################################################
177
  def page1():
178
-
179
- # for local variables
180
- topic_list = []
181
 
182
  st.header('User Info')
183
  st.session_state.user_id = st.text_input(
@@ -186,17 +188,21 @@ def page1():
186
  placeholder="Enter user ID"
187
  )
188
 
189
- if st.button(
190
- label='Submit',
191
  on_click=page_1_2_controller
192
- ):
193
- st.write('Information submitted successfully.')
194
- # You can add a function here to save the submitted info
195
 
196
  #########################################################
197
  # Page 2
198
  #########################################################
199
  def page2():
 
 
 
 
 
 
200
  st.header("Choose Option")
201
  option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only & Analyzing Utterances"])
202
 
@@ -207,7 +213,7 @@ def page2():
207
  page_control_func = page_2_7_controller
208
 
209
  st.button(
210
- label='Submit',
211
  on_click=page_control_func
212
  )
213
 
@@ -229,8 +235,19 @@ def page3():
229
 
230
  print(debate_history)
231
 
 
 
 
 
 
232
  st.header("Debate History")
233
 
 
 
 
 
 
 
234
  num_history = len(debate_history)
235
  for i in range(num_history):
236
  with st.container():
@@ -248,11 +265,6 @@ def page3():
248
  )
249
  st.write("_"*50)
250
 
251
- st.button(
252
- label=f'πŸš€ Start new debate',
253
- on_click=page_3_4_controller
254
- )
255
-
256
  #########################################################
257
  # Page 4
258
  #########################################################
@@ -261,6 +273,12 @@ def page4():
261
  # Tab 1 - Total Debate (ν† λ‘  μ€€λΉ„ -> μ—°μŠ΅ -> 평가)
262
  #########################################################
263
 
 
 
 
 
 
 
264
  st.header("Total Debate")
265
  debate_themes = ['Education','Sports','Religion','Justice','Pandemic','Politics','Minority','etc']
266
 
@@ -335,8 +353,11 @@ def page4():
335
  )
336
  st.write("> Topic : ", topic)
337
 
338
- st.subheader("3. Cases")
339
- st.caption('These are just a tool to help you structure your thoughts on the content and does not reflect the actual discussion.')
 
 
 
340
 
341
  #########################################################
342
  # Case도 μ„Έμ…˜μ— μ €μž₯
@@ -344,23 +365,22 @@ def page4():
344
  st.session_state.case1 = st.text_area(
345
  label="Write a Case 1",
346
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
347
- height=100
348
  )
349
  st.session_state.case2 = st.text_area(
350
  label="Write a Case 2",
351
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
352
- height=100
353
  )
354
  st.session_state.case3 = st.text_area(
355
  label="Write a Case 3",
356
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
357
- height=100
358
  )
359
  case_error_message = st.empty()
360
-
361
- st.subheader("4. Side")
362
- st.session_state.pros_and_cons = st.selectbox("Choose your Side (Pros and Cons)", ["Pros", "Cons"])
363
 
 
 
364
  # Save the data to database
365
  start = st.button(
366
  label="Start Debate",
@@ -461,6 +481,9 @@ def page5():
461
  # time
462
  st.session_state.start_time = time.time()
463
 
 
 
 
464
  with st.sidebar:
465
  st.sidebar.title('Ask to GPT')
466
  user_input = st.sidebar.text_area(
@@ -507,7 +530,7 @@ def page5():
507
  "Debate Rules: ",
508
  "1) This debate will be divided into two teams, pro and con, with two debates on each team.",
509
  "2) The order of speaking is: first debater for the pro side, first debater for the con side, second debater for the pro side, second debater for the con side.",
510
- "3) Answer logically with an introduction, body, and conclusion.", #add this one.
511
  "4) Your role : " + bot_role + " side debator",
512
  "5) Debate subject: " + st.session_state['topic'],
513
  ])
@@ -520,6 +543,12 @@ def page5():
520
  st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
521
  st.session_state['bot_debate_history'].append(response)
522
 
 
 
 
 
 
 
523
  # container for chat history
524
  response_container = st.container()
525
  # container for text box
@@ -530,7 +559,7 @@ def page5():
530
  with st.form(key='my_form', clear_on_submit=True):
531
  user_input = None
532
  # record voice
533
- audio = audiorecorder("Click to record", "Recording...")
534
  if np.array_equal(st.session_state['pre_audio'], audio):
535
  audio = np.array([])
536
 
@@ -575,7 +604,6 @@ def page5():
575
  reload = True
576
  print("Nothing to transcribe")
577
 
578
- #TODO μ‚¬μš©μž input이 없을 λ•Œλ„ reloading으둜 buffering κ±Έλ¦¬λŠ” 문제 ν•΄κ²°
579
  with response_container:
580
  message(st.session_state['bot_debate_history'][0], key='0_bot')
581
  if len(st.session_state['bot_debate_history']) == 1:
@@ -597,16 +625,17 @@ def page5():
597
  st.audio(audio_bytes, format='audio/ogg')
598
  reload = False
599
 
600
- if st.button(label="Next",
601
- on_click=page_5_6_controller):
602
- st.write('Information submitted successfully.')
 
603
 
604
  print("#"*80)
605
  pprint.pprint(st.session_state.to_dict())
606
  print("#"*80)
607
 
608
  #########################################################
609
- # Page5 - Total Debate Evaluation
610
  #########################################################
611
  def page6():
612
 
@@ -614,6 +643,12 @@ def page6():
614
  st.session_state.end_time = time.time()
615
  st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
616
 
 
 
 
 
 
 
617
  # st.tab
618
  st.header('Total Debate Evaluation')
619
 
@@ -722,7 +757,7 @@ def page6():
722
 
723
 
724
  #########################################################
725
- # Page6
726
  #########################################################
727
 
728
  def page7():
@@ -838,13 +873,13 @@ def page7():
838
  # Page Routing
839
  #########################################################
840
  pages = {
841
- "Page 1": page1, # user_id와 openai_keyλ₯Ό μž…λ ₯λ°›λŠ” νŽ˜μ΄μ§€
842
  "Page 2": page2, # μ›ν•˜λŠ” κΈ°λŠ₯을 μ„ νƒν•˜λŠ” νŽ˜μ΄μ§€
843
- "Page 3": page3,
844
- "Page 4": page4, # Total Debate
845
- "Page 5": page5, # Evaluation Only
846
- "Page 6": page6, # Analyzing Utterances
847
- "Page 7": page7,
848
  }
849
 
850
  selection = st.session_state.page
 
16
  from collections import Counter
17
  import time
18
  from time import strftime
 
19
 
20
  from audiorecorder import audiorecorder
21
 
 
170
  def page_2_7_controller():
171
  st.session_state.page = "Page 7"
172
 
173
+ def page_n_1_controller():
174
+ st.session_state.page = "Page 1"
175
+
176
  #########################################################
177
  # Page 1
178
  #########################################################
179
  def page1():
180
+ _, _, pre, home = st.columns([5, 5, 1, 1])
181
+ with home:
182
+ st.button("πŸ”", on_click=page_n_1_controller)
183
 
184
  st.header('User Info')
185
  st.session_state.user_id = st.text_input(
 
188
  placeholder="Enter user ID"
189
  )
190
 
191
+ st.button(
192
+ label='Next',
193
  on_click=page_1_2_controller
194
+ )
 
 
195
 
196
  #########################################################
197
  # Page 2
198
  #########################################################
199
  def page2():
200
+ _, _, pre, home = st.columns([5, 5, 1, 1])
201
+ with pre:
202
+ st.button("πŸ”™", on_click=page_n_1_controller)
203
+ with home:
204
+ st.button("πŸ”", on_click=page_n_1_controller)
205
+
206
  st.header("Choose Option")
207
  option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only & Analyzing Utterances"])
208
 
 
213
  page_control_func = page_2_7_controller
214
 
215
  st.button(
216
+ label='Next',
217
  on_click=page_control_func
218
  )
219
 
 
235
 
236
  print(debate_history)
237
 
238
+ _, _, pre, home = st.columns([5, 5, 1, 1])
239
+ with pre:
240
+ st.button("πŸ”™", on_click=page_1_2_controller)
241
+ with home:
242
+ st.button("πŸ”", on_click=page_n_1_controller)
243
  st.header("Debate History")
244
 
245
+ st.button(
246
+ label=f'πŸš€ Start new debate',
247
+ on_click=page_3_4_controller
248
+ )
249
+ st.write("_"*50)
250
+
251
  num_history = len(debate_history)
252
  for i in range(num_history):
253
  with st.container():
 
265
  )
266
  st.write("_"*50)
267
 
 
 
 
 
 
268
  #########################################################
269
  # Page 4
270
  #########################################################
 
273
  # Tab 1 - Total Debate (ν† λ‘  μ€€λΉ„ -> μ—°μŠ΅ -> 평가)
274
  #########################################################
275
 
276
+ _, _, pre, home = st.columns([5, 5, 1, 1])
277
+ with pre:
278
+ st.button("πŸ”™", on_click=page_2_3_controller)
279
+ with home:
280
+ st.button("πŸ”", on_click=page_n_1_controller)
281
+
282
  st.header("Total Debate")
283
  debate_themes = ['Education','Sports','Religion','Justice','Pandemic','Politics','Minority','etc']
284
 
 
353
  )
354
  st.write("> Topic : ", topic)
355
 
356
+ st.subheader("3. Side")
357
+ st.session_state.pros_and_cons = st.selectbox("Choose your Side (Pros and Cons)", ["Pros", "Cons"])
358
+
359
+ st.subheader("4. Cases")
360
+ st.caption('πŸ“’ These are just a tool to help you structure your thoughts on the content and does not reflect the actual discussion.')
361
 
362
  #########################################################
363
  # Case도 μ„Έμ…˜μ— μ €μž₯
 
365
  st.session_state.case1 = st.text_area(
366
  label="Write a Case 1",
367
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
368
+ height=150
369
  )
370
  st.session_state.case2 = st.text_area(
371
  label="Write a Case 2",
372
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
373
+ height=150
374
  )
375
  st.session_state.case3 = st.text_area(
376
  label="Write a Case 3",
377
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
378
+ height=150
379
  )
380
  case_error_message = st.empty()
 
 
 
381
 
382
+ st.write("*" * 50)
383
+
384
  # Save the data to database
385
  start = st.button(
386
  label="Start Debate",
 
481
  # time
482
  st.session_state.start_time = time.time()
483
 
484
+ #########################################################
485
+ # Ask to GPT
486
+ #########################################################
487
  with st.sidebar:
488
  st.sidebar.title('Ask to GPT')
489
  user_input = st.sidebar.text_area(
 
530
  "Debate Rules: ",
531
  "1) This debate will be divided into two teams, pro and con, with two debates on each team.",
532
  "2) The order of speaking is: first debater for the pro side, first debater for the con side, second debater for the pro side, second debater for the con side.",
533
+ "3) Answer logically with an introduction, body, and conclusion.",
534
  "4) Your role : " + bot_role + " side debator",
535
  "5) Debate subject: " + st.session_state['topic'],
536
  ])
 
543
  st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
544
  st.session_state['bot_debate_history'].append(response)
545
 
546
+ _, _, pre, home = st.columns([5, 5, 1, 1])
547
+ with pre:
548
+ st.button("πŸ”™", on_click=page_3_4_controller)
549
+ with home:
550
+ st.button("πŸ”", on_click=page_n_1_controller)
551
+
552
  # container for chat history
553
  response_container = st.container()
554
  # container for text box
 
559
  with st.form(key='my_form', clear_on_submit=True):
560
  user_input = None
561
  # record voice
562
+ audio = audiorecorder("⏺️ Click to record", "⏹️ Recording...")
563
  if np.array_equal(st.session_state['pre_audio'], audio):
564
  audio = np.array([])
565
 
 
604
  reload = True
605
  print("Nothing to transcribe")
606
 
 
607
  with response_container:
608
  message(st.session_state['bot_debate_history'][0], key='0_bot')
609
  if len(st.session_state['bot_debate_history']) == 1:
 
625
  st.audio(audio_bytes, format='audio/ogg')
626
  reload = False
627
 
628
+ st.button(
629
+ label="Next",
630
+ on_click=page_5_6_controller
631
+ )
632
 
633
  print("#"*80)
634
  pprint.pprint(st.session_state.to_dict())
635
  print("#"*80)
636
 
637
  #########################################################
638
+ # Page6 - Total Debate Evaluation
639
  #########################################################
640
  def page6():
641
 
 
643
  st.session_state.end_time = time.time()
644
  st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
645
 
646
+ _, _, pre, home = st.columns([5, 5, 1, 1])
647
+ with pre:
648
+ st.button("πŸ”™", on_click=page_4_5_controller)
649
+ with home:
650
+ st.button("πŸ”", on_click=page_n_1_controller)
651
+
652
  # st.tab
653
  st.header('Total Debate Evaluation')
654
 
 
757
 
758
 
759
  #########################################################
760
+ # Page7
761
  #########################################################
762
 
763
  def page7():
 
873
  # Page Routing
874
  #########################################################
875
  pages = {
876
+ "Page 1": page1, # user_idλ₯Ό μž…λ ₯λ°›λŠ” νŽ˜μ΄μ§€
877
  "Page 2": page2, # μ›ν•˜λŠ” κΈ°λŠ₯을 μ„ νƒν•˜λŠ” νŽ˜μ΄μ§€
878
+ "Page 3": page3, # κ³Όκ±° ν† λ‘  내역을 μ„ νƒν•˜λŠ” νŽ˜μ΄μ§€
879
+ "Page 4": page4, # ν† λ‘  세뢀사항 μ„€μ •
880
+ "Page 5": page5, # Total Debate
881
+ "Page 6": page6, # Evaluation Only
882
+ "Page 7": page7, # Analyzing Utterances
883
  }
884
 
885
  selection = st.session_state.page