codingchild commited on
Commit
4deaa88
β€’
1 Parent(s): 1a7b403

connect database

Browse files
Files changed (1) hide show
  1. app.py +209 -43
app.py CHANGED
@@ -6,10 +6,15 @@ from gtts import gTTS
6
  from collections import Counter
7
  from streamlit_chat import message
8
 
 
 
 
9
  from dotenv import dotenv_values
10
  from bots.judgement_bot import debate_judgement
11
  from collections import Counter
12
  import time
 
 
13
 
14
  from audiorecorder import audiorecorder
15
 
@@ -22,14 +27,31 @@ config = dotenv_values(".env")
22
  openai.organization = config.get('OPENAI_ORGANIZATION')
23
  openai.api_key = config.get('OPENAI_API_KEY')
24
 
 
25
  #openai.organization = st.secrets['OPENAI_ORGANIZATION']
26
  #openai.api_key = st.secrets['OPENAI_API_KEY']
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- # Page Configuration
 
 
30
  st.set_page_config(page_title="Streamlit App")
31
 
 
32
  # Initialize session state variables
 
33
  if "page" not in st.session_state:
34
  st.session_state.page = "Page 1"
35
 
@@ -39,9 +61,6 @@ if "topic" not in st.session_state:
39
  if "user_id" not in st.session_state:
40
  st.session_state.user_id = ""
41
 
42
- if "openAI_token" not in st.session_state:
43
- st.session_state.openAI_token = ""
44
-
45
  if "case1" not in st.session_state:
46
  st.session_state.case1 = ""
47
 
@@ -69,7 +88,6 @@ if "user_debate_time" not in st.session_state:
69
  if "pros_and_cons" not in st.session_state:
70
  st.session_state.pros_and_cons = ""
71
 
72
- # Time session
73
  if "start_time" not in st.session_state:
74
  st.session_state.start_time = time.time()
75
 
@@ -82,31 +100,64 @@ if "debate_time" not in st.session_state:
82
  if "pre_audio" not in st.session_state:
83
  st.session_state.pre_audio = np.array([])
84
 
 
 
 
 
 
 
 
 
85
 
 
 
 
 
 
 
 
86
  # Save function (placeholder)
87
- def save_info(user_id, openAI_token, debate_theme):
 
88
  # You can add the code to save the submitted info (e.g., to a database)
89
  st.session_state.user_id = user_id
90
- st.session_state.openAI_token = openAI_token
91
- st.session_state.debate_theme = debate_theme
92
 
93
  print("User ID:", user_id)
94
- print("OpenAI token:", openAI_token)
95
- print("Debate theme:", debate_theme)
96
 
97
  # Session state
98
  #session_state = SessionState.get(user_id="", openAI_token="", debate_theme="")
99
-
100
  def write_info():
101
  st.write('You choose', st.session_state.topic_list)
102
 
103
  # for callback when button is clicked
104
  def page_1_2_controller():
105
- if st.session_state.user_id.strip() == "" or st.session_state.openAI_token.strip() == "":
106
  st.session_state.page = "Page 1"
107
  st.warning('Please fill in all the required fields.')
108
  else:
109
  st.session_state.page = "Page 2"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  def page_2_3_controller():
112
  st.session_state.page = "Page 3"
@@ -140,24 +191,12 @@ def page1():
140
  max_chars=100,
141
  placeholder="Enter user ID"
142
  )
143
- # st.session_state.openAI_token = st.text_input(
144
- # label="Enter OpenAI token",
145
- # max_chars=200,
146
- # placeholder="Enter OpenAI token"
147
- # )
148
-
149
- if st.button(
150
  label='Submit all information',
151
  on_click=page_1_2_controller
152
- ):
153
  # You can add a function here to save the submitted info
154
- if st.session_state.user_id != '' and st.session_state.openAI_token != '':
155
- save_info(
156
- st.session_state.user_id,
157
- st.session_state.openAI_token,
158
- st.session_state.debate_theme
159
- )
160
- st.write('Information submitted successfully.')
161
 
162
  #########################################################
163
  # Page 2
@@ -195,49 +234,42 @@ def page3():
195
  "THS a world where the government gives cash that individuals can use to freely select their academic preference (including but not limited to school of choice, private academies, and tutoring) instead of funding for public education.",
196
  "THW abolish all requirements and evaluation criteria in higher education (i.e., attendance, exams, assignments)."
197
  ]
198
- #topic = st.selectbox("Select a topic_list", topic_list)
199
  elif st.session_state.debate_theme == 'Sports':
200
  topic_list = [
201
  "THBT having star players for team sports do more harm than good to the team.",
202
  "THR the emphasis on winning a medal in the Olympics as a core symbol of success.",
203
  "THP a world where sports serves purely entertainment purposes even at the expense of fair play."
204
  ]
205
- #topic = st.selectbox("Select a topic_list", topic_list)
206
  elif st.session_state.debate_theme == 'Religion':
207
  topic_list = [
208
  "THW, as a religious group/leader, cease attempts at increasing the number of believers and instead prioritize boosting loyalty amongst adherents to the religion.",
209
  "Assuming feasibility, TH prefers a world where a panel of church leaders would create a universally accepted interpretation of the Bible that the believers would abide by.",
210
  "THW aggressively crackdown on megachurches."
211
  ]
212
- #topic = st.selectbox("Select a topic_list", topic_list)
213
  elif st.session_state.debate_theme == 'Justice':
214
  topic_list = [
215
  "In 2050, AI robots are able to replicate the appearance, conversation, and reaction to emotions of human beings. However, their intelligence still does not allow them to sense emotions and feelings such as pain, happiness, joy, and etc.",
216
  "In the case a human destroys the robot beyond repair, THW charge murder instead of property damage.",
217
  "THP a world where the criminal justice system’s role is mainly for victim’s vengeance. THW allow prosecutors and victims to veto assigned judges."
218
  ]
219
- #topic = st.selectbox("Select a topic_list", topic_list)
220
  elif st.session_state.debate_theme == 'Pandemic':
221
  topic_list = [
222
  "During a pandemic, THBT businesses that benefit from the pandemic should be additionally taxed.",
223
  "THW nullify the effect of medical patents in cases of medical emergencies.",
224
  "THW ban media content that denies the efficacy of the COVID-19 without substantial evidence."
225
  ]
226
- #topic = st.selectbox("Select a topic_list", topic_list)
227
  elif st.session_state.debate_theme == 'Politics':
228
  topic_list = [
229
  "Info: The Candle Light Will (μ΄›λΆˆλ―Όμ‹¬) is a term derived from the symbolic candle-light protests for the impeachment of the late president Park Geun Hye, commonly used to mean the people’s will to fight against corrupt governments. The Moon administration has frequently referred to the Candle Light Will as the driving force behind its election that grants legitimacy to its policies. THR the β€˜candle light will’ narrative in the political discourse of South Korea.",
230
  "THW impose a cap on the property and income of politicians.",
231
  "THW give the youth extra votes."
232
  ]
233
- #topic = st.selectbox("Select a topic_list", topic_list)
234
  elif st.session_state.debate_theme == 'Minority':
235
  topic_list = [
236
  "Context: A prominent member of the LGBT movement has discovered that a very influential politician helping the LGBT movement has been lying about their sexual orientation as being gay when they are straight. THW disclose this information.",
237
  "THBT the LGBTQIA+ movement should denounce the existence of marriage as opposed to fighting for equal marriage rights.",
238
  "THBT the LGBTQIA+ movement should condemn the consumption of movies and TV shows that cast straight actors/actresses in non-heterosexual identified roles."
239
  ]
240
- #topic = st.selectbox("Select a topic_list", topic_list)
241
  else:
