def get_response(intent): """Get a response for the matched intent""" if intent is not None: return random.choice(intents[intent]['responses']) else: return 'I didn\'t quite understand that. Can you try again?'
def main(): print('Welcome to the character AI bot!') while True: user_input = input('User: ') intent = match_intent(user_input) response = get_response(intent) print('Bot:', response) if intent == 'goodbye': break Character AI Bot Script
def match_intent(message): """Match the user's message to a predefined intent""" for intent, data in intents.items(): for pattern in data['patterns']: if pattern in message.lower(): return intent return None def get_response(intent): """Get a response for the matched