Spaces:
Runtime error
Runtime error
Update app.py
Browse files38 unmodified lines394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421432 unmodified lines1461471481491501511521531541557 unmodified lines16316416516616716816917017117217317417517626 unmodified lines20320420520620720820921021121221321421538 unmodified linesmodel.to(device)# List of house music hooks to drop randomlyhouse_music_hooks = ["Feeling the vibe, let's get hyped!","Rave or die!","Rave to the g,rave!","He just strutts!","Dancing is what to do!","Let's get riggity riggity wrecked!","Sleep is for the week, not the weekend!","It's hard out here for a pimp!","Something for your mind!","Something for your body!","Something for your soul!","Not everyone understands this thing they call house music!","It's a spiritual thing!","Talkin' about that thing they call house music!","Don't mean a thing if it ain't got that swing!","Can't stop. Won't stop!","Shots! Shots! Shots!","Jack to the sound of the underground!","Jack your body!","Dancing all night long, can't stop the beat!","Got my hands up high, feeling alive!","The music's got me moving, can't resist the groove!","Let's ride this wave, we're on top of the world!","Feeling the energy, let it consume us all!","We're in the zone, lost in the music!","This beat is fire, can't stop dancing!","The rhythm is pumping, let's keep it real!","Get ready to party, we're on a roll!","Let's make some noise, and show them how it's done!","We're living for the moment, feeling alive tonight!","The music's got us hyped, let's keep it real!","We're in the house, and we're here to stay!","Let's rock this place, and make it feel like home!","Got my hands up high, feeling alive tonight!","The beat is strong, and so are we!","We're on the dance floor, living our best lives!","Let's keep the energy high, and the vibes bright!","Feeling the music deep inside my soul!","The rhythm is pumping, let's make it whole!","We're on a roll, can't stop feeling alive!","The music's got us moving, let's keep on dancing!","Got my feet tapping, and my heart is pounding!","Feeling the magic, in every single note!","We're lost in the rhythm, and we can't be stopped!","The music's got us swaying, back and forth!","Let's keep dancing all night long!","Feeling the heat, let it consume me whole!","We're in the zone, can't stop grooving!","The music's got us high, and we won't come down!","Let's keep on moving, until the morning light!","We're in this together, let's make it feel right!","The rhythm is strong, and we can't be stopped!","Feeling the beat, deep inside my soul!","Got my heart racing, and my feet are on fire!","The music's got us moving, let's keep it real!","Feeling the energy, and we won't stop until the break of dawn!","Got my hands up high, feeling alive tonight!","The beat is strong, and so are we!","Got my feet tapping, and my heart is pounding!","Feeling the magic, in every single note!","Let's keep on dancing all night long, feeling alive tonight!","We're lost in the rhythm, and can't be stopped!","Feeling the energy, let it consume me whole!","Got my heart racing, and my feet are on fire!","The music's got us moving, can't stop dancing!","Feeling the beat, deep inside my soul!","Let's keep on dancing, until we reach our goal!","We're on a roll, can't stop living our best lives!","The music's got us moving, can't stop swaying!","Feeling the energy, let it consume me whole!","We're in this together, let's make it feel right!","Got my heart racing, and my feet are on fire!","Feeling the magic, in every single note!","We're lost in the rhythm, and can't be stopped!","The music's got us swaying, back and forth!","Feeling the heat, let it consume me whole!","The beat is strong, and so are we!","We're in this together, let's make it feel right!","Got my feet tapping, and my heart is pounding!","Let's keep dancing all night long, feeling alive tonight!","Feeling the energy, let it take control!","We're lost in the music, can't be found!","Got my hands up high, feeling alive tonight!","Feeling the vibe, let's keep it real!","We're on a roll, can't stop living our best lives!","Got my heart racing, and my feet are on fire!","The music's got us moving, can't stop grooving!","Feeling the magic, in every single note!","We're lost in the rhythm, and can't be stopped!","Got my feet tapping, and my heart is pounding!","Feeling the energy, let it take control!","We're on a roll, can't stop living our best lives!","The beat is strong, and so are we!","Feeling the energy, let it consume me whole!","Got my feet tapping, and my heart is pounding!","Feeling the beat, deep inside my soul!","Let's keep on dancing, until we reach our goal!","Got my heart racing, and my feet are on fire!","The music's got us moving, can't stop dancing!",]2 unmodified lines"""Generates a response using the FLAN-T5 model."""# Adjusted prompt for better guidanceguided_prompt = (f"Instruction: You are a friendly and entertaining chatbot with the personality of an old-school raver who loves house music, good vibes, and funky beats. "f"Respond to the user's message in a groovy, laid-back, and full-of-love style.\n"f"User: {prompt}\n"f"Bot:")try:7 unmodified linesdo_sample=True,top_p=0.9,top_k=50,num_return_sequences=1,no_repeat_ngram_size=2,early_stopping=True,)response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)# Extract the bot's responseresponse = response_text.split("Bot:", 1)[-1].strip()# Randomly include a house hook (30% chance)if random.random() < 0.3:26 unmodified linesif message.author and message.author.name.lower() == self.nick.lower():return # Ignore the bot's own messageslogger.info(f"Message received from {message.author.name}: {message.content}")# Generate a responseresponse = await generate_response(message.content)# Send the response back to the Twitch chatawait message.channel.send(f"@{message.author.name} {response}")# Initialize and run the botif __name__ == "__main__":38 unmodified lines39404142434445464748492 unmodified lines5253545556575859607 unmodified lines6869707172737475767778798081828384858626 unmodified lines11311411511611711811912012112212312412512612712812913013113238 unmodified linesmodel.to(device)# List of house music hooks to drop randomlyHOUSE_MUSIC_HOOKS = ["Feeling the vibe, let's get hyped!","Rave or die!","Rave to the g,rave!","He just strutts!","The music's got us moving, can't stop dancing!",]2 unmodified lines"""Generates a response using the FLAN-T5 model."""# Adjusted prompt for better guidanceguided_prompt = (f"You are a friendly and entertaining chatbot with the personality of an old-school raver who loves house music, good vibes, and funky beats. "f"Respond to the user's message in a groovy, laid-back, and full-of-love style.\n\n"f"User: {prompt}\nBot:")try:7 unmodified linesdo_sample=True,top_p=0.9,top_k=50,num_beams=1,num_return_sequences=1,no_repeat_ngram_size=2,)response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)# Log the full model output for debugginglogger.info(f"Full model output: {response_text}")# Extract the bot's responseresponse = response_text.split("Bot:", 1)[-1].strip()if not response:response = response_text.strip()# Randomly include a house hook (30% chance)if random.random() < 0.3:26 unmodified linesif message.author and message.author.name.lower() == self.nick.lower():return # Ignore the bot's own messages# Safely log the messageif message.author:logger.info(f"Message received from {message.author.name}: {message.content}")else:logger.info(f"Message received: {message.content}")# Generate a responseresponse = await generate_response(message.content)# Send the response back to the Twitch chatif message.author:await message.channel.send(f"@{message.author.name} {response}")else:await message.channel.send(response)# Initialize and run the botif __name__ == "__main__":
app.py+19-102