Spaces:
Runtime error
Runtime error
feat: implement 3 cases option checkbox and add data saving logic under condition
Browse files
app.py
CHANGED
@@ -265,6 +265,26 @@ def page3():
|
|
265 |
#########################################################
|
266 |
# Page 4
|
267 |
#########################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
def page4():
|
269 |
#########################################################
|
270 |
# Tab 1 - Total Debate (ํ ๋ก ์ค๋น -> ์ฐ์ต -> ํ๊ฐ)
|
@@ -354,24 +374,30 @@ def page4():
|
|
354 |
|
355 |
st.subheader("4. Cases")
|
356 |
st.caption('๐ข These are just a tool to help you structure your thoughts on the content and does not reflect the actual discussion.')
|
357 |
-
|
|
|
|
|
|
|
358 |
#########################################################
|
359 |
# Case๋ ์ธ์
์ ์ ์ฅ
|
360 |
#########################################################
|
361 |
-
|
362 |
label="Write a Case 1",
|
363 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
364 |
-
height=150
|
|
|
365 |
)
|
366 |
-
|
367 |
label="Write a Case 2",
|
368 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
369 |
-
height=150
|
|
|
370 |
)
|
371 |
-
|
372 |
label="Write a Case 3",
|
373 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
374 |
-
height=150
|
|
|
375 |
)
|
376 |
case_error_message = st.empty()
|
377 |
|
@@ -381,35 +407,25 @@ def page4():
|
|
381 |
start = st.button(
|
382 |
label="Start Debate",
|
383 |
type='primary',
|
384 |
-
on_click=
|
385 |
-
|
386 |
-
item={
|
387 |
-
'user_id': st.session_state.user_id,
|
388 |
-
'time_stamp': time_stamp,
|
389 |
-
'debate_theme': st.session_state.debate_theme,
|
390 |
-
'debate_topic': st.session_state.topic,
|
391 |
-
'case1': st.session_state.case1,
|
392 |
-
'case2': st.session_state.case2,
|
393 |
-
'case3': st.session_state.case3,
|
394 |
-
'session_num': st.session_state.session_num,
|
395 |
-
}
|
396 |
-
)
|
397 |
)
|
398 |
|
399 |
def validate_case(error_message):
|
400 |
if not st.session_state.case1 or not st.session_state.case2 or not st.session_state.case3:
|
401 |
-
|
402 |
return False
|
403 |
else:
|
404 |
-
# st.session_state.case1 = st.session_statecase1
|
405 |
-
# st.session_state.case2 = st.session_statecase2
|
406 |
-
# st.session_state.case3 = st.session_statecase3
|
407 |
return True
|
408 |
|
409 |
if start:
|
410 |
-
if
|
411 |
page_4_5_controller()
|
412 |
st.experimental_rerun()
|
|
|
|
|
|
|
|
|
413 |
|
414 |
#########################################################
|
415 |
# Ask to GPT
|
|
|
265 |
#########################################################
|
266 |
# Page 4
|
267 |
#########################################################
|
268 |
+
def store_debate_data(checked, case1, case2, case3):
|
269 |
+
if checked:
|
270 |
+
st.session_state.case1, st.session_state.case2, st.session_state.case3 = "", "", ""
|
271 |
+
if not checked:
|
272 |
+
st.session_state.case1, st.session_state.case2, st.session_state.case3 = case1, case2, case3
|
273 |
+
|
274 |
+
put_item(
|
275 |
+
table=dynamodb.Table('DEBO_debate_setting'),
|
276 |
+
item={
|
277 |
+
'user_id': st.session_state.user_id,
|
278 |
+
'time_stamp': time_stamp,
|
279 |
+
'debate_theme': st.session_state.debate_theme,
|
280 |
+
'debate_topic': st.session_state.topic,
|
281 |
+
'case1': st.session_state.case1,
|
282 |
+
'case2': st.session_state.case2,
|
283 |
+
'case3': st.session_state.case3,
|
284 |
+
'session_num': st.session_state.session_num,
|
285 |
+
}
|
286 |
+
)
|
287 |
+
|
288 |
def page4():
|
289 |
#########################################################
|
290 |
# Tab 1 - Total Debate (ํ ๋ก ์ค๋น -> ์ฐ์ต -> ํ๊ฐ)
|
|
|
374 |
|
375 |
st.subheader("4. Cases")
|
376 |
st.caption('๐ข These are just a tool to help you structure your thoughts on the content and does not reflect the actual discussion.')
|
377 |
+
checked = st.checkbox(
|
378 |
+
label="If you Don't need to write this 3 cases, Please check",
|
379 |
+
key="disabled",
|
380 |
+
)
|
381 |
#########################################################
|
382 |
# Case๋ ์ธ์
์ ์ ์ฅ
|
383 |
#########################################################
|
384 |
+
case1 = st.text_area(
|
385 |
label="Write a Case 1",
|
386 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
387 |
+
height=150,
|
388 |
+
disabled=st.session_state.disabled
|
389 |
)
|
390 |
+
case2 = st.text_area(
|
391 |
label="Write a Case 2",
|
392 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
393 |
+
height=150,
|
394 |
+
disabled=st.session_state.disabled
|
395 |
)
|
396 |
+
case3 = st.text_area(
|
397 |
label="Write a Case 3",
|
398 |
placeholder="Each case should be consisted of opinion, reasoning, and example.",
|
399 |
+
height=150,
|
400 |
+
disabled=st.session_state.disabled
|
401 |
)
|
402 |
case_error_message = st.empty()
|
403 |
|
|
|
407 |
start = st.button(
|
408 |
label="Start Debate",
|
409 |
type='primary',
|
410 |
+
on_click=store_debate_data,
|
411 |
+
args=(checked, case1, case2, case3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
)
|
413 |
|
414 |
def validate_case(error_message):
|
415 |
if not st.session_state.case1 or not st.session_state.case2 or not st.session_state.case3:
|
416 |
+
error_message.error("Please fill out above all", icon="๐จ")
|
417 |
return False
|
418 |
else:
|
|
|
|
|
|
|
419 |
return True
|
420 |
|
421 |
if start:
|
422 |
+
if checked:
|
423 |
page_4_5_controller()
|
424 |
st.experimental_rerun()
|
425 |
+
else:
|
426 |
+
if validate_case(case_error_message):
|
427 |
+
page_4_5_controller()
|
428 |
+
st.experimental_rerun()
|
429 |
|
430 |
#########################################################
|
431 |
# Ask to GPT
|