Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
from threading import Thread
|
3 |
from typing import Iterator
|
4 |
|
@@ -13,6 +14,30 @@ MAX_MAX_NEW_TOKENS = 1024
|
|
13 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
14 |
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
#Transformers Code
|
17 |
if torch.cuda.is_available():
|
18 |
#model_id = "Qwen/Qwen2.5-7B-Instruct"
|
@@ -45,7 +70,9 @@ def generate(
|
|
45 |
conversation.append({"role": "system", "content": system_prompt})
|
46 |
#for user, assistant in chat_history:
|
47 |
# conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
48 |
-
|
|
|
|
|
49 |
#conversation.append({"role": "user", "content": "Channel the cosmic voice of Longshadow to craft rap lyrics that blend mysticism, grit, and cultural critique. Draw on ancestral wisdom, surreal imagery, and cosmic energy to create a verse that critiques systemic oppression, inspires resilience, and celebrates liberation. The tone should balance sharp wit, evocative imagery, and spiritual insight, culminating in a coherent and impactful thought. All output must be exclusively in English, without inclusion of other languages or scripts. Favor originality and inventive rhymes and deliver each verse as a work of art. Use a mix of ABAB, AABB rhyme schemes, and internal rhymes to create a flowing, rhythmic style. Include some slant rhymes, near rhymes, and perfect rhymes to add complexity. Each line should be 8-12 syllables long. The topic is: " + message})
|
50 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
51 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
|
|
1 |
import os
|
2 |
+
import random
|
3 |
from threading import Thread
|
4 |
from typing import Iterator
|
5 |
|
|
|
14 |
DEFAULT_MAX_NEW_TOKENS = 1024
|
15 |
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
16 |
|
17 |
+
lyrics_pool = [
|
18 |
+
"[VERSE 1]\nBack when I was broken up chasin after yall shit\npriority was smokin up, tryna keep the bar lit\nI tried to use this pain of mine to fertilize the garden\nI would do it rain or shine, I was overwatering\nwhen you take care of business where the air acidic\nbe careful and beware of it, its parasitic\nfrom wonder valley I extend healing\nyo gonna see for miles if you receive\nhere come the ayurvedic love\n",
|
19 |
+
|
20 |
+
"[INTRO]\nSo now i sprint\narms wide, fists clenched\nthirst not quite quenched\nI know what we can be\nmy feet might bleed my heart might break OK\nbut i remember who we used to be\n\n[VERSE 1]\nDying on the cross of who we used to be\nthen i remembered what we all agreed\nto seek out love in all its different energies\ngo back home and then return a bigger better thing,\nonce upon a time we shared a frequency\nbut now we in a different paradigm\nif it’s interference when you seein me\ni’m in paradise\nuse a different pair of eyes\nwe are not the same\n\n[HOOK]\nWe are not the same\nwe are not the same\neverything changed one day\nwe are not the same\nwe are not the same\ni think i like it better this way\n\n[VERSE 2]\nYou should throw the ceiling back\nwhat’s your code to reattach?\nsometimes when i look up at the sky at night, I see a map\nwayfinder, you free at last\neven though the sea is black\nyou can be a firekeeper too, you just need a match\n\n[VERSE 3]\nI got a different assignment\nits in a different alignment\nI came equipped with additional drivers passenger seat with the blinders\nnaturally gifted and guided\ngradually it became normal to hide it\nfear of the fuel I was given to live in this body would leave me divided\nfeelin far from a higher form\ntemperatures up in the biodome\nmight’ve been off of that microdose when I decided to sit by the firestone\nI saw it all when my eyes were closed\nopened em up now its time to go\nbut something done shifted for all of us all a sudden the light is on, whoa\nsharpen the mind with effort\nsoften the psychic edges\nwith fungus fibers and lettuce the darker the night the better\nthe harder I tie the headdress\nthe farther can fly the message\nreach higher to pull the sun down, i wonder who else remembers\nyeah\n\n[BRIDGE]\nThis is not a hologram or a simulation\nit would be so easy if that were the situation\n\n[OUTRO]\nSo now i sprint\narms wide, fist clenched\nthirst not quite quenched\nI know what we can be\nmy feet might bleed my heart might break OK but i remember who we used to be\nso now i sprint\narms wide, eyes squinched\nthirst not quite quenched\nits a lucid dream\nmy feet might bleed my heart might break OK beloved, none of this is new to me",
|
21 |
+
|
22 |
+
"[VERSE 1]\nyeah now i’m runnin w the goats\nstand on every book I bid im taller now we call that growth\na bet on me murdered the old version that you know\nif it aint resolved w him you holdin grudges with a ghost\nthe babadook the baba yaga\npracticin his pranayama\nprayin that he purify a purpose in these final hours\ntryin not to be too hard on myself for entertaining cowards\nnever let draconians go swimmin in the dragon waters\nthats a promise owe it myself to seek refinement\nthe way its routed you’ll be doubted by your chief advisors\nfound a way to eat despite the smaller portion sizes\nmelt the cap, water rises I'm a warmer climate\nfloat into a room like i own that shit\nsovereignty on my domain, blacker than black ownership\nblacker than im mubarack on black ops for the soviets\nturned my back on me enough to know how im supposed to sit\nyou stand up straighter when these facts arriving\nand download an ancestral bag of diamonds\nthats refinement on the black horizon\ngratitude for the dubs when i actualize em\n\n[HOOK]\nwe so ill\nyou can keep the cure\nto achieve peace we believe in war\nrefine, reform, see the light we absorb\ntribe is a vibe, right from the source\n\n[VERSE 2]\nsome people in it to win it\nI got in it to end it\nnever went independent, bitch I been independent\npenmanship is a menace win the pennant a penance\nI negotiate interest, you on pinterest with pendants\nbalance basic intentions\nthats that libra ascendant and the fee for admission\nI be kickin my feet up, like i'm the fifa commission\nout here free on the fringes\ndont need a seat at the table when you the key to the entrance\nonce I decided we was tryna be the highest me\nfirst i refined the mind and afterwards refined the speech\ntrimming fat to feed the ritual im finna eat\nmy time is nature’s now, the teacher had to hike his fee\nif you dont like the premium package price of the chi\nits plenty of pretenders i still hope you find ya peace",
|
23 |
+
|
24 |
+
"[VERSE 1]\nyou ever draw lines in the quicksand\nand the bag keep hoppin out ya hands\nif you feel fire ticklin ya ear drums\nthats god laughin atchya plans\namerican values they got us fucked up\neverybody gotta reach the bottom line\nyou might be cool runnin for the big win\nbut you’ll never outsleigh father time\nI know you want it now but its not yours\nmight feel like its haters by the locked doors\nyou just gotta chill and getcha mind right\nyou prolly already at the top floor\nin a deprivation tank with the lights off\nI meditate in thanks with the brights off\nthink what I should to take my mind off\nuncage it until it flies off\naint as far from myself as I thought I was\nbodhisattva i'm back and you caught a buzz\nput a whole bunch of facts on the firewood\npour the gas can dry then i light it good\nthats a gift given by them long years\neven if they sleep man im all ears\ncuz I too been trapped in a small room\nchanting to myself aw yeah\n\n[HOOK]\nCome for me\nmy time come for me\ncome for me\nmy time come for me\nit chose it chose\nit chose it chose\nit's gon be what it's gon be\n\n[VERSE 2]\nim already knowin that you put the work in\nand the world aint ready for ya genius\nand its all kinda reasons for the hold up\nyou thinkin to yourself they never seen this\npacing in your crib like a wildcat\ncuz inferior motherfuckers be coming up\nin theory you thinking man is because of luck\nbut a serious part of you feel you fuckin up\nit start to chip away at you in small bits\nsocial media got you thinking it’s all lit\nbut The devil is illusion in the tar pit\nyou’ll get stuck in it\ncovered in it, stallin\nbut that wall is where yo blade gotta sharpen\nwhen the hype dies and the room darkens\nthat’s when your warrior side should starts sparkin\nthen the rest of yo life is seances , yeah",
|
25 |
+
|
26 |
+
"[VERSE 1]\nI'm the part of you that never goes to sleep\nLock me out I go and find a key\nI was you before you ever came to be\nThe outside world never came to me\ndig a dirty hole throw me in alive\nShovel soil on me hoping I'm gonna die\nWalkin off like you don't hear my call\nWhile I suffocate, you can hear me thru the walls\n\n[CHORUS]\nThrough the walls\nThrough the walls\nYou can hear me through the walls\n\n[VERSE 2]\nOh you heartless now? can't ya love?\nYouse a monster? an empty husk?\nNobody knows ya? can't be touched?\nBigger than life, but not bigger than us?\nI used to live on ya sleeve,\ntucked in a cuff like a cigarette box\nCut and punched on, watch me bleed\nI saw the sun less the bigger ya got\nHearts were broken, lies were told\nTrust was shook up, it made us cold\nPersonas built up, rhymes got wrote\nBehind a stage name, that was dope\nBut somewhere in there, I was lost\nCalcified, tied down and then offed\nSo ya thought, but hard ta live\nWithout me right there, and the life I give\nThe universe is vast and grand\nA sprawling wilderness of massive span\nholy rivers, rolling rocks\ntumbling planets, dying stars\nThey feed me grace, while you asleep\nkeep me lifted, and full of heat\nAnd even though, the world to you\nIs all the things you see and consume\nAnd all the unseen is simply voodoo\nThat don't add up in human view\nI know the truth, and who you are\nCompared to what you believe and pawn\nOff to folks, the magic show\nWith pretty lights, and fireworks\nI'll still be with you, at the end\nCallin atchya thru the walls",
|
27 |
+
|
28 |
+
"[INTRO]\nWhat if white supremacy was guided by a star\nthat's seen its peak now we feel it dyin off\nto be alive to see it all\nthe final fall of the white dwarf\n\n[VERSE 1]\nYou broke the universal contract\nGET THE FUCK OUTTA HERE you know where the doors at\nall you did was rain ash\nand tell ya worshippers they jealousy was fact\nand the only thing worse than bein dead was bein black\nthe cowards you attract\nknow money give you life so they hoarding all ya gold\nthen send police for overseeing what you stole\nall this had to come to pass I don't try and understand\nthe wreckage you command\nthe sleight of hand of tribalism would divide us into bands\ntoo numb to feel a natural connection to the land\nand your murderers and conquerors\nperverted holy symbols and converted em to swastikas\nand everything you make is partial\ninsecure paranoid and patriarchal\nya medicine is harmful\nya history a guess\nonly legitimate when you come out the best\nthis energy is crazy I can feel it from the sky\nwhat a time to be alive we get to see you die\non behalf of starseed coalitions\nand relatives separated from the old traditions\nwe here to play long game everyday is work\nall moves made accelerated by the earth\nthey cities will dissolve they militias will collapse\nthey sons won't believe em, they daughters will detract\nimagine what we’ll build when you dead on yo back\nif a hen can lay an egg when its fed table scraps\n\n[OUTRO]\nI been waitin my whole damn life for this moment\nTrainin my whole damn life for this day\nI been waitin my whole damn life for this moment\nTrainin my whole damn life for this day\nblack children of the future rejoice\nyou pounded the heavens with the sound of ya voice\nyou shook it loose now watch it cry\nlet it fall down let it die\nbefore it get better it's gonna get worse\nso many levels it's a thick curse\nbut to be alive just to see it all\nthe final fall of the white dwarf",
|
29 |
+
|
30 |
+
"[INTRO]\nIt go nature give precision to all of my decisions\nI don’t play games, I only play my position\nAin’t no slippin\n\n[VERSE 1]\nWhen you on survivor nothings minor, every breath is major\nYou gonna have to get your savior steppin to the steppin razor\nExtra help and echinacea wishin you good health and paper though…\nIn the shit that made us, we rebelled in anger\nIt’s the desperation derby\nHit you like a set of burpees, paper routes would lead us premature to steps of heaven early\nFayettenam, a pressure furnace numbed us to the stress of burning\nCuz I come from that, I stay forever thirsty\nLeft the shores of Africa to hunt the head of Circe\nCame back with medicine to heal the shit I let disturb me\nPaid my dues so when I spat the facts, the elders heard me\nAin’t no slippin\nAnd the desert’s wicked as the devil’s mercy\nHead on swivel through the poverty, disease, addiction\nOn a mission to abolish these police, they trippin\nKept my body like a temple with symbolic scriptures\nAin’t no slippin\nIf you wanna level up and leave the kitchen\n\n[CHORUS]\nIt go nature give precision to all of my decisions\nI don’t play games, I only play my position\nAin’t no slippin\n\n[VERSE 2]\nYo, the food supply is tainted and it’s locusts in the fields of wheat\nCoyotes in the street, fled the hills, they feel the heat\nLuna full in Gemini, the children woke but still asleep\nBilly goats, a million sheep\nI walk in love with gilded feet\nThey want us on they cameras livin life so they can build a case\nAndroids in yo pocket trackin clicks so they can map ya face\nThe mic is on without you askin’, careful what the fuck you say\nBaby boy, be stealthy with the moves you make\nMy alchemy distilled the peak, stretched it a billion feet\nIn any given direction, my message was built to reach\nIf it ain’t on mission, keep it smooth and just observe the light\nAin’t no slippin\nMuthafucka, you heard us right\n\n[OUTRO]\nIt go nature give precision to all of my decisions\nI don’t play games, I only play my position\nAin’t no slippin",
|
31 |
+
|
32 |
+
"[VERSE 1]\nThey said they saw a criminal before he saw a judge\nHe just saw a flash of light when they dislodged a slug\nThey need salty blood to season all the mud\nThey gonna shovel on his grave, his name is all but done\nHere’s the story of a city where we all from\nWhere they make you think they hiding diamonds in a ball of gum\nIt don’t matter ‘bout the heights of the buildings that you like\nWhen they call it, they gon be inside the tallest one\nCuz they gotta see you\n\n[CHORUS]\nBe still\nPretty soon it’s gon’ all be revealed\nYou gon' have to make it known how you feel\nTwelve got eyes in the hill, it’s sorta like a see-through feel\nBe still\nPretty soon it’s gon’ all be revealed\nYou gon' have to make it known how you feel\nTwelve got eyes in the hill, it’s sorta like a see-through feel\n\n[VERSE 2]\nSwimmin’ thru these streets like a hammerhead\nMy body just meat to keep the camera fed\nWhat I do and say keep the feds hand fed\nGettin’ ads on my phone for what my man just said\nBattle for your soul and to the winner goes the spoils\nThey movin’ like a snake, we at the center of the coil\nThey put that eye on high so every winter I can boil\nIt’s beef as far as London that blisters when it broils\nIt ain’t yo phone or the apps, they get you on\nIt’s like they put a signature on every seed that's in the soil\nBuckin’ at the nation state, fuck ‘em, they gon’ hunt us anyway\nAnd only subjugate us if we loyal\nOh boy\n\n[VERSE 3]\nFeelin' small but still involved, my teachers taught it to me\nI hear 'em call while steerin’ off, they get to talkin’ to me\nSmellin' cigarettes, but ain’t nobody light no bogey\nI think my uncle in the passenger beside me, homie\nI felt the need to apologize for how I’m movin’\nHe said keep on doin’ what you doin’ if you fightin’ for me\nTrue… I’d rather die a fighter than live a compliant bitch\nLive by a certain code, it’s hard to find a niche\nGive what you learn to folks in harsh environments\nThen what you searchin’ for will start to find a fit\nAnd it feel like a magnetic field… that baffles astrologers and scientists",
|
33 |
+
|
34 |
+
"[INTRO]\nGrace, gratitude, love\nHealing\nExtending it across all generations and timelines\n\n[VERSE 1]\nNow, look what’s flyin’ out the kitchen — now you in assisted livin’ talkin’ ‘bout the gift of givin’\nIt’s dementia flow, it’s like a water pipe in Flint,\nWhen the mortar strikes the brick, it’s hypnotizin’\nI’m the fire on the petro spliff where the writin’ on the wall look like petroglyphs\nGod bless the mileage moms put behind us\nFleeing from the violence, you prolly know what the vibe is\nIf I met a doper nga, gotta reacquaint us\nBut ain’t nobody leavin’ ‘til you free the natives\nAlpha castaway, lost in a sea of betas\nYou talk in coded language, they see ya data\nThey body-baggin’ our gladiators so young\nThey got yo’ anger tamed, you gotta spray witcho’ thumbs\nWater-bearing sun but my moon Virgo\nSo I study, then I’ll move when the mood fertile\n\n[VERSE 2]\nI go to sleep depleted\nWith my databanks deleted\nIn an alligator’s breeding nest\nSince I been on my dragon shit and tamed the inner beast, the queen agrees I have to feed ‘em less\nSo I dream of serpent magic in Afghani poppy fields, wake up and I feel refreshed\nAnother day of Gilgamesh hopin’ he can liberate hisself and heal his flesh\nYeah, the horde needs steak\nTrain hands on hooks of frozen horse meat flanks\nRaindance on plant bush medicine for the ranks\nWe about to eat, before that we give thanks\n‘Cause Shiva leavin’ bodies on the banks of the Ganges\nIf I go collateral, I’m hatchin’ open Plan B\nDon’t tempt fate and walk quiet\nThen pray for the wounded when you finish your assignments",
|
35 |
+
|
36 |
+
"[VERSE 1]\nWhy do I feel like shit\nThis is the serotonin dip after that Malibu trip\nA night of passin' thru cliffs, recalibrating my shit\nLickin' wound by the skeleton moon on the coast and off of the grid\nUp by the Chumash nem\nAho ase\nLife keeps movin' when the movie pause\nAnd I always show up when duty calls\nDown to resolve how beauty falls\n(And the end of things) the doom we scroll\n(Pull the plug) mute my calls\nPut my heart in my palm\nto do my job, the medicine kicks in and the sand dunes fall\n\n[HOOK]\nI'm inside out\nI'm lost and found\nCuz that was then, where are you now (and this is now)\nI'm turned around and losing ground\nI'm upside down, I'm upside down\n\n[VERSE 2]\nHow can I trust my judgment is sound\nOr anything floating around in my head\nWhen all of my teachers mentally ill, dead\nOr really just not who they said\nLoved one the places you tend to be\nFinna be empty\nThe finality hit me, I haven't been able to get sleep\nYou haven't transitioned yet, wanted to rock while you hear me\nI'm better for having you near me\nWhen after this year, multiply into many\nAnd all of my life cycles end up in plenty\nAnd I leave the illusion of living to be a new mandala petal that's peeling\nApart at whatever particular barrier separating our oneness\nWe'll be one again, then we'll run this\nOne day I'll look up to wonder about where the sun went\nYou was around to hear all the demos and punch-ins\nYou might be alone in understanding I'm Sumkid\nAnd knowing all that I'm up against\nWhen down is up again\nI'm sorry, come again\n(Comin' in)",
|
37 |
+
|
38 |
+
"[VERSE 1]\nI can feel the weight of all we left behind us\nIt's heavy on occasion if I'm bein' honest\nBut I learned a shadow cannot show up where the light is\nWhere the light is, that's where the line is\nAnd so I tunneled deep into my inner being\nAnd found the solar energy that kept me heated\nDug it up but then I couldn't find a word to fit the feelin'\nCome close enough and you could see that\n\n[CHORUS]\nI'm light I'm light pouring through open door\nI'm never goin' back again\nI'm only here one time\nOnly here one time\nI promise I can show you more\nAnd you'll be comin' back again\nI'm only here to shine\nOnly here to shine one time\n\n[VERSE 2]\nWhat's the hold up\nNever fold up, if I do, I'm doin' yoga\nCreatures of the night are solar even they got sun to soak up\nIridescence is the lesson\nIf it's in you, then yo show up... that's how we go up\nThe desert winds, they conjure an electric healing\nThe moon is high but low enough for me to feel it\nI pull it down and take it everywhere I'm goin'\nAnd that's a glow up\nI'm light pouring through an open door",
|
39 |
+
]
|
40 |
+
|
41 |
#Transformers Code
|
42 |
if torch.cuda.is_available():
|
43 |
#model_id = "Qwen/Qwen2.5-7B-Instruct"
|
|
|
70 |
conversation.append({"role": "system", "content": system_prompt})
|
71 |
#for user, assistant in chat_history:
|
72 |
# conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
73 |
+
chosen_lyrics = random.choice(lyrics_pool)
|
74 |
+
conversation.append({"role": "user", "content": "Channel the cosmic voice of Longshadow to craft a shadow song of the provided rap lyrics. Use vivid imagery of the given topic to create the song. All output must be exclusively in English. Each line should be 8-12 syllables long. The generated song should include the following song structure [INTRO] [VERSE 1] [HOOK] [VERSE 2] [OUTRO]. The topic is: " + message + ".The lyrics to shadow are: " + chosen_lyrics})
|
75 |
+
#conversation.append({"role": "user", "content": "Channel the cosmic voice of Longshadow to craft rap lyrics into a song. Use vivid imagery of the given topic to create the song. The tone should balance sharp wit, evocative imagery, and deep insights. The mood should inspire resilience and personal growth in the face of systemic injustice. All output must be exclusively in English. Favor originality and inventive rhymes and deliver each verse as a work of art. Use a mix of ABAB, and AABB rhyme patterns to create a flowing, rhythmic style. Include some internal rhymes, slant rhymes, near rhymes, and perfect rhymes to add complexity. Each line should be 8-12 syllables long. The generated song should include the following song structure [INTRO] [VERSE 1] [HOOK] [VERSE 2] [OUTRO]. The topic is: " + message})
|
76 |
#conversation.append({"role": "user", "content": "Channel the cosmic voice of Longshadow to craft rap lyrics that blend mysticism, grit, and cultural critique. Draw on ancestral wisdom, surreal imagery, and cosmic energy to create a verse that critiques systemic oppression, inspires resilience, and celebrates liberation. The tone should balance sharp wit, evocative imagery, and spiritual insight, culminating in a coherent and impactful thought. All output must be exclusively in English, without inclusion of other languages or scripts. Favor originality and inventive rhymes and deliver each verse as a work of art. Use a mix of ABAB, AABB rhyme schemes, and internal rhymes to create a flowing, rhythmic style. Include some slant rhymes, near rhymes, and perfect rhymes to add complexity. Each line should be 8-12 syllables long. The topic is: " + message})
|
77 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
78 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|