Created
July 6, 2023 23:54
-
-
Save sampoder/407d146b637c06f096c80894828177df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This is very hacky and jank but I made it for a bit of fun! | |
import openai | |
def generateNextParagraph(previous_with_choices, past, choice): | |
completion = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[{"role": "user", "content": f""" | |
{previous_with_choices} | |
The user choose Choice {choice}. Write the next paragraph of this choose your own adventure story and finish by providing three choices in the format of: | |
Choice 1: THE CHOICE | |
Choice 2: THE CHOICE | |
Choice 3: THE CHOICE"""}] | |
) | |
print(f"\n {completion.choices[0].message.content}") | |
text_no_choices = completion.choices[0].message.content.split("Choice 1")[0] | |
new_past = past + f"\n {text_no_choices}" | |
past_with_choices = past + f"\n {completion.choices[0].message.content}" | |
print("\nWhat do you choose (1 / 2 / 3)?", end =" ") | |
new_choice = input() | |
generateNextParagraph(past_with_choices, new_past, new_choice) | |
completion = openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[{"role": "user", "content": f"""Write the first paragraph of a choose your own adventure story and finish by providing three choices in the format of: | |
Choice 1: THE CHOICE | |
Choice 2: THE CHOICE | |
Choice 3: THE CHOICE"""}] | |
) | |
print(completion.choices[0].message.content) | |
text_no_choices = completion.choices[0].message.content.split("Choice 1")[0] | |
print("\nWhat do you choose (1 / 2 / 3)?", end =" ") | |
new_choice = input() | |
generateNextParagraph(completion.choices[0].message.content, text_no_choices, new_choice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment