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)