242
  topic_list = [
243
  "THW remove all laws that relate to filial responsibilities.",
@@ -259,17 +291,20 @@ def page3():
259
 
260
  st.write("3. Write 3 cases")
261
 
262
- case1 = st.text_area(
 
 
 
263
  label="Case 1",
264
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
265
  height=100
266
  )
267
- case2 = st.text_area(
268
  label="Case 2",
269
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
270
  height=100
271
  )
272
- case3 = st.text_area(
273
  label="Case 3",
274
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
275
  height=100
@@ -277,16 +312,32 @@ def page3():
277
  case_error_message = st.empty()
278
  st.session_state.pros_and_cons = st.selectbox("Choose your Side (Pros and Cons)", ["Pros", "Cons"])
279
 
280
- start = st.button(label="Start Debate")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
  def validate_case(error_message):
283
- if not case1 or not case2 or not case3:
284
  case_error_message.error("Please fill out above all", icon="🚨")
285
  return False
286
  else:
287
- st.session_state.case1 = case1
288
- st.session_state.case2 = case2
289
- st.session_state.case3 = case3
290
  return True
291
 
292
  if start:
@@ -294,6 +345,9 @@ def page3():
294
  page_3_4_controller()
295
  st.experimental_rerun()
296
 
 
 
 
297
  with st.sidebar:
298
  st.sidebar.title('Ask to GPT')
299
  user_input = st.sidebar.text_area(
@@ -308,6 +362,19 @@ def page3():
308
  result = ""
309
  else:
310
  result = gpt_call(user_input)
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  else:
312
  result = ""
313
 
@@ -359,6 +426,16 @@ def page4():
359
  result = ""
360
  else:
361
  result = gpt_call(user_input)
 
 
 
 
 
 
 
 
 
 
362
  else:
363
  result = ""
364
 
@@ -387,6 +464,21 @@ def page4():
387
  st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
388
  st.session_state['bot_debate_history'].append(response)
389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  # container for chat history
391
  response_container = st.container()
392
  # container for text box
@@ -409,8 +501,33 @@ def page4():
409
  if submit_buttom:
410
  if audio.any():
411
  user_input = execute_stt(audio)
412
- output = generate_response(user_input)
413
  st.session_state['pre_audio'] = audio
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  else:
415
  send_error_message.error("Please record your voice first", icon="🚨")
416
  print("Nothing to transcribe")
@@ -481,6 +598,18 @@ def page5():
481
 
482
  st.write("Debate Judgement Result")
483
  st.write(judgement_result)
 
 
 
 
 
 
 
 
 
 
 
 
484
  st.success('Done!')
485
 
486
  with tab2:
@@ -518,6 +647,19 @@ def page5():
518
  disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
519
  st.write("Disfluency Counts: ", disfluency_counts)
520
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  # μœ μ €μ™€ λ΄‡μ˜ λŒ€ν™” 데이터가 μ„Έμ…˜μ— λ‚¨μ•„μžˆμŒ
522
  # st.session_state.debate_history
523
 
@@ -561,6 +703,17 @@ def page6():
561
  user_debate_history,
562
  bot_debate_history
563
  )
 
 
 
 
 
 
 
 
 
 
 
564
 
565
  st.write("Debate Judgement Result")
566
  st.write(judgement_result)
@@ -600,6 +753,19 @@ def page6():
600
  disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
601
  st.write("Disfluency Counts: ", disfluency_counts)
602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  # μœ μ €μ™€ λ΄‡μ˜ λŒ€ν™” 데이터가 μ„Έμ…˜μ— λ‚¨μ•„μžˆμŒ
604
  # st.session_state.debate_history
605
 
 
6
  from collections import Counter
7
  from streamlit_chat import message
8
 
9
+ # db_modules
10
+ from modules.db_modules import get_db, put_item, get_item, get_lastest_item
11
+
12
  from dotenv import dotenv_values
13
  from bots.judgement_bot import debate_judgement
14
  from collections import Counter
15
  import time
16
+ from time import strftime
17
+ from time import localtime
18
 
19
  from audiorecorder import audiorecorder
20
 
 
27
  openai.organization = config.get('OPENAI_ORGANIZATION')
28
  openai.api_key = config.get('OPENAI_API_KEY')
29
 
30
+
31
  #openai.organization = st.secrets['OPENAI_ORGANIZATION']
32
  #openai.api_key = st.secrets['OPENAI_API_KEY']
33
 
34
+ #########################################################
35
+ # GET DB
36
+ #########################################################
37
+ dynamodb = get_db()
38
+
39
+
40
+ #########################################################
41
+ # Time Stamp
42
+ #########################################################
43
+ tm = time.localtime()
44
+ time_stamp = strftime('%Y-%m-%d %I:%M:%S %p', tm)
45
+
46
 
47
+ #########################################################
48
+ # Page Configurations
49
+ #########################################################
50
  st.set_page_config(page_title="Streamlit App")
51
 
52
+ #########################################################
53
  # Initialize session state variables
54
+ #########################################################
55
  if "page" not in st.session_state:
56
  st.session_state.page = "Page 1"
57
 
 
61
  if "user_id" not in st.session_state:
62
  st.session_state.user_id = ""
63
 
 
 
 
64
  if "case1" not in st.session_state:
65
  st.session_state.case1 = ""
66
 
 
88
  if "pros_and_cons" not in st.session_state:
89
  st.session_state.pros_and_cons = ""
90
 
 
91
  if "start_time" not in st.session_state:
92
  st.session_state.start_time = time.time()
93
 
 
100
  if "pre_audio" not in st.session_state:
101
  st.session_state.pre_audio = np.array([])
102
 
103
+ if "case1" not in st.session_state:
104
+ st.session_state.case1 = ""
105
+
106
+ if "case2" not in st.session_state:
107
+ st.session_state.case2 = ""
108
+
109
+ if "case3" not in st.session_state:
110
+ st.session_state.case3 = ""
111
 
112
+
113
+ # for db session number
114
+ if "session_num" not in st.session_state:
115
+ st.session_state.session_num = 0
116
+
117
+
118
+ #########################################################
119
  # Save function (placeholder)
120
+ #########################################################
121
+ def save_info(user_id):
122
  # You can add the code to save the submitted info (e.g., to a database)
123
  st.session_state.user_id = user_id
 
 
124
 
125
  print("User ID:", user_id)
 
 
126
 
127
  # Session state
128
  #session_state = SessionState.get(user_id="", openAI_token="", debate_theme="")
 
129
  def write_info():
130
  st.write('You choose', st.session_state.topic_list)
131
 
132
  # for callback when button is clicked
133
  def page_1_2_controller():
134
+ if st.session_state.user_id.strip() == "":
135
  st.session_state.page = "Page 1"
136
  st.warning('Please fill in all the required fields.')
137
  else:
138
  st.session_state.page = "Page 2"
139
+ print("save info")
140
+
141
+ save_info(
142
+ st.session_state.user_id
143
+ )
144
+ st.write('Information submitted successfully.')
145
+
146
+ #########################################################
147
+ # Session Update
148
+ #########################################################
149
+ debate_setting = get_lastest_item(
150
+ table=dynamodb.Table('DEBO_debate_setting'),
151
+ name_of_partition_key="user_id",
152
+ value_of_partition_key=st.session_state.user_id,
153
+ limit_num=1
154
+ )
155
+ # Session이 μ—†λ‹€λ©΄, 0으둜 μ΄ˆκΈ°ν™”
156
+ if debate_setting == []:
157
+ st.session_state.session_num = 0
158
+ # User의 이전 κΈ°λ‘μ—μ„œ Session이 μžˆλ‹€λ©΄, Session Numberλ₯Ό κ°€μ Έμ˜€κ³  갱신함
159
+ else:
160
+ st.session_state.session_num = debate_setting[0]['session_num']
161
 
162
  def page_2_3_controller():
163
  st.session_state.page = "Page 3"
 
191
  max_chars=100,
192
  placeholder="Enter user ID"
193
  )
194
+
195
+ st.button(
 
 
 
 
 
196
  label='Submit all information',
197
  on_click=page_1_2_controller
198
+ )
199
  # You can add a function here to save the submitted info
 
 
 
 
 
 
 
200
 
201
  #########################################################
202
  # Page 2
 
234
  "THS a world where the government gives cash that individuals can use to freely select their academic preference (including but not limited to school of choice, private academies, and tutoring) instead of funding for public education.",
235
  "THW abolish all requirements and evaluation criteria in higher education (i.e., attendance, exams, assignments)."
236
  ]
 
237
  elif st.session_state.debate_theme == 'Sports':
238
  topic_list = [
239
  "THBT having star players for team sports do more harm than good to the team.",
240
  "THR the emphasis on winning a medal in the Olympics as a core symbol of success.",
241
  "THP a world where sports serves purely entertainment purposes even at the expense of fair play."
242
  ]
 
243
  elif st.session_state.debate_theme == 'Religion':
244
  topic_list = [
245
  "THW, as a religious group/leader, cease attempts at increasing the number of believers and instead prioritize boosting loyalty amongst adherents to the religion.",
246
  "Assuming feasibility, TH prefers a world where a panel of church leaders would create a universally accepted interpretation of the Bible that the believers would abide by.",
247
  "THW aggressively crackdown on megachurches."
248
  ]
 
249
  elif st.session_state.debate_theme == 'Justice':
250
  topic_list = [
251
  "In 2050, AI robots are able to replicate the appearance, conversation, and reaction to emotions of human beings. However, their intelligence still does not allow them to sense emotions and feelings such as pain, happiness, joy, and etc.",
252
  "In the case a human destroys the robot beyond repair, THW charge murder instead of property damage.",
253
  "THP a world where the criminal justice system’s role is mainly for victim’s vengeance. THW allow prosecutors and victims to veto assigned judges."
254
  ]
 
