from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
# Create a new chat bot
chatbot = ChatBot('MyBot')
# Create a new trainer for the chat bot
trainer = ChatterBotCorpusTrainer(chatbot)
# Train the chat bot on English language data
trainer.train('chatterbot.corpus.english')
# Main chat loop
print("Hello! I'm your AI chat bot. Type 'exit' to end the conversation.")
while True:
# Get user input
user_input = input("You: ")
# Exit the chat if the user types 'exit'
if user_input.lower() == 'exit':
print("Goodbye!")
break
# Get the AI's response
response = chatbot.get_response(user_input)
# Display the AI's response
print(f"Bot: {response}")
Comments
Post a Comment