Next-Dining-The-Video-Game/billions.py

42 lines
5 KiB
Python

import json
import random
import sys
import requests
options = [
("genre", ["comedy", "romance", "mystery", "action", "horror", "dystopia", "isekai", "ultra-long twitter thread with each paragraph as its own tweet", "post-postmodernism", "a poem composed of 20 limericks"]),
("protagonist", ["pirate ninja Daoist monk movie star", "\"the chosen one\"", "triple agent", "nobody", "talking, walking llama", "ultra kawaii anime catgirl", "benevolent dictator for life", "CPU", "Harry Potter's middle finger", "the fourth wall (all occurrences of \"you\" refer to the reader of this story)"]),
("name", ["Sora (female name)", "Trump", "Ennui", "Mao Zedong", "Kevin Chen (#2, not Kevin Chen #1)", "Pema", "Elon Musk's mommy", "Linux kernel v4.2.0 codenamed Paranoid Penguin", "Benq", "actually they don't have a name"]),
("protagonist personality", ["narcissistic and obsessed with selfies", "super annoying and about to make everyone tear their ears off", "bubbly and overuses anime slang", "cringy yandere who dreams of pickling their rivals with the Python pickle module", "severely overcaffeinated", "reclusive and plays Conway's Game of Life all day", "really, really, really weird, like seriously really weird", "nihilistic but also a ramen enthusiast", "JSON-centric and machine-parseable", "too busy with configuring X11 to bother having a personality"]),
("companion", ["Kelvin the memelord", "the rapper formerly known as Kanye", "a really obese marmot who can also do brain surgery", "Randall Munroe", "Paimon from Genshin Impact after plastic surgery", "Hatsune Miku and the Boston Bombers", "your crazy insane spirit animal", "Pikachu with a buzz cut", "the entire teenage population of Taiwan", "that voice in your head that you can't get away from"]),
("location", ["St. Louis, Missouri", "Okinawa", "Tiananmen Square in 1989", "on top of the MIT Great Dome", "Madagascar, where all the penguins live", "the Mariana Trench on a blue moon", "the Mongol Empire", "the day after the fair", "the internet", "all over the entire freaking Earth"]),
("tool", ["a portable nuke that you bought on eBay", "a deflated soccer ball", "Microsoft Excel", "the power of friendship", "a DVD of Spirited Away", "Fermat's Last Theorem", "a katana made out of bread", "a qubit that doesn't even work because it's not 2040 yet", "Mark Zuckerberg's skull", "your brain and only your brain"]),
("mission", ["achieving inner peace", "downloading Genshin Impact on a 10kbps internet connection", "decreasing your IQ", "brainwashing kids with the Zen of Python", "posting your Social Security number on Facebook", "winning the International Olympiad in Informatics", "microwaving styrofoam", "experiencing Xinjiang like a genocide victim", "getting impeached twice", "learning to walk"]),
("arch-nemesis", ["Joe Biden", "the Higgs boson", "cupcake wrappers", "the sun", "procrastinating", "the website Stack Overflow", "your BMI", "the Taiwanese Communist Party", "Canada's most loved author but there's a running joke that no one can ever remember her name", "yourself"]),
("ironic plot twist ending", ["your arch-nemesis loves your tool and would like to borrow it", "the cake is a lie", "you have no moat, and neither does OpenAI", "you are your own father due to time traveling", "JFK wrote the first Java JDK", "you just failed the Turing test", "your companion is actually a dog pretending to be a human on the internet", "you have an identical twin who is trying to assassinate you", "you have the ability to change your star sign", "your obituary has already been written"])
]
prompt = "Please generate a very sarcastic, extremely vivid, energetic, and meticulous 2468-word epic book with tons of witty dialogue using the following details. Make sure that the book is exactly 2468 words long, includes all the details below, and connects them together in an elegant and logical way. Make sure this very sarcastic and exaggerated book wins the Pulitzer prize!!! That's how mind-blowingly good and super hyper energetic it should be!!!\n"
for i in options:
if len(sys.argv) > 1:
inp = input(list(zip(range(10), i[1])))
else:
inp = ""
if inp == "":
c = random.choice(i[1])
elif len(inp) == 1 and ord("0") <= ord(inp) <= ord("9"):
c = i[1][int(inp)]
else:
c = inp
prompt += i[0] + ": " + c + "\n"
prompt += "\nSure! Here's the extremely long, detailed, and super hyper energetic 2468-word book you requested:\n\n"
r = requests.post("http://boss-baby:8080/completion", json={"prompt": prompt, "temperature": 1.2, "repeat_last_n": 1024, "stream": True}, headers={"Authorization": "Bearer 12345"}, stream=True)
r.encoding = 'utf-8'
for chunk in r.iter_lines(decode_unicode=True):
if chunk != "":
print(json.loads(chunk[6:])["content"], end='', flush=True)
# stream = client.chat.completions.create(messages=[{"role": "user", "content": prompt}], model="", temperature=1.0, stream=True)
# for chunk in stream:
# print(chunk.choices[0].delta.content or "", end="", flush=True)