Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line234567820 unmodified lines293031323334353637383940414243444546474849505152535455565758596061626364656667686918 unmodified lines8889909192939448 unmodified lines1431441451461 unmodified lineimport randomimport loggingfrom twitchio.ext import commandsfrom transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLMimport torch# Set up logging20 unmodified linesif missing_vars:raise ValueError(f"Missing environment variables: {', '.join(missing_vars)}")# Replace with your actual model namemodel_name = "jacksonstrut/tinyllama-1.1B-chat"# Disable tokenizer parallelismos.environ["TOKENIZERS_PARALLELISM"] = "false"# Load the tokenizer with use_fast=Falsetokenizer = AutoTokenizer.from_pretrained(model_name,token=HUGGINGFACE_API_TOKEN,use_fast=False)# Ensure pad_token is setif tokenizer.pad_token is None:tokenizer.pad_token = tokenizer.eos_tokenconfig = AutoConfig.from_pretrained(model_name)model = AutoModelForCausalLM.from_pretrained(model_name,config=config,token=HUGGINGFACE_API_TOKEN)model.to('cpu')# List of house music hooks to drop randomlyHOUSE_MUSIC_HOOKS = [# ... your list of hooks ...]# Initialize chat history for userschat_histories = {}async def generate_response(user_id, user_message):"""Generates a response using the model."""try:# Retrieve or initialize the chat history for the userif user_id in chat_histories:18 unmodified linesdo_sample=True,top_p=0.95,top_k=50,pad_token_id=tokenizer.pad_token_id,no_repeat_ngram_size=3,)48 unmodified lines# Initialize and run the botif __name__ == "__main__":bot = TwitchChatBot()bot.run()1 unmodified line234567820 unmodified lines293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514618 unmodified lines16516616716816917017148 unmodified lines2202212222231 unmodified lineimport randomimport loggingfrom twitchio.ext import commandsfrom transformers import AutoTokenizer, AutoModelForCausalLMimport torch# Set up logging20 unmodified linesif missing_vars:raise ValueError(f"Missing environment variables: {', '.join(missing_vars)}")# Initialize the Hugging Face tokenizer and model for DialoGPTmodel_name = "jacksonstrut/tinyllama-1.1B-chat"tokenizer = AutoTokenizer.from_pretrained(model_name, token=HUGGINGFACE_API_TOKEN)model = AutoModelForCausalLM.from_pretrained(model_name, token=HUGGINGFACE_API_TOKEN)model.to('cpu')# 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!","Asking ya..to BELIEVE..in the MIX!","BeaverBankHouseMafia in the house baby!","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!","We're on a roll, can't stop feeling alive!","The music's got us moving, let's keep on dancing!","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!","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!","Got my heart racing, and my feet are on fire!","The music's got us moving, can't stop dancing!",]# Initialize chat history for userschat_histories = {}async def generate_response(user_id, user_message):"""Generates a response using the DialoGPT model."""try:# Retrieve or initialize the chat history for the userif user_id in chat_histories:18 unmodified linesdo_sample=True,top_p=0.95,top_k=50,pad_token_id=tokenizer.eos_token_id,no_repeat_ngram_size=3,)48 unmodified lines# Initialize and run the botif __name__ == "__main__":bot = TwitchChatBot()bot.run()
app.py+104-27