DEV Community

parmarjatin4911@gmail.com
parmarjatin4911@gmail.com

Posted on

ChatGPT Chatbot

ChatGPT Chatbot

import openai

def chatbot(prompt):
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = [{'role': 'user', 'content': prompt}],
)
return response['choices'][0]['message']['content']

if name == "main":
while True:
user_input = input("You: ")
if user_input.lower() in ["exit", "quit"]:
break
print("Bot: ", chatbot(user_input))

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay