Files
ui-cviko1/notebook/cviko1_2-chatbot.ipynb
2025-02-19 22:11:03 +01:00

2.2 KiB

In [10]:
import random

no_responses = [
    "I can't answer that.",
    "I don't know, sorry.",
    "I can't understand you.",
    "Can you elaborate, please?"
]

responses = {
    "What's the weather like today?": [
        "It's sunny!",
        "It seems sunny today.",
        "Sunny."
    ],
    "What is your name?": [
        "My name is AI-CHATBOT.",
        "It's AI-CHATBOT.",
    ],
    "What's your favorite color?": [
        "It's yellow.",
        "Yellow."
    ],
    "What color is the sky?": [
        "The sky is blue.",
        "It's blue."
    ],
    "Can you talk?": [
        "No.",
        "Nope.",
        "I can't do that."
    ]
}

while True:
    message = input("> ")

    if message == "bye":
        print("< Bye")
        break
    
    if message in responses.keys():
        print("<", random.choice(responses[message]))
    else:
        print("<", random.choice(no_responses))
< My name is AI-CHATBOT.
< I can't do that.
< Nope.
< The sky is blue.
< Bye
In [ ]: