Allow manually setting options, decode to utf-8

This commit is contained in:
Anthony Wang 2024-02-04 22:16:52 -05:00
parent 71ec146f2f
commit cbfd21dff8
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ

View file

@ -19,12 +19,19 @@ options = [
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 this very sarcastic and exaggerated book win the Pulitzer prize!!! That's how mind-blowingly good it should be!!!\n" 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 this very sarcastic and exaggerated book win the Pulitzer prize!!! That's how mind-blowingly good it should be!!!\n"
for i in options: for i in options:
if len(sys.argv) > 1: if len(sys.argv) > 1:
c = i[1][int(input(list(zip(range(10), i[1]))))] inp = input(list(zip(range(10), i[1])))
else: else:
inp == ""
if inp == "":
c = random.choice(i[1]) 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 += i[0] + ": " + c + "\n"
prompt += "\nSure! Here's the extremely long and detailed 2468-word book you requested:\n\n" prompt += "\nSure! Here's the extremely long and detailed 2468-word book you requested:\n\n"
r = requests.post("http://boss-baby:8080/completion", json={"prompt": prompt, "temperature": 1.0, "repeat_last_n": 1024, "stream": True}, headers={"Authorization": "Bearer 12345"}, stream=True) r = requests.post("http://boss-baby:8080/completion", json={"prompt": prompt, "temperature": 1.0, "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): for chunk in r.iter_lines(decode_unicode=True):
if chunk != "": if chunk != "":
print(json.loads(chunk[6:])["content"], end='', flush=True) print(json.loads(chunk[6:])["content"], end='', flush=True)