codingchild commited on
Commit
f7709d8
โ€ข
1 Parent(s): 50e66ae

page 5 complete

Browse files
Files changed (3) hide show
  1. bots/judgement_bot.py +27 -0
  2. vocal_app.py +65 -8
  3. whisper_app.py +4 -0
bots/judgement_bot.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from modules.gpt_modules import gpt_call
2
+ from langchain.prompts import PromptTemplate
3
+
4
+ def debate_judgement(debate_history):
5
+
6
+ judgement_prompt = "\n".join([
7
+ "!!Instruction!",
8
+ "You are now the judge of this debate. Evaluate the debate according to the rules below.",
9
+ "Rule 1. Decide between the USER and BOT.",
10
+ "Rule 2. Summarize the debate as a whole and what each debater said.",
11
+ "Rule 3. For each debater, explain what was persuasive and what made the differnce between winning and losing.",
12
+ ])
13
+
14
+ judgement_prompt_template = PromptTemplate(
15
+ input_variables=["prompt"],
16
+ template="\n".join([
17
+ debate_history,
18
+ judgement_prompt,
19
+ "Judgement: "
20
+ ])
21
+ )
22
+ judgement_bot_prompt = judgement_prompt_template.format(
23
+ prompt=""
24
+ )
25
+ bot_response = gpt_call(judgement_bot_prompt)
26
+
27
+ return bot_response
vocal_app.py CHANGED
@@ -1,4 +1,7 @@
1
  import streamlit as st
 
 
 
2
  #import SessionState
3
 
4
  # Page Configuration
@@ -28,6 +31,15 @@ if "case3" not in st.session_state:
28
  if "page2_tab" not in st.session_state:
29
  st.session_state.page2_tab = "tab1"
30
 
 
 
 
 
 
 
 
 
 
31
 
32
  # Save function (placeholder)
33
  def save_info(user_id, openAI_token, debate_theme):
@@ -60,6 +72,10 @@ def page_2_3_controller():
60
  def page2_tab_controller():
61
  st.session_state.page2_tab = "tab2"
62
 
 
 
 
 
63
  #########################################################
64
  # Page 1
65
  #########################################################
@@ -231,17 +247,55 @@ def page4():
231
 
232
 
233
  #########################################################
234
- # Page5
235
  #########################################################
236
  def page5():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
- with st.sidebar:
239
- st.sidebar.title('Ask to GPT')
240
- st.sidebar.text_area(
241
- label="Input text here",
242
- placeholder="Input text here",
243
- height=100)
244
- st.sidebar.button("Ask")
245
 
246
 
247
  #########################################################
@@ -253,6 +307,9 @@ pages = {
253
  "Page 3": page3, # Total Debate
254
  "Page 4": page4, # Evaluation Only
255
  "Page 5": page5, # Analyzing Utterances
 
 
 
256
  }
257
 
258
  selection = st.session_state.page
 
1
  import streamlit as st
2
+ from modules.gpt_modules import gpt_call
3
+ from langchain.prompts import PromptTemplate
4
+ from bots.judgement_bot import debate_judgement
5
  #import SessionState
6
 
7
  # Page Configuration
 
31
  if "page2_tab" not in st.session_state:
32
  st.session_state.page2_tab = "tab1"
33
 
34
+ if "total_debate_history" not in st.session_state:
35
+ st.session_state.total_debate_history = ""
36
+
37
+ if "user_debate_history" not in st.session_state:
38
+ st.session_state.user_debate_history = ""
39
+
40
+ if "bot_debate_history" not in st.session_state:
41
+ st.session_state.bot_debate_history = ""
42
+
43
 
44
  # Save function (placeholder)
45
  def save_info(user_id, openAI_token, debate_theme):
 
72
  def page2_tab_controller():
73
  st.session_state.page2_tab = "tab2"
74
 
75
+
76
+ def page_5_6_controller():
77
+ st.session_state.page = "Page 6"
78
+
79
  #########################################################
80
  # Page 1
81
  #########################################################
 
247
 
248
 
249
  #########################################################
250
+ # Page5 - Total Debate Evaluation
251
  #########################################################
252
  def page5():
253
+ st.header('Debate Judgement')
254
+ # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
255
+ # st.session_state.debate_history
256
+
257
+ debate_themes = ['User-Bot', "User", "Bot"]
258
+
259
+ # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
260
+ judgement_who = st.selectbox("Choose your debate theme", debate_themes)
261
+
262
+ if judgement_who == 'User-Bot':
263
+ debate_history = st.session_state.total_debate_history
264
+ elif judgement_who == 'User':
265
+ debate_history = st.session_state.user_debate_history
266
+ elif judgement_who == 'Bot':
267
+ debate_history = st.session_state.bot_debate_history
268
+
269
+ judgement_result = debate_judgement(debate_history)
270
+
271
+ st.write("Debate Judgement Result")
272
+ st.write(judgement_result)
273
+
274
+ st.button(
275
+ label='Move to Debate Dashboard',
276
+ on_click=page_5_6_controller
277
+ )
278
+
279
+ #########################################################
280
+ # Page6
281
+ #########################################################
282
+ def page6():
283
+ pass
284
+
285
+
286
+ #########################################################
287
+ # Page7
288
+ #########################################################
289
+ def page7():
290
+ pass
291
+
292
+
293
+ #########################################################
294
+ # Page8
295
+ #########################################################
296
+ def page8():
297
+ pass
298
 
 
 
 
 
 
 
 
299
 
300
 
301
  #########################################################
 
307
  "Page 3": page3, # Total Debate
308
  "Page 4": page4, # Evaluation Only
309
  "Page 5": page5, # Analyzing Utterances
310
+ "Page 6": page6,
311
+ "Page 7": page7,
312
+ "Page 8": page8
313
  }
314
 
315
  selection = st.session_state.page
whisper_app.py CHANGED
@@ -24,6 +24,10 @@ def debate(audio):
24
  # user_words
25
  user_prompt = openai.Audio.transcribe("whisper-1", file).text
26
 
 
 
 
 
27
  # ์ผ๋‹จ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๊ณ ์ •ํ•จ
28
  debate_subject = "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."
29
 
 
24
  # user_words
25
  user_prompt = openai.Audio.transcribe("whisper-1", file).text
26
 
27
+ print("**************************************")
28
+ print("user_audio transcription", user_prompt)
29
+ print("**************************************")
30
+
31
  # ์ผ๋‹จ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๊ณ ์ •ํ•จ
32
  debate_subject = "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."
33