Spaces:
Runtime error
Runtime error
Merge remote-tracking branch 'upstream/master' into prototype_v0.1
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
import numpy as np
|
3 |
import openai
|
4 |
import pprint
|
|
|
5 |
|
6 |
from gtts import gTTS
|
7 |
from collections import Counter
|
@@ -131,7 +132,7 @@ def page_1_2_controller():
|
|
131 |
print("save info")
|
132 |
|
133 |
save_info(st.session_state.user_id)
|
134 |
-
|
135 |
|
136 |
#########################################################
|
137 |
# Session Update
|
@@ -185,10 +186,11 @@ def page1():
|
|
185 |
placeholder="Enter user ID"
|
186 |
)
|
187 |
|
188 |
-
st.button(
|
189 |
label='Submit',
|
190 |
on_click=page_1_2_controller
|
191 |
-
)
|
|
|
192 |
# You can add a function here to save the submitted info
|
193 |
|
194 |
#########################################################
|
@@ -262,6 +264,7 @@ def page4():
|
|
262 |
debate_themes = ['Education','Sports','Religion','Justice','Pandemic','Politics','Minority','etc']
|
263 |
|
264 |
st.write("1. Select a debate theme")
|
|
|
265 |
st.session_state.debate_theme = st.selectbox("Choose your debate theme", debate_themes)
|
266 |
|
267 |
if st.session_state.debate_theme == 'Education':
|
@@ -325,7 +328,7 @@ def page4():
|
|
325 |
st.write("2. Select a topic")
|
326 |
st.session_state.topic = st.selectbox("Choose your topic", topic_list)
|
327 |
|
328 |
-
st.write("3. Write 3 cases")
|
329 |
|
330 |
#########################################################
|
331 |
# Case๋ ์ธ์
์ ์ ์ฅ
|
@@ -346,7 +349,9 @@ def page4():
|
|
346 |
height=100
|
347 |
)
|
348 |
case_error_message = st.empty()
|
349 |
-
|
|
|
|
|
350 |
|
351 |
# Save the data to database
|
352 |
start = st.button(
|
@@ -418,7 +423,7 @@ def page4():
|
|
418 |
label="Answer",
|
419 |
placeholder="(Answer will be shown here)",
|
420 |
value=result,
|
421 |
-
height=
|
422 |
|
423 |
#########################################################
|
424 |
# Page5
|
@@ -479,16 +484,23 @@ def page5():
|
|
479 |
label="Answer",
|
480 |
placeholder="(Answer will be shown here)",
|
481 |
value=result,
|
482 |
-
height=
|
483 |
|
484 |
# default system prompt settings
|
485 |
if not st.session_state['total_debate_history']:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
debate_preset = "\n".join([
|
487 |
"Debate Rules: ",
|
488 |
"1) This debate will be divided into two teams, pro and con, with two debates on each team.",
|
489 |
"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.",
|
490 |
"3) Answer logically with an introduction, body, and conclusion.", #add this one.
|
491 |
-
"4) Your role : " +
|
492 |
"5) Debate subject: " + st.session_state['topic'],
|
493 |
])
|
494 |
first_prompt = "Now we're going to start. Summarize the subject and your role. And ask user ready to begin."
|
@@ -500,21 +512,6 @@ def page5():
|
|
500 |
st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
|
501 |
st.session_state['bot_debate_history'].append(response)
|
502 |
|
503 |
-
# ์๋์์ ํ๋ฒ์ ์ ์ฅ
|
504 |
-
|
505 |
-
# put_item(
|
506 |
-
# table=dynamodb.Table('DEBO_debate_main'),
|
507 |
-
# item={
|
508 |
-
# 'user_id': st.session_state.user_id,
|
509 |
-
# 'time_stamp': time_stamp,
|
510 |
-
# 'session_num': st.session_state.session_num,
|
511 |
-
# 'bot_response': response,
|
512 |
-
# 'user_prompt': "",
|
513 |
-
# 'turn_num': 0,
|
514 |
-
# }
|
515 |
-
# )
|
516 |
-
|
517 |
-
|
518 |
# container for chat history
|
519 |
response_container = st.container()
|
520 |
# container for text box
|
@@ -612,7 +609,9 @@ def page6():
|
|
612 |
# st.tab
|
613 |
st.header('Total Debate Evaluation')
|
614 |
|
615 |
-
|
|
|
|
|
616 |
|
617 |
with tab1:
|
618 |
st.header("Debate Evaluation")
|
@@ -690,15 +689,23 @@ def page6():
|
|
690 |
st.write("Disfluency Counts: ", disfluency_counts)
|
691 |
|
692 |
if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
put_item(
|
694 |
-
table=dynamodb.Table('
|
695 |
item={
|
696 |
'user_id': st.session_state.user_id,
|
697 |
'time_stamp': time_stamp,
|
698 |
'total_word_count': total_word_count,
|
699 |
-
'average_word_per_time': average_word_per_time,
|
700 |
'disfluency_counts': disfluency_counts,
|
701 |
-
'session_num': st.session_state.session_num,
|
702 |
}
|
703 |
)
|
704 |
|
|
|
2 |
import numpy as np
|
3 |
import openai
|
4 |
import pprint
|
5 |
+
from decimal import Decimal
|
6 |
|
7 |
from gtts import gTTS
|
8 |
from collections import Counter
|
|
|
132 |
print("save info")
|
133 |
|
134 |
save_info(st.session_state.user_id)
|
135 |
+
|
136 |
|
137 |
#########################################################
|
138 |
# Session Update
|
|
|
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 |
#########################################################
|
|
|
264 |
debate_themes = ['Education','Sports','Religion','Justice','Pandemic','Politics','Minority','etc']
|
265 |
|
266 |
st.write("1. Select a debate theme")
|
267 |
+
|
268 |
st.session_state.debate_theme = st.selectbox("Choose your debate theme", debate_themes)
|
269 |
|
270 |
if st.session_state.debate_theme == 'Education':
|
|
|
328 |
st.write("2. Select a topic")
|
329 |
st.session_state.topic = st.selectbox("Choose your topic", topic_list)
|
330 |
|
331 |
+
st.write("3. Write 3 cases (Note that these are just a tool to help you structure your thoughts on the content and does not reflect the actual discussion.)")
|
332 |
|
333 |
#########################################################
|
334 |
# Case๋ ์ธ์
์ ์ ์ฅ
|
|
|
349 |
height=100
|
350 |
)
|
351 |
case_error_message = st.empty()
|
352 |
+
|
353 |
+
st.write("4. Choose your Side (Pros and Cons)")
|
354 |
+
st.session_state.pros_and_cons = st.selectbox("Choose your Side", ["Pros", "Cons"])
|
355 |
|
356 |
# Save the data to database
|
357 |
start = st.button(
|
|
|
423 |
label="Answer",
|
424 |
placeholder="(Answer will be shown here)",
|
425 |
value=result,
|
426 |
+
height=400)
|
427 |
|
428 |
#########################################################
|
429 |
# Page5
|
|
|
484 |
label="Answer",
|
485 |
placeholder="(Answer will be shown here)",
|
486 |
value=result,
|
487 |
+
height=400)
|
488 |
|
489 |
# default system prompt settings
|
490 |
if not st.session_state['total_debate_history']:
|
491 |
+
|
492 |
+
# bot role, pros and cons
|
493 |
+
if st.session_state['pros_and_cons'] == "Pros":
|
494 |
+
bot_role = "Con"
|
495 |
+
else:
|
496 |
+
bot_role = "Pros"
|
497 |
+
|
498 |
debate_preset = "\n".join([
|
499 |
"Debate Rules: ",
|
500 |
"1) This debate will be divided into two teams, pro and con, with two debates on each team.",
|
501 |
"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.",
|
502 |
"3) Answer logically with an introduction, body, and conclusion.", #add this one.
|
503 |
+
"4) Your role : " + bot_role + " side debator",
|
504 |
"5) Debate subject: " + st.session_state['topic'],
|
505 |
])
|
506 |
first_prompt = "Now we're going to start. Summarize the subject and your role. And ask user ready to begin."
|
|
|
512 |
st.session_state['total_debate_history'].append({"role": "assistant", "content": response})
|
513 |
st.session_state['bot_debate_history'].append(response)
|
514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
# container for chat history
|
516 |
response_container = st.container()
|
517 |
# container for text box
|
|
|
609 |
# st.tab
|
610 |
st.header('Total Debate Evaluation')
|
611 |
|
612 |
+
st.write('Note that evaluation using GPT is an experimental feature. Please check it out and give us your feedback.')
|
613 |
+
|
614 |
+
tab1, tab2 = st.tabs(['Debate Evaluation', 'Debate Analysis'])
|
615 |
|
616 |
with tab1:
|
617 |
st.header("Debate Evaluation")
|
|
|
689 |
st.write("Disfluency Counts: ", disfluency_counts)
|
690 |
|
691 |
if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
|
692 |
+
|
693 |
+
print("user_id", type(st.session_state.user_id))
|
694 |
+
print("time_stamp", type(time_stamp))
|
695 |
+
print("total_word_count", type(total_word_count))
|
696 |
+
print("average_word_per_time", type(average_word_per_time))
|
697 |
+
print("disfluency_counts", type(disfluency_counts))
|
698 |
+
print("session_num", type(st.session_state.session_num))
|
699 |
+
|
700 |
put_item(
|
701 |
+
table=dynamodb.Table('DEBO_debate_analysis'),
|
702 |
item={
|
703 |
'user_id': st.session_state.user_id,
|
704 |
'time_stamp': time_stamp,
|
705 |
'total_word_count': total_word_count,
|
706 |
+
'average_word_per_time': Decimal(str(average_word_per_time)),
|
707 |
'disfluency_counts': disfluency_counts,
|
708 |
+
'session_num': int(st.session_state.session_num),
|
709 |
}
|
710 |
)
|
711 |
|