Unggi commited on
Commit
38840ef
1 Parent(s): 1bae996

debate bot prototype 1 complete

Browse files
Files changed (1) hide show
  1. bots/debate_bot.py +137 -3
bots/debate_bot.py CHANGED
@@ -228,23 +228,139 @@ def debate_bot(prompt, history="", debate_subject="", bot_role="", history_num=0
228
 
229
  # Answer and Ask Judgement.
230
  if history_num == 1:
 
 
 
 
 
 
 
 
231
  print("history1: ", history)
232
 
233
  # user가 가장 첫번째로 답변했다면, 봇이 2, 3, 4 답변을 하고, 평가할지를 물어보면 됨.
234
  if "User debate role: first debater for the pro side" in history:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
236
- bot_response = ask_judgement
 
 
 
 
 
 
 
 
237
 
238
  # user가 두번째로 답변했다면, 봇이 3, 4 번째 답변을 하고, 평가할지를 물어보면 됨.
239
  elif "User debate role: first debater for the con side" in history:
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
242
- bot_response = ask_judgement
 
 
 
 
 
 
243
 
244
  # user가 세번째로 답변했다면, ���이 4 번째 답변을 하고, 평가할지를 물어보면 됨.
245
  elif "User debate role: second debater for the pro side" in history:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
247
- bot_response = ask_judgement
 
 
 
 
248
 
249
  # user가 네번째로 답변했다면, 바로 평가할지를 물어보면 됨.
250
  elif "User debate role: second debater for the con side" in history:
@@ -263,5 +379,23 @@ def debate_bot(prompt, history="", debate_subject="", bot_role="", history_num=0
263
  "Rule 3. For each debater, explain what was persuasive and what made the differnce between winning and losing.",
264
  ])
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
267
  return bot_response
 
228
 
229
  # Answer and Ask Judgement.
230
  if history_num == 1:
231
+
232
+ debate_role = [
233
+ "first debater for the pro side",
234
+ "first debater for the con side",
235
+ "second debater for the pro side",
236
+ "second debater for the con side"
237
+ ]
238
+
239
  print("history1: ", history)
240
 
241
  # user가 가장 첫번째로 답변했다면, 봇이 2, 3, 4 답변을 하고, 평가할지를 물어보면 됨.
242
  if "User debate role: first debater for the pro side" in history:
243
+
244
+ # second
245
+ second_prompt_template = PromptTemplate(
246
+ input_variables=["prompt"],
247
+ template="\n".join([
248
+ history,
249
+ "User: {prompt}",
250
+ debate_role[2] + ": "
251
+ ])
252
+ )
253
+ second_bot_prompt = second_prompt_template.format(
254
+ prompt=prompt
255
+ )
256
+ second_response = gpt_call(second_bot_prompt)
257
+
258
+
259
+ # third
260
+ third_prompt_template = PromptTemplate(
261
+ input_variables=["prompt"],
262
+ template="\n".join([
263
+ history,
264
+ "User: {prompt}",
265
+ debate_role[2] + ": "
266
+ ])
267
+ )
268
+ third_bot_prompt = third_prompt_template.format(
269
+ prompt=prompt
270
+ )
271
+ third_response = gpt_call(third_bot_prompt)
272
+
273
+ # fourth
274
+ fourth_prompt_template = PromptTemplate(
275
+ input_variables=["prompt"],
276
+ template="\n".join([
277
+ history,
278
+ "User: {prompt}",
279
+ debate_role[3] + ": "
280
+ ])
281
+ )
282
+ fourth_bot_prompt = fourth_prompt_template.format(
283
+ prompt=prompt
284
+ )
285
+ fourth_response = gpt_call(fourth_bot_prompt)
286
+
287
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
288
+ bot_response = "\n".join([
289
+ "[first debater for the con side]: " + "\n" + second_response + "\n",
290
+ "-----------------------------------------------------------------",
291
+ "[second debater for the pro sid]: " + "\n" + third_response + "\n",
292
+ "-----------------------------------------------------------------",
293
+ "[second debater for the con side]: " + "\n" + fourth_response + "\n",
294
+ "-----------------------------------------------------------------",
295
+ ask_judgement
296
+ ])
297
 
298
  # user가 두번째로 답변했다면, 봇이 3, 4 번째 답변을 하고, 평가할지를 물어보면 됨.
299
  elif "User debate role: first debater for the con side" in history:
300
 
301
+ # third
302
+ third_prompt_template = PromptTemplate(
303
+ input_variables=["prompt"],
304
+ template="\n".join([
305
+ history,
306
+ "User: {prompt}",
307
+ debate_role[2] + ": "
308
+ ])
309
+ )
310
+ third_bot_prompt = third_prompt_template.format(
311
+ prompt=prompt
312
+ )
313
+ third_response = gpt_call(third_bot_prompt)
314
+
315
+ # fourth
316
+ fourth_prompt_template = PromptTemplate(
317
+ input_variables=["prompt"],
318
+ template="\n".join([
319
+ history,
320
+ "User: {prompt}",
321
+ debate_role[2] + ": " + third_response,
322
+ debate_role[3] + ": "
323
+ ])
324
+ )
325
+ fourth_bot_prompt = fourth_prompt_template.format(
326
+ prompt=prompt
327
+ )
328
+ fourth_response = gpt_call(fourth_bot_prompt)
329
+
330
+ # ask_judgement
331
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
332
+ bot_response = "\n".join([
333
+ "[second debater for the pro sid]: " + "\n" + third_response + "\n",
334
+ "-----------------------------------------------------------------",
335
+ "[second debater for the con side]: " + "\n" + fourth_response + "\n",
336
+ "-----------------------------------------------------------------",
337
+ ask_judgement
338
+ ])
339
 
340
  # user가 세번째로 답변했다면, ���이 4 번째 답변을 하고, 평가할지를 물어보면 됨.
341
  elif "User debate role: second debater for the pro side" in history:
342
+
343
+ fourth_prompt_template = PromptTemplate(
344
+ input_variables=["prompt"],
345
+ template="\n".join([
346
+ history,
347
+ "User: {prompt}",
348
+ debate_role[3] + ": "
349
+ ])
350
+ )
351
+ fourth_bot_prompt = fourth_prompt_template.format(
352
+ prompt=prompt
353
+ )
354
+ fourth_response = gpt_call(fourth_bot_prompt)
355
+
356
+
357
+
358
  ask_judgement = "Do you want to be the judge of this debate? (If you want, enter any words.)"
359
+ bot_response = "\n".join([
360
+ "[second debater for the con side]: " + "\n" + fourth_response + "\n",
361
+ "-----------------------------------------------------------------",
362
+ ask_judgement
363
+ ])
364
 
365
  # user가 네번째로 답변했다면, 바로 평가할지를 물어보면 됨.
366
  elif "User debate role: second debater for the con side" in history:
 
379
  "Rule 3. For each debater, explain what was persuasive and what made the differnce between winning and losing.",
380
  ])
381
 
382
+ judgement_prompt_template = PromptTemplate(
383
+ input_variables=["prompt"],
384
+ template="\n".join([
385
+ history,
386
+ "{prompt}",
387
+ judgement_word_list,
388
+ "Judgement: "
389
+ ])
390
+ )
391
+ judgement_bot_prompt = judgement_prompt_template.format(
392
+ prompt=""
393
+ )
394
+ judgement_response = gpt_call(judgement_bot_prompt)
395
+
396
+ bot_response = "\n".join([
397
+ "[Judgement]: " + "\n" + judgement_response + "\n",
398
+ ])
399
+
400
 
401
  return bot_response