Untitled

 avatar
unknown
plain_text
2 years ago
794 B
3
Indexable
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

# Create a chatbot instance
chatbot = ChatBot('SimpleChatBot')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot on English language data
trainer.train('chatterbot.corpus.english')

# Function to get a response from the chatbot
def get_response(user_input):
    return chatbot.get_response(user_input)

# Main loop for the chat
print("Simple ChatBot: Hello! Type 'exit' to end the conversation.")
while True:
    user_input = input("You: ")
    
    if user_input.lower() == 'exit':
        print("Simple ChatBot: Goodbye!")
        break
    
    response = get_response(user_input)
    print(f"Simple ChatBot: {response}")
Editor is loading...
Leave a Comment