255
  elif st.session_state.debate_theme == 'Pandemic':
256
  topic_list = [
257
  "During a pandemic, THBT businesses that benefit from the pandemic should be additionally taxed.",
258
  "THW nullify the effect of medical patents in cases of medical emergencies.",
259
  "THW ban media content that denies the efficacy of the COVID-19 without substantial evidence."
260
  ]
 
261
  elif st.session_state.debate_theme == 'Politics':
262
  topic_list = [
263
  "Info: The Candle Light Will (μ΄›λΆˆλ―Όμ‹¬) is a term derived from the symbolic candle-light protests for the impeachment of the late president Park Geun Hye, commonly used to mean the people’s will to fight against corrupt governments. The Moon administration has frequently referred to the Candle Light Will as the driving force behind its election that grants legitimacy to its policies. THR the β€˜candle light will’ narrative in the political discourse of South Korea.",
264
  "THW impose a cap on the property and income of politicians.",
265
  "THW give the youth extra votes."
266
  ]
 
267
  elif st.session_state.debate_theme == 'Minority':
268
  topic_list = [
269
  "Context: A prominent member of the LGBT movement has discovered that a very influential politician helping the LGBT movement has been lying about their sexual orientation as being gay when they are straight. THW disclose this information.",
270
  "THBT the LGBTQIA+ movement should denounce the existence of marriage as opposed to fighting for equal marriage rights.",
271
  "THBT the LGBTQIA+ movement should condemn the consumption of movies and TV shows that cast straight actors/actresses in non-heterosexual identified roles."
272
  ]
 
273
  else:
274
  topic_list = [
275
  "THW remove all laws that relate to filial responsibilities.",
 
291
 
292
  st.write("3. Write 3 cases")
293
 
294
+ #########################################################
295
+ # Case도 μ„Έμ…˜μ— μ €μž₯
296
+ #########################################################
297
+ st.session_state.case1 = st.text_area(
298
  label="Case 1",
299
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
300
  height=100
301
  )
302
+ st.session_state.case2 = st.text_area(
303
  label="Case 2",
304
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
305
  height=100
306
  )
307
+ st.session_state.case3 = st.text_area(
308
  label="Case 3",
309
  placeholder="Each case should be consisted of opinion, reasoning, and example.",
310
  height=100
 
312
  case_error_message = st.empty()
313
  st.session_state.pros_and_cons = st.selectbox("Choose your Side (Pros and Cons)", ["Pros", "Cons"])
314
 
315
+ # Save the data to database
316
+ start = st.button(
317
+ label="Start Debate",
318
+ on_click=put_item(
319
+ table=dynamodb.Table('DEBO_debate_setting'),
320
+ item={
321
+ 'user_id': st.session_state.user_id,
322
+ 'time_stamp': time_stamp,
323
+ 'debate_theme': st.session_state.debate_theme,
324
+ 'debate_topic': st.session_state.topic,
325
+ 'case1': st.session_state.case1,
326
+ 'case2': st.session_state.case2,
327
+ 'case3': st.session_state.case3,
328
+ 'session_num': st.session_state.session_num,
329
+ }
330
+ )
331
+ )
332
 
333
  def validate_case(error_message):
334
+ if not st.session_state.case1 or not st.session_state.case2 or not st.session_state.case3:
335
  case_error_message.error("Please fill out above all", icon="🚨")
336
  return False
337
  else:
338
+ # st.session_state.case1 = st.session_statecase1
339
+ # st.session_state.case2 = st.session_statecase2
340
+ # st.session_state.case3 = st.session_statecase3
341
  return True
342
 
343
  if start:
 
345
  page_3_4_controller()
346
  st.experimental_rerun()
347
 
348
+ #########################################################
349
+ # Ask to GPT
350
+ #########################################################
351
  with st.sidebar:
352
  st.sidebar.title('Ask to GPT')
353
  user_input = st.sidebar.text_area(
 
362
  result = ""
363
  else:
364
  result = gpt_call(user_input)
365
+
366
+ # save user_prompt and bot_response to database
367
+ put_item(
368
+ table=dynamodb.Table('DEBO_gpt_ask'),
369
+ item={
370
+ 'user_id': st.session_state.user_id,
371
+ 'time_stamp': time_stamp,
372
+ 'user_prompt': user_input,
373
+ 'bot_response': result,
374
+ 'session_num': st.session_state.session_num,
375
+ }
376
+ )
377
+
378
  else:
379
  result = ""
380
 
 
426
  result = ""
427
  else:
428
  result = gpt_call(user_input)
429
+ put_item(
430
+ table=dynamodb.Table('DEBO_gpt_ask'),
431
+ item={
432
+ 'user_id': st.session_state.user_id,
433
+ 'time_stamp': time_stamp,
434
+ 'user_prompt': user_input,
435
+ 'bot_response': result,
436
+ 'session_num': st.session_state.session_num,
437
+ }
438
+ )
439
  else:
440
  result = ""
441
 
 
464
  st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
465
  st.session_state['bot_debate_history'].append(response)
466
 
467
+ # μ•„λž˜μ—μ„œ ν•œλ²ˆμ— μ €μž₯
468
+
469
+ # put_item(
470
+ # table=dynamodb.Table('DEBO_debate_main'),
471
+ # item={
472
+ # 'user_id': st.session_state.user_id,
473
+ # 'time_stamp': time_stamp,
474
+ # 'session_num': st.session_state.session_num,
475
+ # 'bot_response': response,
476
+ # 'user_prompt': "",
477
+ # 'turn_num': 0,
478
+ # }
479
+ # )
480
+
481
+
482
  # container for chat history
483
  response_container = st.container()
484
  # container for text box
 
501
  if submit_buttom:
502
  if audio.any():
503
  user_input = execute_stt(audio)
504
+ response = generate_response(user_input)
505
  st.session_state['pre_audio'] = audio
506
+
507
+ debate_main_latest_data = get_lastest_item(
508
+ table=dynamodb.Table('DEBO_debate_main'),
509
+ name_of_partition_key="user_id",
510
+ value_of_partition_key=st.session_state.user_id,
511
+ limit_num=1
512
+ )
513
+
514
+ if debate_main_latest_data == []:
515
+ turn_num = 0
516
+ else:
517
+ turn_num = debate_main_latest_data[0]['turn_num']
518
+
519
+ put_item(
520
+ table=dynamodb.Table('DEBO_debate_main'),
521
+ item={
522
+ 'user_id': st.session_state.user_id,
523
+ 'time_stamp': time_stamp,
524
+ 'session_num': st.session_state.session_num,
525
+ 'bot_response': response,
526
+ 'user_prompt': user_input,
527
+ 'turn_num': turn_num,
528
+ }
529
+ )
530
+
531
  else:
532
  send_error_message.error("Please record your voice first", icon="🚨")
533
  print("Nothing to transcribe")
 
598
 
599
  st.write("Debate Judgement Result")
600
  st.write(judgement_result)
601
+
602
+ if judgement_result != "":
603
+ put_item(
604
+ table=dynamodb.Table('DEBO_evaluation'),
605
+ item={
606
+ 'user_id': st.session_state.user_id,
607
+ 'time_stamp': time_stamp,
608
+ 'judgement_text': judgement_result,
609
+ 'session_num': st.session_state.session_num,
610
+ }
611
+ )
612
+
613
  st.success('Done!')
614
 
615
  with tab2:
 
647
  disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
648
  st.write("Disfluency Counts: ", disfluency_counts)
649
 
650
+ if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
651
+ put_item(
652
+ table=dynamodb.Table('DEBO_evaluation'),
653
+ item={
654
+ 'user_id': st.session_state.user_id,
655
+ 'time_stamp': time_stamp,
656
+ 'total_word_count': total_word_count,
657
+ 'average_word_per_time': average_word_per_time,
658
+ 'disfluency_counts': disfluency_counts,
659
+ 'session_num': st.session_state.session_num,
660
+ }
661
+ )
662
+
663
  # μœ μ €μ™€ λ΄‡μ˜ λŒ€ν™” 데이터가 μ„Έμ…˜μ— λ‚¨μ•„μžˆμŒ
664
  # st.session_state.debate_history
665
 
 
703
  user_debate_history,
704
  bot_debate_history
705
  )
706
+
707
+ if judgement_result != "":
708
+ put_item(
709
+ table=dynamodb.Table('DEBO_evaluation'),
710
+ item={
711
+ 'user_id': st.session_state.user_id,
712
+ 'time_stamp': time_stamp,
713
+ 'judgement_text': judgement_result,
714
+ 'session_num': st.session_state.session_num,
715
+ }
716
+ )
717
 
718
  st.write("Debate Judgement Result")
719
  st.write(judgement_result)
 
753
  disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
754
  st.write("Disfluency Counts: ", disfluency_counts)
755
 
756
+ if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
757
+ put_item(
758
+ table=dynamodb.Table('DEBO_evaluation'),
759
+ item={
760
+ 'user_id': st.session_state.user_id,
761
+ 'time_stamp': time_stamp,
762
+ 'total_word_count': total_word_count,
763
+ 'average_word_per_time': average_word_per_time,
764
+ 'disfluency_counts': disfluency_counts,
765
+ 'session_num': st.session_state.session_num,
766
+ }
767
+ )
768
+
769
  # μœ μ €μ™€ λ΄‡μ˜ λŒ€ν™” 데이터가 μ„Έμ…˜μ— λ‚¨μ•„μžˆμŒ
770
  # st.session_state.debate_history
771