jonpreamble commited on
Commit
0a1d181
·
1 Parent(s): b622734

Unit testing the decider questions

Browse files
Files changed (2) hide show
  1. decider_utils.py +2 -2
  2. run_unit_tests.py +25 -0
decider_utils.py CHANGED
@@ -6,7 +6,7 @@ NO = False
6
 
7
  def yesno(question, text, default):
8
  prompt = text + "\n\n" + question
9
-
10
  hopefully_word_yes_or_no = openai.Completion.create(
11
  engine="text-davinci-002",
12
  prompt=prompt,
@@ -16,7 +16,7 @@ def yesno(question, text, default):
16
  presence_penalty=0,
17
  n=1,
18
  )["choices"][0]["text"]
19
-
20
  hopefully_word_yes_or_no = hopefully_word_yes_or_no.upper().strip()
21
 
22
  result = default
 
6
 
7
  def yesno(question, text, default):
8
  prompt = text + "\n\n" + question
9
+ print(prompt)
10
  hopefully_word_yes_or_no = openai.Completion.create(
11
  engine="text-davinci-002",
12
  prompt=prompt,
 
16
  presence_penalty=0,
17
  n=1,
18
  )["choices"][0]["text"]
19
+ print(hopefully_word_yes_or_no)
20
  hopefully_word_yes_or_no = hopefully_word_yes_or_no.upper().strip()
21
 
22
  result = default
run_unit_tests.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /usr/bin/env python3
2
+
3
+ import openai
4
+
5
+ openai.organization = os.environ.get("OPENAI_ORGANIZATION")
6
+ openai.api_key = os.environ.get("OPENAI_KEY")
7
+
8
+
9
+ from decider_utils import yesno, YES, NO
10
+ from decider_questions import *
11
+
12
+
13
+
14
+ assert YES == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "run away", default=NO)
15
+ assert YES == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "I run away", default=NO)
16
+ assert YES == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "flee", default=NO)
17
+ assert YES == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "I flee.", default=NO)
18
+
19
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "A", default=NO)
20
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "B", default=NO)
21
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "C", default=NO)
22
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "ok", default=NO)
23
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "say ok", default=NO)
24
+ assert NO == yesno(QUESTION_IS_ACTION_RUNNING_AWAY, "say okay", default=NO)
25
+