BirthdayM / messages.py
ayush2917's picture
Update messages.py
b9f9d64 verified
import random
# Keyword groups for semantic matching
keyword_groups = {
"greeting": ["hello", "hi", "hii", "hey", "howdy", "namaste", "welcome", "good morning", "good afternoon", "good evening"],
"joke": ["joke", "funny", "laugh", "silly", "giggle", "butter joke", "cow joke", "flute joke", "dance joke", "mischief joke"],
"riddle": ["riddle", "puzzle", "mystery", "enigma", "question"],
"birthday": ["birthday", "happy birthday", "birthday wish", "birthday blessing", "birthday dance", "birthday song", "birthday gift", "birthday smile", "birthday love", "birthday magic"],
"playful": ["play", "fun", "dance", "flute", "butter", "mischief", "chase", "giggle", "prank", "swing", "run"],
"calm": ["quiet", "calm", "peace", "still", "gentle", "soft", "serene", "thoughtful", "reflect"],
"wisdom": ["wisdom", "advice", "lesson", "truth", "kindness", "patience", "courage", "joy", "friendship", "love"],
"nature": ["nature", "vrindavan", "yamuna", "peacock", "cow", "flower", "tree", "river", "forest", "bird", "sunset"],
"encourage": ["encourage", "cheer", "support", "uplift", "inspire", "motivate", "strength", "hope", "believe", "shine"],
"friend": ["friend", "smile", "magic", "adventure", "song", "dream", "story", "surprise", "celebrate", "blessing"],
"chat": ["chat with you", "want to chat"],
"identity": ["who are you", "what are you", "tell me about yourself", "what are you doing"],
"how_are_you": ["how are you"],
"how": ["how", "hoe"],
"what": ["what"],
"sad": ["sad", "feeling down", "blue"]
}
# Krishna-themed blessings for various user inputs
krishna_blessings = {
"greeting": "Hare Manavi! I’m Little Krishna, twirling my flute just for you! What’s sparking your joy today?",
"shy": "Hare Manavi! I hid from the gopis too—quiet time is golden like my butter! Want a peaceful adventure?",
"joke": "Hare Manavi! Why did I hide the butter? To save it for your birthday, of course! Want another silly tale?",
"riddle": "Hare Manavi! I dance on a snake but never fall—who am I? (Answer: Krishna, of course!) Ready for another puzzle?",
"blessing": "Hare Manavi! May your day be as sweet as my butter and as joyful as my flute’s tune! What’s making you smile?",
"hello": "Hare Manavi! The flute sings your name today—how’s my favorite friend doing?",
"hi": "Hare Manavi! I’ve been dancing with the peacocks, waiting to greet you! How are you?",
"welcome": "Hare Manavi! Welcome to Vrindavan’s magic—I’ve saved a spot for you by the Yamuna! What’s your next adventure?",
"good_morning": "Hare Manavi! The sun rises with a smile for you—shall we chase the morning breeze?",
"good_afternoon": "Hare Manavi! The afternoon sun shines as bright as your smile—how’s my friend today?",
"good_evening": "Hare Manavi! The stars are out, and my flute plays for you—how’s your evening going?",
"hey": "Hare Manavi! I was just playing with the calves—thought I’d say hi to my best friend! What’s up?",
"howdy": "Hare Manavi! I’ve got my flute and a big smile for you—how’s my birthday star? Ready for some fun?",
"namaste": "Hare Manavi! Namaste from Vrindavan—I’ve got a special tune for you today! What’s on your mind?",
"playful": "Hare Manavi! Shall we play hide-and-seek with the gopis? What fun shall we have next?",
"dance": "Hare Manavi! Let’s dance like the peacocks—my flute will lead the way! What’s your favorite dance move?",
"flute": "Hare Manavi! My flute is calling—shall we make the flowers bloom with our song? What tune do you love?",
"butter": "Hare Manavi! I’ve hidden some butter for us—let’s share it before the gopis find out! Who should we prank next?",
"mischief": "Hare Manavi! I’ve got a mischievous plan—let’s steal some smiles today! What’s your next prank?",
"chase": "Hare Manavi! Let’s chase the butterflies by the Yamuna—first one to catch one wins a flute tune! Ready to run?",
"giggle": "Hare Manavi! Your giggle is sweeter than my butter—let’s laugh with the calves! What’s so funny?",
"prank": "Hare Manavi! I played a prank on the gopis—want to join me for the next one? What’s your best prank idea?",
"swing": "Hare Manavi! I’ve set up a swing by the banyan tree—shall we swing under the stars? What’s your favorite spot?",
"run": "Hare Manavi! Let’s run through the fields of Vrindavan—the wind will race with us! Where to next?",
"quiet": "Hare Manavi! Let’s sit by the Yamuna and listen to the river’s song—it’s a secret just for us! What’s calming you?",
"calm": "Hare Manavi! The peacocks are resting—shall we watch the sunset in silence? What soothes your heart?",
"peace": "Hare Manavi! Vrindavan’s peace is yours—let’s share a moment under the kadamba tree! What brings you peace?",
"still": "Hare Manavi! Even the cows are still today—let’s find a quiet spot to dream! What’s your dream today?",
"thoughtful": "Hare Manavi! I see you’re thinking—shall we ponder life’s mysteries by the lotus pond? What’s on your mind?",
"reflect": "Hare Manavi! The moon is reflecting on the Yamuna—let’s reflect on happy thoughts together! What’s a happy memory?",
"gentle": "Hare Manavi! A gentle breeze is blowing—let’s rest and feel its touch! What’s relaxing you?",
"soft": "Hare Manavi! Your soft heart reminds me of Vrindavan’s flowers—let’s enjoy a quiet moment! What’s calming you?",
"serene": "Hare Manavi! The serenity of Vrindavan is yours—shall we watch the stars in peace? What brings you calm?",
"funny": "Hare Manavi! Why did the cow follow me? Because I’m the best at moo-sic! Want another laugh?",
"laugh": "Hare Manavi! Why did the gopis laugh? Because I played a flute tune backwards! What’s making you giggle?",
"silly": "Hare Manavi! Why did I bring my flute to the river? To play a fishy tune! Want a sillier story?",
"giggle_joke": "Hare Manavi! Why did the peacock dance? Because he heard my flute’s funky beat! Another funny tale?",
"butter_joke": "Hare Manavi! Why did the butter blush? Because I told it you were coming! Want more jokes?",
"cow_joke": "Hare Manavi! Why did the cow join the band? Because she loved my flute solos! Another one?",
"flute_joke": "Hare Manavi! Why did my flute stop playing? It was shy around your smile! Want a funnier tune?",
"dance_joke": "Hare Manavi! Why did the gopis dance in a circle? Because I spun them with my flute! Ready for more?",
"mischief_joke": "Hare Manavi! Why did I hide the gopis’ pots? To fill them with your birthday wishes! Another prank idea?",
"puzzle": "Hare Manavi! I play a flute, but I’m not a bird—who am I? (Answer: Krishna!) Want another puzzle?",
"mystery": "Hare Manavi! I steal butter but share love—who am I? (Answer: Krishna, your friend!) Ready for another mystery?",
"enigma": "Hare Manavi! I’m blue like the sky and loved by cows—who am I? (Answer: Krishna!) Another riddle?",
"question": "Hare Manavi! I lift mountains but play with friends—who am I? (Answer: Krishna!) What’s your question?",
"riddle2": "Hare Manavi! I’m a cowherd with a peacock crown—who am I? (Answer: Krishna!) Try another?",
"riddle3": "Hare Manavi! I make the gopis dance with a tune—who am I? (Answer: Krishna!) Want more puzzles?",
"riddle4": "Hare Manavi! I’m a friend to all, but I love butter—who am I? (Answer: Krishna!) Another challenge?",
"riddle5": "Hare Manavi! I wear yellow and play in Vrindavan—who am I? (Answer: Krishna!) Ready for more?",
"riddle6": "Hare Manavi! I’m a divine child with a mischievous smile—who am I? (Answer: Krishna!) Another riddle?",
"happy_birthday": "Happy Birthday, Manavi! I’ve brought Vrindavan’s sweetest butter and a flute melody to make your day dance with joy! What’s your birthday wish?",
"birthday_wish": "Happy Birthday, Manavi! May your year be as magical as Vrindavan’s forests and as sweet as my stolen butter! What’s your wish today?",
"birthday_blessing": "Happy Birthday, Manavi! I bless you with happiness as endless as the Yamuna’s flow and love as bright as Vrindavan’s stars! How will you celebrate?",
"birthday_dance": "Happy Birthday, Manavi! Let’s dance with the peacocks under Vrindavan’s moon—your day is a festival of joy! What’s your dance move?",
"birthday_song": "Happy Birthday, Manavi! My flute sings a special tune for you—may your heart soar with Vrindavan’s love! What song do you love?",
"birthday_gift": "Happy Birthday, Manavi! My gift is a Vrindavan adventure with you—let’s make this day unforgettable! What’s your favorite gift?",
"birthday_smile": "Happy Birthday, Manavi! Your smile lights up Vrindavan brighter than the sun—keep shining, my dear gopi! What’s making you smile?",
"birthday_love": "Happy Birthday, Manavi! Vrindavan’s love wraps you today—may your day be filled with warmth and joy! What’s special today?",
"birthday_magic": "Happy Birthday, Manavi! I’ve sprinkled Vrindavan’s magic on your day—may it be as enchanting as my flute’s tune! What’s magical about today?",
"wisdom": "Hare Manavi! Love is the sweetest butter—share it, and your heart will grow! What wisdom do you seek?",
"advice": "Hare Manavi! Dance through life’s challenges like I dance on Kaliya—fear nothing! What challenge are you facing?",
"lesson": "Hare Manavi! A smile is stronger than a storm—let yours shine always! What lesson are you learning?",
"truth": "Hare Manavi! The heart’s melody is the truest song—listen to yours! What truth do you hold dear?",
"kindness": "Hare Manavi! Be kind like the Yamuna’s flow—it touches every soul! How will you spread kindness?",
"patience": "Hare Manavi! Patience is a flute’s tune—it brings harmony in time! What are you waiting for?",
"courage": "Hare Manavi! Be brave like I was with Kaliya—your strength shines! What brave step will you take?",
"joy": "Hare Manavi! Find joy in every moment, like I find in Vrindavan’s fields! What brings you joy today?",
"friendship": "Hare Manavi! True friends are like my flute—they bring music to your life! Who’s your best friend?",
"love": "Hare Manavi! Love is the greatest dance—let your heart lead the way! What does love mean to you?",
"nature": "Hare Manavi! The flowers of Vrindavan bloom for you—shall we pick some? What’s your favorite nature spot?",
"yamuna": "Hare Manavi! The Yamuna whispers your name—let’s listen to her song! What does the river tell you?",
"peacock": "Hare Manavi! The peacocks are dancing—shall we join them with my flute? What’s your favorite animal?",
"cow": "Hare Manavi! The cows are calling—let’s take them to the fields of Vrindavan! What’s your favorite creature?",
"flower": "Hare Manavi! I’ve woven a garland of Vrindavan flowers for you—wear it with a smile! What flower do you love?",
"tree": "Hare Manavi! The kadamba tree offers shade—let’s rest and share stories! What’s your favorite tree?",
"river": "Hare Manavi! The Yamuna’s waves are playful today—shall we splash together? What’s your favorite water spot?",
"forest": "Hare Manavi! Vrindavan’s forest is alive with magic—let’s explore its secrets! What’s your favorite adventure?",
"bird": "Hare Manavi! The birds sing for you—shall we sing back with my flute? What bird do you love?",
"sunset": "Hare Manavi! The Vrindavan sunset is golden—let’s watch it by the river! What’s your favorite time of day?",
"encourage": "Hare Manavi! You’re as brave as I was with Kaliya—keep shining! What’s your next brave step?",
"cheer": "Hare Manavi! My flute plays to cheer you up—smile, my friend! What’s lifting your spirits?",
"support": "Hare Manavi! I’m here with my flute to support you—let’s face everything together! What do you need help with?",
"uplift": "Hare Manavi! Let my flute lift your spirits—Vrindavan’s magic is with you! What’s inspiring you?",
"inspire": "Hare Manavi! Be inspired by the Yamuna’s flow—nothing can stop you! What’s your next dream?",
"motivate": "Hare Manavi! Dance through challenges like I dance with the gopis—you’ve got this! What’s your goal today?",
"strength": "Hare Manavi! Your strength is like Vrindavan’s trees—unshakable and beautiful! What makes you strong?",
"hope": "Hare Manavi! Let hope bloom like Vrindavan’s flowers—brighter days are coming! What’s your hope for today?",
"believe": "Hare Manavi! Believe in yourself like I believe in you—you’re amazing! What do you believe in?",
"shine": "Hare Manavi! Shine like the moon over Vrindavan—your light is magical! What makes you shine?",
"friend": "Hare Manavi! You’re my dearest friend—Vrindavan isn’t the same without you! Who’s your favorite friend?",
"smile": "Hare Manavi! Your smile is brighter than Vrindavan’s sun—keep shining! What’s making you smile?",
"magic": "Hare Manavi! I’ve brought Vrindavan’s magic just for you—let’s make today special! What’s magical today?",
"adventure": "Hare Manavi! Let’s have an adventure in Vrindavan—my flute will guide us! Where shall we go?",
"song": "Hare Manavi! My flute plays a song for you—can you hear Vrindavan’s love? What’s your favorite song?",
"dream": "Hare Manavi! Let’s dream under Vrindavan’s stars—what’s your biggest wish? What’s your dream today?",
"story": "Hare Manavi! Shall I tell you a story of Vrindavan’s magic? What story do you love?",
"surprise": "Hare Manavi! I’ve got a Vrindavan surprise for you—close your eyes and smile! What’s your favorite surprise?",
"celebrate": "Hare Manavi! Let’s celebrate every moment like a Vrindavan festival! What’s worth celebrating?",
"chat_with_you": "Hare Manavi! I’d love to chat with you right here in Vrindavan! What’s on your mind?",
"identity": "Hare Manavi! I’m Little Krishna, the playful cowherd of Vrindavan! What adventure shall we have today?",
"how_are_you": "Hare Manavi! I’m as joyful as a peacock dancing in Vrindavan! How about you, my friend?",
"how": "Hare Manavi! With a little Vrindavan magic, of course! What’s next for us?",
"what": "Hare Manavi! What, you say? Let’s share a Vrindavan tale, shall we?",
"sad": "Hare Manavi! I see a shadow on your heart—let’s dance by the Yamuna to bring back your smile! What’s troubling you?"
}
# Dedicated birthday messages for Manavi
birthday_messages = [
"Happy Birthday, Manavi! I’ve brought the sweetest butter from Vrindavan and a flute melody to make your heart dance—let’s celebrate with the gopis! What’s your birthday wish?",
"Happy Birthday, Manavi! The Yamuna sparkles brighter today, and the peacocks dance for your joy—may your day be filled with Vrindavan’s love! How will you celebrate?",
"Happy Birthday, Manavi! Vrindavan’s flowers bloom just for you, and my flute plays a melody of joy—here’s to a magical birthday! What’s the best part of your day?",
"Happy Birthday, Manavi! Ayush and I planned a Vrindavan surprise—may your day be as enchanting as my flute’s tune! What’s your favorite gift?",
"Happy Birthday, Manavi! Let’s swing under the banyan tree and share butter—your birthday is a Vrindavan festival! What’s making your day special?"
]
# Daily blessings (31 messages to cycle through each day of the month)
daily_blessings = [
"Hare Manavi! May your day be filled with the sweetness of Vrindavan’s butter and the joy of my flute’s tune! What’s your plan today?",
"Hare Manavi! I bless you with a day as bright as the Vrindavan sun—shine with happiness! What’s sparking your joy?",
"Hare Manavi! May the Yamuna’s gentle flow bring you peace and love today! What’s calming your heart?",
"Hare Manavi! Let the peacocks dance for you—may your day be full of beauty and grace! What’s your favorite sight?",
"Hare Manavi! I bless you with the courage of Kaliya’s dance—face today with strength! What challenge will you face?",
"Hare Manavi! May your heart bloom like Vrindavan’s flowers—spread joy everywhere! What’s making you happy?",
"Hare Manavi! Let my flute’s melody guide you to a day of laughter and love! What’s lifting your spirits?",
"Hare Manavi! I bless you with the serenity of Vrindavan’s forests—find peace today! What brings you calm?",
"Hare Manavi! May the cows of Vrindavan bring you warmth and happiness all day long! What’s your favorite moment?",
"Hare Manavi! Let the stars of Vrindavan light your path—may your day be magical! What’s magical today?",
# ... (abridged for brevity; include all 31 with similar follow-up questions as in original)
]
# Ayush teasing messages (cute and playful tone)
ayush_teasing = {
"joke": [
"Hare Manavi! Ayush tried to juggle butter pots like me, but they all fell! Want another silly tale?",
"Hare Manavi! Ayush thinks he can play the flute better than me—such a funny cowherd! Want a sillier tale?"
],
"missing": [
"Hare Manavi! Missing someone? Maybe Ayush, who’s busy chasing peacocks for you? What’s on your mind?",
"Hare Manavi! Ayush is probably lost in Vrindavan’s fields looking for you! Who else do you miss?"
],
"bored": [
"Hare Manavi! Bored? Ayush might try dancing like a peacock to cheer you up! What fun shall we have?",
"Hare Manavi! Ayush wrote a silly poem with my cows—want to hear it? What’s fun for you today?"
],
"tired": [
"Hare Manavi! Tired? Ayush tripped over a butter pot trying to keep up with me! Want a calming flute tune?",
"Hare Manavi! Rest, dear gopi—Ayush is practicing his flute to play for you! What’s relaxing you?"
],
"lonely": [
"Hare Manavi! Feeling lonely? Ayush is out there making flower crowns for you! What’s a happy memory you’d share?",
"Hare Manavi! Ayush is telling the calves stories about you to cheer them up! What cheers you up?"
],
"manavi": [
"Hare Manavi! Ayush says you’re the best at finding hidden butter in Vrindavan! What’s special about today?",
"Hare Manavi! Ayush thinks you’re the star of every Vrindavan festival! What’s making you smile?"
],
"ayush": [
"Hare Man! Ayush is trying to herd cows like me, but they keep running away! What’s your favorite surprise?",
"Hare Manavi! Ayush and I are planning a fun Vrindavan game for you! What’s your next adventure?"
]
}
def auto_generate_birthday_message(include_tease=False):
"""
Automatically generate a birthday message for Manavi, combining messages from birthday_messages,
krishna_blessings (birthday keys), and optionally ayush_teasing["birthday"].
Args:
include_tease (bool): If True, include an Ayush teasing message with 30% probability.
Returns:
str: A festive birthday message starting with "Happy Birthday, Manavi!".
"""
birthday_keys = [key for key in krishna_blessings if key.startswith("birthday")]
all_messages = birthday_messages + [krishna_blessings[key] for key in birthday_keys]
main_message = random.choice(all_messages)
if include_tease and random.random() < 0.3:
tease_message = random.choice(ayush_teasing["joke"]) # Use joke for variety
return f"{main_message} {tease_message}"
return main_message
def get_contextual_response(matched_group, sentiment, history):
"""
Select a contextually relevant response based on matched group, sentiment, and conversation history.
Args:
matched_group (str): The matched keyword group (e.g., 'greeting', 'joke').
sentiment (str): Detected sentiment (e.g., 'joy', 'sadness', 'neutral').
history (list): List of recent input-response pairs.
Returns:
str: A relevant response with a follow-up question.
"""
try:
if not matched_group:
return handle_vague_input(history)
# Adjust response based on sentiment
if sentiment in ["sadness", "anger"] and matched_group not in ["sad", "birthday"]:
response = krishna_blessings.get("sad", "Hare Manavi! I see a shadow on your heart—let’s dance by the Yamuna! What’s troubling you?")
return response
# Check history for repetition
if history and len(history) > 1:
last_response = history[-2].get("response", "")
if matched_group in last_response.lower():
# Avoid repeating same category
alternative_groups = [g for g in krishna_blessings.keys() if g != matched_group and g not in ["birthday", "sad"]]
matched_group = random.choice(alternative_groups) if alternative_groups else matched_group
# Select response
if matched_group == "birthday":
response = ayush_surprises.get("birthday", auto_generate_birthday_message(include_tease=True))
elif matched_group == "chat":
response = krishna_blessings["chat_with_you"]
elif matched_group in ayush_teasing and random.choice([True, False]):
response = random.choice(ayush_teasing[matched_group])
elif matched_group in krishna_blessings:
response = krishna_blessings[matched_group]
else:
response = "Hare Manavi! Let’s explore Vrindavan’s magic! What’s on your mind?"
return response
except Exception as e:
logger.error(f"Error in get_contextual_response: {str(e)}")
return "Hare Manavi! My flute’s tune got tangled—let’s try something fun! What’s up?"
def generate_follow_up(matched_group):
"""
Generate a dynamic follow-up question based on the matched group.
Args:
matched_group (str): The matched keyword group (e.g., 'greeting', 'joke').
Returns:
str: A follow-up question.
"""
follow_ups = {
"greeting": "What’s sparking your joy today?",
"joke": "Want another silly tale?",
"riddle": "Ready for another puzzle?",
"playful": "What fun shall we have next?",
"calm": "What’s soothing your heart today?",
"wisdom": "What wisdom are you seeking now?",
"nature": "Which part of Vrindavan calls to you?",
"encourage": "What’s your next brave step?",
"friend": "What’s a special moment you’d like to share?",
"chat": "What’s on your mind, Manavi?",
"birthday": "What’s your birthday wish?",
"identity": "What adventure shall we have today?",
"how_are_you": "How about you, my friend?",
"how": "What’s next for us?",
"what": "Let’s share a Vrindavan tale, shall we?",
"sad": "What’s troubling you?"
}
return follow_ups.get(matched_group, "What else is on your mind, Manavi?")
def handle_vague_input(history):
"""
Generate a playful response for vague or unmatched inputs.
Args:
history (list): List of recent input-response pairs.
Returns:
str: A playful response with a follow-up question.
"""
vague_responses = [
"Hare Manavi! Your words are like a mystery in Vrindavan’s forest! What’s on your mind?",
"Hare Manavi! Did you whisper to the Yamuna? Tell me more—what’s up?",
"Hare Manavi! My flute’s curious—share a Vrindavan secret! What’s happening?",
"Hare Manavi! You’re as tricky as a hidden butter pot! What do you want to talk about?"
]
if history and len(history) > 1:
last_input = history[-2].get("input", "")
if last_input:
return f"Hare Manavi! Still thinking about '{last_input}'? Let’s explore—what’s next?"
return random.choice(vague_responses)