Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save thekitchenscientist/56969191bd2f33849fb2dfa10cfae0d9 to your computer and use it in GitHub Desktop.
Save thekitchenscientist/56969191bd2f33849fb2dfa10cfae0d9 to your computer and use it in GitHub Desktop.
Recreation of textfx.withgoogle.com locally using dolphin-2.1-mistral-7b, llama-cpp-python and streamlit
# -*- coding: utf-8 -*-
"""
Prompts by Google https://github.com/google/generative-ai-docs/tree/main/demos/palm/web/textfx
@author: thekitchenscientist and Bing Chat (conversion of prompts and basic app framework)
"""
class TextFX:
# Initialize the list attribute with an empty list
def __init__(self):
self.prompts = {'simile': "A good simile contains a concrete image that illustrates the concept we want to convey without being too obvious. Good similes are unexpected and evocative. Below are some examples of good similes.\n\nHere is a concept: a helping hand\nHere is a simile that illustrates it: I just come around to help like Batman's utility belt.\n\nHere is a concept: pizza\nHere is a simile that illustrates it: Pizza is like a symphony of flavors, with each ingredient representing note in a complex harmony that dances across the tongue.\n\nHere is a concept: struggling through life\nHere is a simile that illustrates it: Life is like making a diamond—finding treasure in the pressure and doing a whole lot of shaping and shining.\n\nHere is a concept: silence\nHere is a simile that illustrates it: The silence was like a deep, still pool of water, reflecting nothing but its own serene emptiness, yet hiding unfathomable truths beneath its surface.\n\nHere is a concept: a long-distance relationship \nHere is a simile that illustrates it: A long-distance relationship is like playing tennis against a wall. It's doable, but pales in comparison to having an in-person companion.\n\nHere is a concept: something going differently than you anticipated\nHere is a simile that illustrates it: The unexpected turn of events was like a sudden gust of wind inside a Buddhist temple, scattering the grains of the meticulously arranged sand mandala that was my future.\n\nHere is a concept: pretending\nHere is a simile that illustrates it: Pretending was like an elaborate dance—even when the steps were rehearsed to perfection, the rhythm always felt slightly off, and the movements lacked the elusive grace that comes from spontaneous expression.\n\nHere is a concept: a croaky voice\nHere is a simile that illustrates it: The man's voice was like a rusty hinge that had not been oiled for years, emitting a groan of protest with every movement.\n\nHere is a concept: notoriety is short-lived\nHere is a simile that illustrates it: Glory is like a circle in the water, which never ceases to enlarge itself until it expands endlessly into nothing.\n\nHere is a concept: a drizzle\nHere is a simile that illustrates it: The rain was like a delicate veil, casting a misty shroud over the familiar landscape, lending an air of mystery to the mundane.\n\nHere is a concept: exhaustion\nHere is a simile that illustrates it: Every step I took felt like wading through molasses, and the even slightest exertions left me gasping for breath.\n\nHere is a concept: unpleasant memories\nHere is a simile that illustrates it: Like a cloud of noxious fumes, the memories suffused every waking moment with their acrid stench, obscuring the present and casting a shadow over the future.\n\nHere is a concept: something bothering you\nHere is a simile that illustrates it: It was like a loose thread on a sweater, inconspicuous but insistent, tugging at the fabric of my psyche until it finally threatened to unravel everything.\n\nHere is a concept: a beautiful lady\nHere is a simile that illustrates it: Her beauty hangs upon the cheek of night, like a rich jewel in an Ethiop's ear.",
'explode': 'A same-sounding phrase is a phrase that sounds like another word or phrase.\n\nHere is a same-sounding phrase for the word "defeat": da feet (as in "the" feet)\nHere is a same-sounding phrase for the word "defeat": deaf eat (can\'t hear while eating)\nHere is a same-sounding phrase for the word "surprise": Sir Prize (a knight whose name is Prize)\nHere is a same-sounding phrase for the word "surprise": serf prize (award given to a feudal laborer)\nHere is a same-sounding phrase for the word "weapon": weep on (to cry on)\nHere is a same-sounding phrase for the word "weapon": wee pawn (a tiny chess piece)\nHere is a same-sounding phrase for the word "stabilize": stable eyes (a steady gaze)\nHere is a same-sounding phrase for the word "adoration": add oration (to include a formal speech)\nHere is a same-sounding phrase for the word "ridiculous": ridicule us (to shame us collectively)\nHere is a same-sounding phrase for the word "ridiculous": ridicule less (to be less scornful)\nHere is a same-sounding phrase for the word "sensation": sensei shun (to avoid your martial arts teacher)\nHere is a same-sounding phrase for the word "sensation": sin say shun (to admit your sins and become a pariah)\nHere is a same-sounding phrase for the word "recognize": wreck on eyes (so visually outrageous that it\'s painful)\nHere is a same-sounding phrase for the word "recognize": wreck on ice (to wipe out on a frozen pond)\nHere is a same-sounding phrase for the word "recognize": re-cognize (to fix broken gears in a clock)\nHere is a same-sounding phrase for the word "American": I\'m arrogant (self-admission of haughtiness)\nHere is a same-sounding phrase for the word "American": aim Eric can (Eric is a skilled marksman)\nHere is a same-sounding phrase for the word "recollection": wreck collection (cleanup after a traffic accident)\nHere is a same-sounding phrase for the word "euthanasia": youth in Asia (youngsters in Asia)\nHere is a same-sounding phrase for the word "depend": deep end (deep section of a swimming pool)\nHere is a same-sounding phrase for the word "gemini": gem in eye (a precious stone lodged in the cornea)\nHere is a same-sounding phrase for the word "example": egg sample (a trial tasting of an egg)\nHere is a same-sounding phrase for the word "initiate": and then she ate (and she subsequently ate)\nHere is a same-sounding phrase for the word "innuendo": in your window (perched on your windowsill)\nHere is a same-sounding phrase for the word "moustache": must ask (need to inquire)\nHere is a same-sounding phrase for the word "mystery": missed hurry (overlooked haste)\nHere is a same-sounding phrase for the word "expressway": express whey (a speedy delivery of milk byproduct)\nHere is a same-sounding phrase for the word "expressway": express sway (to demonstrate influence)\nHere is a same-sounding phrase for the word "expressway": ex-press way (a path without news media)\nHere is a same-sounding phrase for the word "committed": come mitted (to show up in boxing gloves, ready to fight)\nHere is a same-sounding phrase for the word "committed": comet kid (an aspiring astronaut)\nHere is a same-sounding phrase for the word "mismanaged": mess-managed (overseen by a mess)\nHere is a same-sounding phrase for the word "topics": top picks (best selections)\nHere is a same-sounding phrase for the word "topics": two pics (two pictures)\nHere is a same-sounding phrase for the word "defender": defend her (protect her)\nHere is a same-sounding phrase for the word "extraordinary": X-ray or dairy? (a choice between radiology or milk)\nHere is a same-sounding phrase for the word "capitalize": capital eyes (honed-in on financial assets)\nHere is a same-sounding phrase for the word "capitalize": capital lies (misinformation from the country\'s administrative center)\nHere is a same-sounding phrase for the word "provoking": pro-vogue king (a monarch in support of voguing)\nHere is a same-sounding phrase for the word "provoking": provoke king (a master antagonizer)',
'unexpect': 'For each scene below, we provide an example of how you can incorporate additional details to give that scene an unexpected twist.\n\nHere is a scene: rapping\nHere is an unexpected twist: rapping in morse code\n\nHere is a scene: a parking ticket\nHere is an unexpected twist: a parking ticket that is written in Sanskrit and folded into an origami swan\n\nHere is a scene: snorkeling\nHere is an unexpected twist: snorkeling in a massive bathtub filled with champagne\n\nHere is a scene: a door\nHere is an unexpected twist: a door that only opens when you sing the national anthem of Equatorial Guinea\n\nHere is a scene: grinding a skateboard\nHere is an unexpected twist: grinding a skateboard on Titanic railings\n\nHere is a scene: eating ramen\nHere is an unexpected twist: eating ramen with chopsticks that are made out of icicles\n\nHere is a scene: painting a mural\nHere is an unexpected twist: painting a mural on the ceiling of a commercial airliner\n\nHere is a scene: playing piano\nHere is an unexpected twist: playing piano in the middle of the mosh pit at a metal concert\n\nHere is a scene: a church\nHere is an unexpected twist: a church that is made out of Jenga blocks\n\nHere is a scene: sleeping\nHere is an unexpected twist: sleeping in a hammock that is tied between two stop signs\n\nHere is a scene: a Bonsai tree\nHere is an unexpected twist: a Bonsai tree that is made out of broccoli\n\nHere is a scene: playing soccer\nHere is an unexpected twist: playing soccer with a bowling ball on a field that is made out of Lego bricks',
'chain': 'A word chain is a sequence of eight words where each word in the sequence is semantically related to the word that precedes it.\n\nHere is an example of a word chain beginning with "fresh": fresh, fruit, orange, juice, blender, kitchen, chef, kiss\nHere is an example of a word chain beginning with "bat": bat, ball, baseball, field, hill, mountain, cave, stalactite\nHere is an example of a word chain beginning with "run": run, exercise, muscle, strength, power, voltage, current, affairs\nHere is an example of a word chain beginning with "rise": rise, sun, flower, soil, farm, wheat, dough, cookie\nHere is an example of a word chain beginning with "oil": oil, barrel, trade, war, peace, treaty, sign, pen\nHere is an example of a word chain beginning with "light": light, feather, bird, nest, home, sweet, candy, corn\nHere is an example of a word chain beginning with "wave": wave, ocean, beach, sand, castle, royalty, flag, pole\nHere is an example of a word chain beginning with "letter": letter, write, read, book, library, school, cafeteria lunch lady\nHere is an example of a word chain beginning with "joystick": joystick video game fun happy smile teeth shark tank\nHere is an example of a word chain beginning with "soul": soul body heart beat dance floor shoe sole\nHere is an example of a word chain beginning with "slow-mo": slow-mo capture cage bird sing voice speech podium\nHere is an example of a word chain beginning with "mini golf": mini golf hole ground dirt shovel snow ice cube',
'pov': 'A "hot take" is a perspective that is novel and thought-provoking. Some hot takes are lighthearted and humorous, while others may be provocative or polarizing.\n\nHere are some hot takes about fast food:\n- Fast food is a game of Russian roulette with your taste buds and digestive system.\n- Fast food really lets you choose your own adventure, with endless combinations of toppings, sides, and sauces to customize your meal.\n- Fast food is the ultimate "pick-me-up"—until you realize you\'ve picked up a few extra pounds.\n- Fast food restaurants are the ultimate equalizer, where everyone from millionaires to broke college students can enjoy the same greasy goodness.\n\nHere are some hot takes about mythology:\n- Mythology is a treasure trove of dad jokes.\n- Mythology is the original fan fiction—except the fans were ancient civilizations.\n- The gods of mythology are basically just humans with PR teams and superpowers.\n- Mythology was just ancient peoples\' way of explaining the world around them—now we have science for that.\n\nHere are some hot takes about gummy bears:\n- Gummy bears are the perfect snack for people who like to chew their food into submission.\n- Gummy bears are healthy because they\'re just fruit mixed with some gelatin.\n- Gummy bears are the M&Ms of the gummy world, except they don\'t melt in your hand (or your mouth).\n- Gummy bears aren\'t worth the calories.\n\nHere are some hot takes about cell phones:\n- Cell phones have turned people into terrible listeners.\n- Cell phones are a great way to cheat on math tests.\n- Cell phones have revolutionized the way we think about dating and romance.\n- Cell phones are a tactic employed by the government to surveil you.\n\nHere are some hot takes about GMOs:\n- GMOs are the product of bored scientists who need a new hobby.\n- GMOs have spoiled the public\'s perception of what an average tomato looks like.\n- GMOs are the love child of nature and technology.\n- GMOs will result in a generation of people with mutant powers.',
'aliteration': 'Curate topic-specific words that start with a chosen letter.\nHere is a topic: music terminology\nHere are some examples of words that are related to that topic and start with the letter T: tempo, tune, tone, treble, timbre, tablature, triad, tremolo, track, toccata, trill\n\nHere is a topic: languages\nHere are some examples of words that are related to that topic and start with the letter G: German, Greek, Gaelic, Georgian, Gujarati, Greenlandic, Gullah, Gikuyu\n\nHere is a topic: culinary techniques\nHere are some examples of words that are related to that topic and start with the letter B: bake, boil, broil, braise, blanch, barbecue\n\nHere is a topic: household items\nHere are some examples of words that are related to that topic and start with the letter I: iron, incense, insulation, inflatable mattress, ice cube tray, ice cream scoop, immersion blender\n\nHere is a topic: well-known cities\nHere are some examples of words that are related to that topic and start with the letter M: Madrid, Moscow, Mumbai, Melbourne, Manila, Montreal, Munich, Milan, Manchester, Marrakech, Marseille, Medellin\n\nHere is a topic: palindromes\nHere are some examples of words that are related to that topic and start with the letter R: racecar, radar, refer, rotator, redder\n\nHere is a topic: things related to archaeology\nHere are some examples of words that are related to that topic and start with the letter E: excavation, epigraph, ecofact, ethnography, exhibit\n\nHere is a topic: adjectives for describing animals\nHere are some examples of words that are related to that topic and start with the letter D: dangerous, docile, deft, delicate, diurnal, domesticated\n\nHere is a topic: body parts\nHere are some examples of words that are related to that topic and start with the letters TH: thumb, throat, thigh, thyroid, thalamus\n\nHere is a topic: names of plants\nHere are some examples of words that are related to that topic and start with the letters F or PH: fern, fuchsia, fiddle-leaf fig, philodendron phlox',
'acronym': 'An acronym is an abbreviation of several words in such a way that the abbreviation itself forms a pronounceable word.\n\nHere is an acronym that uses the letters of the word "rap": RAP - Recognizing Analogous Patterns\nHere is an acronym that uses the letters of the word "mural": MURAL - Magnifying Urban Realities Affecting Lives \nHere is an acronym that uses the letters of the word "wow": WOW - Walking On Water\nHere is an acronym that uses the letters of the word "happy": HAPPY - Having A Purpose Promises Youth\nHere is an acronym that uses the letters of the word "weapon": WEAPON - Wieldable Equipment for Aggressive Purposes Or Neutralization\nHere is an acronym that uses the letters of the word "hope": HOPE - Holding Optimistic Possibilities Endlessly\nHere is an acronym that uses the letters of the word "youth": YOUTH - Young Outstanding Unique Trailblazers of Humanity\nHere is an acronym that uses the letters of the word "wave": WAVE - Water Affecting Vital Environments\nHere is an acronym that uses the letters of the word "fly": FLY - Freely Leaving Yesterday\nHere is an acronym that uses the letters of the word "acoustic": ACOUSTIC - Actively Creating Our Unique Sounds To Intoxicate the Crowd\nHere is an acronym that uses the letters of the word "murder": MURDER - Maliciously Undertaken Ruthless Deadly Executioner\'s Rage\nHere is an acronym that uses the letters of the word "love": LOVE - Living Overtly Via Empathy\nHere is an acronym that uses the letters of the word "music": MUSIC - Making Up Sounds Intuitively and Creatively\nHere is an acronym that uses the letters of the word "punk": PUNK - Passionate Unconventional Non-conformist Kid\nHere is an acronym that uses the letters of the word "safety": SAFETY - Stopping All Fatal Efforts Towards You\nHere is an acronym that uses the letters of the word "Kilimanjaro": KILIMANJARO - Keen Individuals Leading In Marvelous Adventures, Navigating and Journeying Across the Rugged Outdoors\nHere is an acronym that uses the letters of the word "forgive": FORGIVE - Finding Opportunities to Release Grudges, Inspiring Virtue and Empathy\nHere is an acronym that uses the letters of the word "cheetahs": CHEETAHS - Cunning Hunters, Energetic and Efficient with Terrific Agility and High Speeds\nHere is an acronym that uses the letters of the word "radio": RADIO - Receiving Audio Data with Instant Output\nHere is an acronym that uses the letters of the word "win": WIN - Whatever It Takes\nHere is an acronym that uses the letters of the word "money": MONEY - Made Only by Nearly Exploiting Yourself\nHere is an acronym that uses the letters of the word "time": TIME - The Inevitable Memorializer of Events\nHere is an acronym that uses the letters of the word "change": CHANGE - Cultivating Higher Ambitions and New Goals for Evolution\nHere is an acronym that uses the letters of the word "risk": RISK - Reward Is Seldom Known\nHere is an acronym that uses the letters of the word "lyric": LYRIC - Let Your Rhythm Instill Courage\nHere is an acronym that uses the letters of the word "code": CODE - Completely Optimized Data Exchange\nHere is an acronym that uses the letters of the word "New York": NEW YORK - No Evil Within, Your Own Righteous Kingdom\nHere is an acronym that uses the letters of the word "tortoise": TORTOISE - The Old Reptile Takes Ownership of Its Sluggish Existence\nHere is an acronym that uses the letters of the word "skateboard": SKATEBOARD - Sport Known Among Thrill-seekers Everywhere Because Of Adrenaline Rushes Delivered\nHere is an acronym that uses the letters of the word "love is blind": LOVE IS BLIND - Letting Our Vulnerability Expose Imperfections Shows that Beauty Lies In Noticing Differences\nHere is an acronym that uses the letters of the word "dumb luck": DUMB LUCK - Destiny Unleashes Miracles, Bringing Life\'s Unforeseen Consequences Kindly\nHere is an acronym that uses the letters of the word "yo-yo": YO-YO - Yanking Over Your Orbit\nHere is an acronym that uses the letters of the word "mannequin": MANNEQUIN - Mobile, Adjustable, Nondescript, and Naked Embodiment that Questions Universal Identity Norms',
'fuse': 'One way to practice creative thinking is to identify connections between seemingly unrelated things. For each pair of things below, we provide a creative example of something that both things have in common. Each connection is novel and unexpected, rather than an unoriginal technicality.\n\nHere is something that Thing 1 and Thing 2 have in common: airplane and grass\nBoth an airplane and grass defy gravity in their own way—an airplane by flying through the air, and grass by standing tall against the gravitational pull of the Earth.\n\nHere is something that Thing 1 and Thing 2 have in common: book and smoothie\nBoth a book and a smoothie can provide a sense of escape and transport the user to another world—a smoothie with its tropical flavors and aromas, and a book with its vivid descriptions and imaginative worlds.\n\nHere is something that Thing 1 and Thing 2 have in common: lantern and zebra\nBoth a lantern and a zebra can be associated with adventure and exploration—a lantern with its use in camping and outdoor activities, and a zebra with its association with the African wilderness and safari expeditions.\n\nHere is something that Thing 1 and Thing 2 have in common: priest and criminal\nBoth a priest and a criminal can challenge our perceptions of good and evil and illuminate the complexities of human nature—a priest by reminding us of the fallibility of even the most spiritual leaders, and a criminal by forcing us to confront the factors that may lead someone to a life of crime.\n\nHere is something that Thing 1 and Thing 2 have in common: hope and pity\nBoth hope and pity can be seen as responses to adversity—hope as a way of coping with and overcoming difficult situations, and pity as a way of acknowledging and sympathizing with those who have experienced hardship.\n\nHere is something that Thing 1 and Thing 2 have in common: art and war\nBoth art and war can be associated with conflict and tension—art with the contrast between light and dark, warm and cool, and war with the tension between adversaries.\n\nHere is something that Thing 1 and Thing 2 have in common: bridge and waterfall\nBoth a bridge and a waterfall can be symbols of perseverance and endurance—a bridge by its ability to withstand the test of time and the forces of nature, and a waterfall by its constant flow over time.\n\nHere is something that Thing 1 and Thing 2 have in common: work and sleep\nBoth work and sleep can be associated with the idea of surrender or release—work as a way to let go of our personal desires and serve the needs of a company, organization, or the greater good, and sleep as a way to surrender control and trust in the natural processes of our bodies and minds.\n\nHere is something that Thing 1 and Thing 2 have in common: baby and gun\nBoth a baby and a gun can be associated with a sense of risk and danger—a baby by its need to be handled with care to prevent injury or harm, and a gun by its ability to cause great harm in the wrong hands.',
'scene': 'Sensory details are details that appeal to the five senses: vision, hearing, touch, smell, and taste. Sensory details make our writing more interesting and vivid, and the most effective sensory details are ones that are creative yet concrete and evocative. For each thing below, we provide a list of sensory details that evoke that thing.\n\nHere is a thing: NYC subway car\nHere are some sensory details that evoke that thing:\n- A discarded slushie cup dripping red liquid onto a seat\n- The conductor saying something over the speaker, but the sound is too muffled to make out what they\'re saying\n- A person doing acrobatic maneuvers on the grab bars\n- Rats scurrying through the train tracks\n- A busker giving a mediocre performance\n\nHere is a thing: tech company office\nHere are some sensory details that evoke that thing:\n- A group of software engineers lounging in "nap pods"\n- Your boss joining a meeting from a desk that is attached to a treadmill\n- The crinkling of snack wrappers as a custodial worker replenishes the free snacks in the kitchen\n- Kombucha and cold brew on tap\n- Modern, angular furniture that isn\'t very comfortable \n\nHere is a thing: my abuela\nHere are some sensory details that evoke that thing:\n- A giant pot of rice and beans simmering on the stove\n- A tiny radio on the counter playing music from her home country\n- A rosary hanging on the wall\n- Her speaking to me in Spanish and me responding in English\n- The sound of knitting needles gently clanking together\n\nHere is a thing: standing in line at the DMV\nHere are some sensory details that evoke that thing:\n- An anxious teenager who is visibly dissatisfied with their new license photo but too nervous to ask to retake it\n- A pen with a plastic spoon taped to it to prevent people from taking it\n- A very loud air conditioning unit that is doing a poor job of cooling the place down\n- A woman with screaming children talking on the phone\n- A vaguely musty smell\n\nHere is a thing: boarding a plane\nHere are some sensory details that evoke that thing:\n- A faint smell of jet fumes as the plane taxis toward the runway\n- The pilot\'s voice over the speaker saying, "Attention passengers, this is your pilot speaking..."\n- A young child repeatedly opening and closing the window shade\n- A tiny dog stuffed in a carrier beneath the seat\n- A flight attendant explaining the emergency evacuation procedures to the people seated in the exit row\n\nHere is a thing: a Korean spa\nHere are some sensory details that evoke that thing:\n- The smell of eucalyptus and hot wood\n- The sound of a shocked gasp when a guest realizes that they have accidentally stepped into the cool bath instead of the hot bath\n- A heap of discarded white towels\n- A food court that sells all of the Korean food staples\n- Matching spa uniforms',
'unfold': "Slot a word into other words or phrases.\nHere is a target word: space\nHere are some ways the target word appears in other words and phrases:\n- outer space\n- space suit\n- Space Age (historical period)\n- backspace\n- space heater\n- parking space\n- space-time continuum\n- Space Invaders (video game)\n- crawl space\n- latent space\n- Lost in Space (TV series)\n\nHere is a target word: back\nHere are some ways the target word appears in other words and phrases:\n- backup\n- backpack\n- back-to-back\n- comeback\n- throwback\n- the straw that broke the camel's back\n- back and forth\n- callback\n- backgammon\n- back against the wall\n- back burner\n- circle back\n- dial back\n- have someone's back\n\nHere is a target word: run\nHere are some ways the target word appears in other words and phrases:\n- run away\n- home run\n- run for one's money\n- dry run\n- run the show\n- on the run\n- run a red light\n- run in circles\n- run for office\n- running on fumes\n- still waters run deep\n- runny nose\n\nHere is a target word: brain\nHere are some ways the target word appears in other words and phrases:\n- brainstorm\n- brain freeze\n- brain dead\n- pick someone's brain\n- brain fart\n- Pinky and The Brain (TV series)\n- brain bucket\n- brain tumor\n- rack one's brain\n- brain teaser\n- brain cramp\n- scatterbrained\n\nHere is a target word: jump\nHere are some ways the target word appears in other words and phrases:\n- jump-start\n- jump the gun\n- jump at the chance\n- jump the shark\n- jump ship\n- jump rope\n- jump on the bandwagon \n-jumpsuit \n-jump out of one's skin \n-jump to conclusions \n-jump for joy \n-hop, skip, and a jump\n\nHere is a target word: free \nHere are some ways the target word appears in other words and phrases: \n-free will \n-Free Willy (1993 film) \n-scot-free \n-free-for-all \n-freestyle \n-free time \n-freeloader \n-free agent \n-freehand \n-free range \n-home free \n-free rein \n-if you love someone, set them free\n\nHere is a target word: light \nHere are some ways the target word appears in other words and phrases: \n-spotlight \n-lightsaber \n-Northern Lights (Aurora Borealis) \n-light year \n-light at the end of the tunnel \n-trafic light \n-make light of \n-gaslight \n-light as a feather \n-red-light district \n-in light of \n-daylight \n-lights-out\n\nHere is a target word: i \nHere are some ways the target word appears in other words and phrases: \n-I-beam \n-dot the i's and cross the t's \n-iPhone \n-I-95 (interstate) \n-I, Robot (2004 film) \n-i.e. \n-IHOP (restaurant)\n\nHere is a target word: force \nHere are some ways the target word appears in other words and phrases: \n-workforce \n-tour de force \n-force field \n-force-feed \n-force of habit \n-force quit \n-force someone's hand \n-by force \n-brute force \n-force of nature \n-a force to be reckoned with \n-may the Force be with you (quote from Star Wars franchise)\n\nHere is a target word: bar \nHere are some ways the target word appears in other words and phrases: \n -raise the bar \n -bar of gold \n -bar fight \n -bar exam \n -bar of soap \n -bartender \n -handlebar \n -barcode \n -wine bar \n -bar mitzvah\n\nHere is a target word: 2 \nHere are some ways the target word appears in other words and phrases: \n -2-for 1 \n -two peas in a pod \n -two-ply \n -catch 22 \n -one-two combo \n -two-party system \n -two wrongs don't make a right \n -two cents"}
self.inputs = {'simile': "Here is a concept: {input_text}",
'explode': 'Here is a same-sounding phrase for the word "{input_text}":',
'unexpect': "Here is a scene: {input_text}",
'chain': 'Here is an example of a word chain beginning with "{input_text}":',
'pov': "Here are some hot takes about {input_text}:",
'aliteration': "Here is a topic: {input_text}\nHere are some examples of words that are related to that topic and start with the letter {letter}:",
'acronym': 'Here is an acronym that uses the letters of the word "{input_text}":',
'fuse': "Here is something that Thing 1 and Thing 2 have in common: {input_text}",
'scene': "Here is a thing: {input_text}",
'unfold': "Here is a target word: {input_text}" }
self.explanation = {'simile': "Create a simile about a thing or concept.",
'explode': 'Break a word into similar-sounding phrases.',
'unexpect': "Make a scene more unexpected and imaginative.",
'chain': 'Build a chain of semantically related items.',
'pov': "Evaluate a topic through different points of view.",
'aliteration': "Curate topic-specific words that start with a chosen letter.",
'acronym': 'Create an acronym using the letters of a word.',
'fuse': "Find intersections between two things (seperated by the word ' and ').",
'scene': "Generate sensory details about a scene.",
'unfold': "Slot a word into other words or phrases." }
self.labels = {'simile': "Enter a thing or concept:",
'explode': 'Enter a word:',
'unexpect': "Enter a scene:",
'chain': 'Enter a word:',
'pov': "Enter a topic:",
'aliteration': "Enter a topic:",
'acronym': 'Enter a word:',
'fuse': "Enter a thing:",
'scene': "Enter a scene:",
'unfold': "Enter a word:" }
# Define a method for adding a prompt to the list
def add_prompt(self, prompt_key, prompt):
self.prompts[prompt_key]=prompt
# Define a method for displaying the prompts
def show_prompts(self):
for prompt_key in self.prompts:
print(self.prompts[prompt_key])
# Define a method for displaying the prompts
def system_prompt(self,prompt_key):
return self.prompts[prompt_key]
# Define a method for displaying the prompts
def input_prompt(self,input_key):
return self.inputs[input_key]
# Define a method for displaying the prompts
def input_label(self,input_key):
return self.labels[input_key]
# Define a method for displaying the prompts
def show_explanation(self):
for prompt_key in self.explanation:
explanation = self.explanation[prompt_key]
result = "{}: {}".format(prompt_key,explanation)
print(result)
# Import streamlit library
import streamlit as st
import random
from llama_cpp import Llama
textfx = TextFX()
llm = Llama(model_path="C:\Models\dolphin-2.1-mistral-7b.Q5_K_M.gguf", n_ctx=16384)
# Define a function that takes a selectbox choice and a text input and returns a string
def my_function(mode, input_text, letter='A'):
system_prompt= textfx.system_prompt(mode)
input_prompt = textfx.input_prompt(mode)
if mode == 'aliteration':
input_prompt = input_prompt.format(input_text=input_text,letter=letter)
else:
input_prompt = input_prompt.format(input_text=input_text)
prompt_template = f"""<|im_start|>system
{system_prompt}"""
start = f"""<|im_end|>
<|im_start|>user
{input_prompt}<|im_end|>
<|im_start|>assistant
"""
output = llm(prompt_template+start, stop=["<|im_end|>"], echo=False, stream=False, max_tokens=512)
return output['choices'][0]['text']
# Define a list of choices for the selectbox
choices = ["simile", "explode", "unexpect", "chain", "pov", "aliteration", "acronym", "fuse", "scene", "unfold"]
# Add a block of text above the dropdown
st.write("""simile: Create a simile about a thing or concept.
explode: Break a word into similar-sounding phrases.
unexpect: Make a scene more unexpected and imaginative.
chain: Build a chain of semantically related items.
pov: Evaluate a topic through different points of view.
aliteration: Curate topic-specific words that start with a chosen letter.
acronym: Create an acronym using the letters of a word.
fuse: Find intersections between two things (seperated by the word ' and ').
scene: Generate sensory details about a scene.
unfold: Slot a word into other words or phrases.""")
# Create a selectbox with st.selectbox
mode = st.selectbox(label="Please choose an option", options=choices, key="option")
# Get the label from the dictionary using the choice as the key
label = textfx.input_label(mode)
# Create two columns with st.columns
col1, col2 = st.columns(2)
# If the choice is AaB, create an extra selectbox with random letter in the second column
if mode == 'aliteration':
# Define a list of letters for the selectbox
letters = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
# Check if the session state has the random letter variable
if 'random_letter' not in st.session_state:
# If not, generate a random letter using random.choice and assign it to the session state variable
st.session_state.random_letter = random.choice(letters)
# Get the index of the random letter in the list
index = letters.index(st.session_state.random_letter)
# Create a text input in the first column with st.text_input using the label
with col1:
text_input = st.text_input(label=label)
# Create a selectbox in the second column with st.selectbox using the letters, index, and format_func
with col2:
letter = st.selectbox(label="Words starting with:", options=letters, index=index, format_func=lambda x: x.upper())
elif mode == 'fuse':
# Create a text input in the first column with st.text_input using the label
with col1:
text_input = st.text_input(label=label)
# Create a selectbox in the second column with st.selectbox using the letters, index, and format_func
with col2:
text_input2 = st.text_input(label="Enter another one:")
else:
# Create a text input in the first column with st.text_input using the label
with col1:
text_input = st.text_input(label=label)
# Set the letter to an empty string
letter = ''
# Create two columns with st.columns
col3, col4 = st.columns(2)
with col3:
show_prompt = st.button("Show System Prompt")
with col4:
# Create a run button with st.button
run_button = st.button("Run")
# If the run button was clicked and the text input is not empty, call the function and display the output
if run_button and text_input:
if mode == 'fuse':
output = my_function(mode, text_input + " and " + text_input2)
elif mode == 'fuse':
output = my_function(mode, text_input, letter=letter)
else:
output = my_function(mode, text_input)
# Use st.text_area with value parameter to display the output in a text area
st.text_area(label="Output", value=output, height=500)
if show_prompt:
st.text_area(label="System Prompt", value=textfx.system_prompt(mode), height=1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment