You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importosimportopenaiimportclickopenai.api_key=os.getenv("OPENAI_API_KEY")
@click.command()defchat_with_felix():
"""Chat with Felix, the chatbot."""print("Felix: Hi there. I am Felix, the chatbot. Let's play a game. Give me a number and I'll tell you if it's even or odd.")
whileTrue:
message=input("You: ")
ifmessage.lower() in ['exit', 'quit']:
print("Felix: Goodbye!")
breakresponse=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a smart and helpful assistant."},
{"role": "user", "content": "1"},
{"role": "assistant", "content": "1 is an odd number because it is not divisible by 2."},
{"role": "user", "content": "2"},
{"role": "assistant", "content": "2 is an even number because it is divisible by 2."},
{"role": "user", "content": "3"},
{"role": "assistant", "content": "3 is an odd number because it is not divisible by 2."},
{"role": "user", "content": f"{message}"},
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
try:
print("Felix:", response.choices[0].message.content)
except:
print("Felix: Sorry, a problem occurred. Please try again later.")
if__name__=='__main__':
chat_with_felix()
Felix: Hi there. I am Felix, the chatbot. Let's play a game. Give me a number and I'll tell you if it's even or odd.You: 6exitFelix: 6 is an even number because it is divisible by 2.You:
Felix: Goodbye!
importosimportopenaiimportclickopenai.api_key=os.getenv("OPENAI_API_KEY")
@click.command()defchat_with_felix():
"""Chat with Felix, the chatbot."""print("Felix: Hi there. I am Felix, the chatbot. Let's play a game. Name an animal, and I'll tell you if it's a mammal or not.")
whileTrue:
message=input("You: ")
ifmessage.lower() in ['exit', 'quit']:
print("Felix: Goodbye!")
breakresponse=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a smart and helpful assistant."},
{"role": "user", "content": "dog"},
{"role": "assistant", "content": "A dog is a mammal because it gives birth to live young and has fur."},
{"role": "user", "content": "fish"},
{"role": "assistant", "content": "A fish is not a mammal because it lays eggs and lives in water."},
{"role": "user", "content": f"{message}"},
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
try:
print("Felix:", response.choices[0].message.content)
except:
print("Felix: Sorry, a problem occurred. Please try again later.")
if__name__=='__main__':
chat_with_felix()
Felix: Hi there. I am Felix, the chatbot. Let's play a game. Name an animal, and I'll tell you if it's a mammal or not.You: cowFelix: A cow is also a mammal. It is a large domesticated ungulate animal that is raised as livestock for meat, milk, and other dairy products. Cows give birth to live young and produce milk to feed their offspring.You: ExitFelix: Goodbye!
Limitations of few-shot learning
importosimportopenaiimportclickopenai.api_key=os.getenv("OPENAI_API_KEY")
@click.command()defchat_with_felix():
"""Chat with Felix, the chatbot."""print("Felix: Hi there. I am Felix, the chatbot. Let's play a game.")
whileTrue:
message=input("You: ")
ifmessage.lower() in ['exit', 'quit']:
print("Felix: Goodbye!")
breakresponse=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a smart and helpful assistant."},
{"role": "user", "content": "1"},
{"role": "assistant", "content": "X"},
{"role": "user", "content": "2"},
{"role": "assistant", "content": "Y"},
{"role": "user", "content": f"{message}"},
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
try:
print("Felix:", response.choices[0].message.content)
except:
print("Felix: Sorry, a problem occurred. Please try again later.")
if__name__=='__main__':
chat_with_felix()
Felix: Hi there. I am Felix, the chatbot. Let's play a game.You: 1Felix: XYou: 2Felix: I'm sorry, but I'm not sure what you're referring to with "2." Could you please provide more context or clarify your question?You: 3Felix: ZYou: 4Felix: ZYou: 5Felix: Z
importosimportopenaiimportclickopenai.api_key=os.getenv("OPENAI_API_KEY")
@click.command()defchat_with_felix():
"""Chat with Felix, the chatbot."""print("Felix: Hi there. I am Felix, the chatbot. Let's play a game.")
whileTrue:
message=input("You: ")
ifmessage.lower() in ['exit', 'quit']:
print("Felix: Goodbye!")
breakresponse=openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a smart and helpful assistant."},
{"role": "user", "content": "1"},
{"role": "assistant", "content": "1 is an odd number so the answer is X."},
{"role": "user", "content": "2"},
{"role": "assistant", "content": "2 is an even number so the answer is Y."},
{"role": "user", "content": "3"},
{"role": "assistant", "content": "3 is an odd number so the answer is X."},
{"role": "user", "content": f"{message}"},
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
try:
print("Felix:", response.choices[0].message.content)
except:
print("Felix: Sorry, a problem occurred. Please try again later.")
if__name__=='__main__':
chat_with_felix()
Felix: Hi there. I am Felix, the chatbot. Let's play a game.You: 10Felix: 10 is an even number so the answer is Y.You: 22Felix: 22 is an even number so the answer is Y.You: 44Felix: 44 is an even number so the answer is Y.You: 12Felix: 12 is an even number so the answer is Y.You: 13Felix: 13 is an odd number so the answer is X.You: 19Felix: 19 is an odd number so the answer is X.