riyaKWK's picture
Update app.py
56abd35 verified
# ======================
# ROUND 1
# ======================
# BUG: The chatbot should respond "Hello!" to greetings (hi, hello, hey)
# and "Goodbye!" to farewells (bye, goodbye, see you)
# But it only handles greetings!
#
# import gradio as gr
#
# def greet_bot(message, history):
# user_msg = message.lower()
#
# if "hi" in user_msg or "hello" in user_msg or "hey" in user_msg:
# return "Hello!"
# # Missing: What happens when user says goodbye?
#
# chatbot = gr.ChatInterface(greet_bot, title="Greeting Bot")
# chatbot.launch()
# ======================
# ROUND 2
# ======================
# BUG: This bot should count how many times the user has sent a message
# But it's using the wrong variable!
#
# import gradio as gr
#
# def counter_bot(message, history):
# message_count = len(history) + 1
# return f"This is message number {count}!"
#
# chatbot = gr.ChatInterface(counter_bot, title="Counter Bot")
# chatbot.launch()
# ======================
# ROUND 3
# ======================
# BUG: This bot should check if ANY word in the user's message is positive
# But the return statement is in the wrong place!
# Right now it only checks the FIRST word.
#
# import gradio as gr
#
# def sentiment_bot(message, history):
# positive_words = ["good", "great", "awesome", "amazing", "love"]
# words = message.lower().split()
#
# for word in words:
# if word in positive_words:
# return "That sounds positive! 😊"
# return "Hmm, seems neutral to me."
#
# chatbot = gr.ChatInterface(sentiment_bot, title="Sentiment Bot")
# chatbot.launch()
# ======================
# BONUS: ROUND 4
# ======================
# BUG: This Magic 8 Ball should give different responses based on question type:
# - Questions with "should" β†’ advice responses
# - Questions with "will" β†’ prediction responses
# - Everything else β†’ random general responses
# But it's missing the logic to handle different question types!
#
# import gradio as gr
# import random
#
# def magic_8_ball(message, history):
# advice = ["Yes, definitely", "No way", "Think carefully"]
# predictions = ["It will happen", "Not likely", "The future is unclear"]
# general = ["Ask again later", "Maybe", "I'm not sure"]
#
# # Missing: Check what TYPE of question this is
# # Then return appropriate response from correct list
#
# return random.choice(general)
#
# chatbot = gr.ChatInterface(magic_8_ball, title="Magic 8 Ball")
# chatbot.launch()