from transformers import pipeline

Load the pre-trained model for conversational AI

chatbot = pipeline("conversational")

Define a function to interact with the chatbot

def chat_with_bot(): while True: user_input = input("User: ")

    # Exit the loop if the user says 'bye'
    if user_input.lower() == "bye":
        print("Chatbot: Goodbye!")
        break
    
    # Generate a response from the chatbot
    response = chatbot(user_input)[0]['generated_text']
    print("Chatbot:", response)

Start the conversation with the chatbot

print("Chatbot: Hello! How can I assist you?") chat_with_bot()