diff --git a/ai.py b/ai.py index 4934625..6ba9604 100644 --- a/ai.py +++ b/ai.py @@ -6,9 +6,14 @@ def is_yes_or_no_question(question: str, key: str): openai.api_key = key response = openai.ChatCompletion.create( model='gpt-3.5-turbo', + logit_bias={ + 9642: 100, # Yes + 2822: 90 # No + }, + max_tokens=1, messages=[ {'role': 'system', 'content': 'You answer questions with a simple "yes" or "no".'}, - {'role': 'user', 'content': f'Can the following question be generally answered with a "yes" or "no"? \n {question}'}, + {'role': 'user', 'content': f'Is the following question a boolean question? \n {question}'}, ] ) diff --git a/examples/example.gif b/examples/example.gif index 1c5470c..6d8d34e 100644 Binary files a/examples/example.gif and b/examples/example.gif differ diff --git a/playground.py b/playground.py index adb60cc..d662420 100644 --- a/playground.py +++ b/playground.py @@ -1,12 +1,30 @@ import openai -response = openai.ChatCompletion.create( - model="gpt-3.5-turbo", - messages=[ - {"role": "system", "content": "You answer questions with a simple 'yes' or 'no'."}, - {"role": "user", "content": "Can the following question be generally answered with a 'yes' or 'no'? \n Is C# better than Java?"}, - ] -) +questions = [ + 'Is love more important than science?', + 'Should one follow emotions instead of reason?', + 'Is 3 > 2?', + 'How are you?', + 'Is Robert in today?', + 'Can you describe Robert for me?', + 'What is most important in life?', +] + +for question in questions: + response = openai.ChatCompletion.create( + model='gpt-3.5-turbo', + logit_bias={ + 9642: 100, # Yes + 2822: 90 # No + }, + max_tokens=1, + messages=[ + {'role': 'system', 'content': 'You answer questions with a simple "yes" or "no".'}, + {'role': 'user', 'content': f'Is the following question a boolean question? \n {question}'}, + ] + ) + + print(response['choices'][0]['message']['content']) # { # "choices": [ @@ -29,5 +47,3 @@ response = openai.ChatCompletion.create( # "total_tokens": 52 # } # } - -print(response)