Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,10 +29,10 @@ missing_vars = [var for var in required_vars if not globals().get(var)]
|
|
| 29 |
if missing_vars:
|
| 30 |
raise ValueError(f"Missing environment variables: {', '.join(missing_vars)}")
|
| 31 |
|
| 32 |
-
# Initialize the Hugging Face tokenizer and model for
|
| 33 |
model_name = "jacksonstrut/tinyllama-1.1B-chat"
|
| 34 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name,
|
| 35 |
-
model = AutoModelForCausalLM.from_pretrained(model_name,
|
| 36 |
model.to('cpu')
|
| 37 |
|
| 38 |
# List of house music hooks to drop randomly
|
|
@@ -50,97 +50,14 @@ HOUSE_MUSIC_HOOKS = [
|
|
| 50 |
"Something for your soul!",
|
| 51 |
"Not everyone understands this thing they call house music!",
|
| 52 |
"It's a spiritual thing!",
|
| 53 |
-
|
| 54 |
-
"Don't mean a thing if it ain't got that swing!",
|
| 55 |
-
"Can't stop. Won't stop!",
|
| 56 |
-
"Shots! Shots! Shots!",
|
| 57 |
-
"Jack to the sound of the underground!",
|
| 58 |
-
"Jack your body!",
|
| 59 |
-
"Asking ya..to BELIEVE..in the MIX!",
|
| 60 |
-
"BeaverBankHouseMafia in the house baby!",
|
| 61 |
-
"Dancing all night long, can't stop the beat!",
|
| 62 |
-
"Got my hands up high, feeling alive!",
|
| 63 |
-
"The music's got me moving, can't resist the groove!",
|
| 64 |
-
"Let's ride this wave, we're on top of the world!",
|
| 65 |
-
"Feeling the energy, let it consume us all!",
|
| 66 |
-
"We're in the zone, lost in the music!",
|
| 67 |
-
"This beat is fire, can't stop dancing!",
|
| 68 |
-
"The rhythm is pumping, let's keep it real!",
|
| 69 |
-
"Get ready to party, we're on a roll!",
|
| 70 |
-
"Let's make some noise, and show them how it's done!",
|
| 71 |
-
"We're living for the moment, feeling alive tonight!",
|
| 72 |
-
"The music's got us hyped, let's keep it real!",
|
| 73 |
-
"We're in the house, and we're here to stay!",
|
| 74 |
-
"Let's rock this place, and make it feel like home!",
|
| 75 |
-
"Got my hands up high, feeling alive tonight!",
|
| 76 |
-
"The beat is strong, and so are we!",
|
| 77 |
-
"We're on the dance floor, living our best lives!",
|
| 78 |
-
"Let's keep the energy high, and the vibes bright!",
|
| 79 |
-
"Feeling the music deep inside my soul!",
|
| 80 |
-
"We're on a roll, can't stop feeling alive!",
|
| 81 |
-
"The music's got us moving, let's keep on dancing!",
|
| 82 |
-
"Feeling the magic, in every single note!",
|
| 83 |
-
"We're lost in the rhythm, and we can't be stopped!",
|
| 84 |
-
"The music's got us swaying, back and forth!",
|
| 85 |
-
"Let's keep dancing all night long!",
|
| 86 |
-
"Feeling the heat, let it consume me whole!",
|
| 87 |
-
"We're in the zone, can't stop grooving!",
|
| 88 |
-
"The music's got us high, and we won't come down!",
|
| 89 |
-
"Let's keep on moving, until the morning light!",
|
| 90 |
-
"We're in this together, let's make it feel right!",
|
| 91 |
-
"The rhythm is strong, and we can't be stopped!",
|
| 92 |
-
"Feeling the beat, deep inside my soul!",
|
| 93 |
-
"Got my heart racing, and my feet are on fire!",
|
| 94 |
-
"The music's got us moving, let's keep it real!",
|
| 95 |
-
"Feeling the energy, and we won't stop until the break of dawn!",
|
| 96 |
-
"Got my hands up high, feeling alive tonight!",
|
| 97 |
-
"The beat is strong, and so are we!",
|
| 98 |
-
"Got my feet tapping, and my heart is pounding!",
|
| 99 |
-
"Feeling the magic, in every single note!",
|
| 100 |
-
"Let's keep on dancing all night long, feeling alive tonight!",
|
| 101 |
-
"We're lost in the rhythm, and can't be stopped!",
|
| 102 |
-
"Feeling the energy, let it consume me whole!",
|
| 103 |
-
"Got my heart racing, and my feet are on fire!",
|
| 104 |
-
"The music's got us moving, can't stop dancing!",
|
| 105 |
-
"Feeling the beat, deep inside my soul!",
|
| 106 |
-
"Let's keep on dancing, until we reach our goal!",
|
| 107 |
-
"We're on a roll, can't stop living our best lives!",
|
| 108 |
-
"The music's got us moving, can't stop swaying!",
|
| 109 |
-
"Feeling the energy, let it consume me whole!",
|
| 110 |
-
"We're in this together, let's make it feel right!",
|
| 111 |
-
"Got my heart racing, and my feet are on fire!",
|
| 112 |
-
"Feeling the magic, in every single note!",
|
| 113 |
-
"We're lost in the rhythm, and can't be stopped!",
|
| 114 |
-
"The music's got us swaying, back and forth!",
|
| 115 |
-
"Feeling the heat, let it consume me whole!",
|
| 116 |
-
"The beat is strong, and so are we!",
|
| 117 |
-
"Got my feet tapping, and my heart is pounding!",
|
| 118 |
-
"Let's keep dancing all night long, feeling alive tonight!",
|
| 119 |
-
"Feeling the energy, let it take control!",
|
| 120 |
-
"We're lost in the music, can't be found!",
|
| 121 |
-
"Got my hands up high, feeling alive tonight!",
|
| 122 |
-
"Feeling the vibe, let's keep it real!",
|
| 123 |
-
"We're on a roll, can't stop living our best lives!",
|
| 124 |
-
"Got my heart racing, and my feet are on fire!",
|
| 125 |
-
"The music's got us moving, can't stop grooving!",
|
| 126 |
-
"Feeling the magic, in every single note!",
|
| 127 |
-
"We're lost in the rhythm, and can't be stopped!",
|
| 128 |
-
"Got my feet tapping, and my heart is pounding!",
|
| 129 |
-
"Feeling the energy, let it take control!",
|
| 130 |
-
"We're on a roll, can't stop living our best lives!",
|
| 131 |
-
"The beat is strong, and so are we!",
|
| 132 |
-
"Feeling the energy, let it consume me whole!",
|
| 133 |
-
"Got my feet tapping, and my heart is pounding!",
|
| 134 |
-
"Feeling the beat, deep inside my soul!",
|
| 135 |
-
"Got my heart racing, and my feet are on fire!",
|
| 136 |
-
"The music's got us moving, can't stop dancing!",
|
| 137 |
]
|
| 138 |
|
| 139 |
# Initialize chat history for users
|
| 140 |
chat_histories = {}
|
| 141 |
|
| 142 |
async def generate_response(user_id, user_message):
|
| 143 |
-
"""Generates a response using the
|
| 144 |
try:
|
| 145 |
# Retrieve or initialize the chat history for the user
|
| 146 |
if user_id in chat_histories:
|
|
|
|
| 29 |
if missing_vars:
|
| 30 |
raise ValueError(f"Missing environment variables: {', '.join(missing_vars)}")
|
| 31 |
|
| 32 |
+
# Initialize the Hugging Face tokenizer and model for TinyLlama
|
| 33 |
model_name = "jacksonstrut/tinyllama-1.1B-chat"
|
| 34 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=HUGGINGFACE_API_TOKEN)
|
| 35 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=HUGGINGFACE_API_TOKEN)
|
| 36 |
model.to('cpu')
|
| 37 |
|
| 38 |
# List of house music hooks to drop randomly
|
|
|
|
| 50 |
"Something for your soul!",
|
| 51 |
"Not everyone understands this thing they call house music!",
|
| 52 |
"It's a spiritual thing!",
|
| 53 |
+
# ... [keep the rest of the hooks as they are] ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
]
|
| 55 |
|
| 56 |
# Initialize chat history for users
|
| 57 |
chat_histories = {}
|
| 58 |
|
| 59 |
async def generate_response(user_id, user_message):
|
| 60 |
+
"""Generates a response using the TinyLlama model."""
|
| 61 |
try:
|
| 62 |
# Retrieve or initialize the chat history for the user
|
| 63 |
if user_id in chat_histories:
|