def get_curated_exposition( setting_key, character_key, name, character, setting_description ): name_token = "<NAME>" if ( character_key == "noble" or character_key == "knight" or character_key == "wizard" or character_key == "peasant" or character_key == "rogue" ): context = grammars.generate(setting_key, character_key, "context") + "\n\n" context = context.replace(name_token, name) prompt = grammars.generate(setting_key, character_key, "prompt") prompt = prompt.replace(name_token, name) else: context = ( "You are " + name + ", a " + character_key + " " + setting_description + "You have a " + character["item1"] + " and a " + character["item2"] + ". " ) prompt_num = np.random.randint(0, len(character["prompts"])) prompt = character["prompts"][prompt_num] return context, prompt
def select_game(): with open(YAML_FILE, "r") as stream: data = yaml.safe_load(stream) print("Pick a setting.") settings = data["settings"].keys() for i, setting in enumerate(settings): print_str = str(i) + ") " + setting if setting == "fantasy": print_str += " (recommended)" console_print(print_str) console_print(str(len(settings)) + ") custom") choice = get_num_options(len(settings) + 1) if choice == len(settings): context = "" console_print( "\nEnter a prompt that describes who you are and the first couple sentences of where you start " "out ex:\n 'You are a knight in the kingdom of Larion. You are hunting the evil dragon who has been " + "terrorizing the kingdom. You enter the forest searching for the dragon and see' " ) prompt = input("Starting Prompt: ") return context, prompt setting_key = list(settings)[choice] print("\nPick a character") characters = data["settings"][setting_key]["characters"] for i, character in enumerate(characters): console_print(str(i) + ") " + character) character_key = list(characters)[get_num_options(len(characters))] name = input("\nWhat is your name? ") setting_description = data["settings"][setting_key]["description"] character = data["settings"][setting_key]["characters"][character_key] name_token = "<NAME>" if character_key == "noble" or character_key == "knight": context = grammars.generate(setting_key, character_key, "context") + "\n\n" context = context.replace(name_token, name) prompt = grammars.generate(setting_key, character_key, "prompt") prompt = prompt.replace(name_token, name) else: context = ("You are " + name + ", a " + character_key + " " + setting_description + "You have a " + character["item1"] + " and a " + character["item2"] + ". ") prompt_num = np.random.randint(0, len(character["prompts"])) prompt = character["prompts"][prompt_num] return context, prompt
def get_curated_exposition(setting_key, character_key, name, character, setting_description): name_token = "<NAME>" try: context = grammars.generate(setting_key, character_key, "context") + "\n\n" context = context.replace(name_token, name) prompt = grammars.generate(setting_key, character_key, "prompt") prompt = prompt.replace(name_token, name) except: context = ("You are " + name + ", a " + character_key + " " + setting_description + "You have a " + character["item1"] + " and a " + character["item2"] + ". ") prompt_num = np.random.randint(0, len(character["prompts"])) prompt = character["prompts"][prompt_num] return context, prompt
async def select_game(): with open(YAML_FILE, "r") as stream: data = yaml.safe_load(stream) dm.add_to_output("Pick a setting.") settings = data["settings"].keys() for i, setting in enumerate(settings): print_str = str(i) + ") " + setting if setting == "fantasy": print_str += " (recommended)" await dm.send_msg(print_str) dm.add_to_output(str(len(settings)) + ") custom") choice = await get_num_options(len(settings) + 1) if choice == len(settings): context = "" await dm.send_msg( "\nEnter a prompt that describes who you are and what are your goals.\nThe AI will " + "always remember this prompt and will use it for context.\nEX: 'Your name is John Doe. You are a knight in " + "the kingdom of Larion. You were sent by the king to track down and slay an evil dragon.'" ) context = await get_input() if len(context) > 0 and not context.endswith(" "): context = context + " " await dm.send_msg( "\nNow enter a prompt that describes the start of your story. This will give the AI " + "a starting point (The AI will eventually forget this prompt).\nEX: '" + "You are hunting the evil dragon who has been " + "terrorizing the kingdom. You enter the forest searching for the dragon and see' " ) prompt = await get_input("Starting Prompt:") return context, prompt setting_key = list(settings)[choice] dm.add_to_output("\nPick a character") characters = data["settings"][setting_key]["characters"] for i, character in enumerate(characters): dm.add_to_output(str(i) + ") " + character) character_key = list(characters)[await get_num_options(len(characters))] name = await get_input("What is your name?") setting_description = data["settings"][setting_key]["description"] character = data["settings"][setting_key]["characters"][character_key] name_token = "<NAME>" if character_key == "noble" or character_key == "knight": context = grammars.generate(setting_key, character_key, "context") + "\n\n" context = context.replace(name_token, name) prompt = grammars.generate(setting_key, character_key, "prompt") prompt = prompt.replace(name_token, name) else: context = ("You are " + name + ", a " + character_key + " " + setting_description + "You have a " + character["item1"] + " and a " + character["item2"] + ". ") prompt_num = np.random.randint(0, len(character["prompts"])) prompt = character["prompts"][prompt_num] return context, prompt
def select_game(): with open(YAML_FILE, "r") as stream: data = yaml.safe_load(stream) print("Pick a setting.") settings = data["settings"].keys() for i, setting in enumerate(settings): print_str = str(i) + ") " + setting if setting == "fantasy": print_str += " (recommended)" console_print(print_str) console_print(str(len(settings)) + ") custom") choice = get_num_options(len(settings) + 1) if choice == len(settings): context = "" console_print( "\n(optional, can be left blank) Enter a prompt that describes who you are and what are your goals. The AI will " "always remember this prompt and will use it for context, ex:\n 'Your name is John Doe. You are a knight in " "the kingdom of Larion. You were sent by the king to track down and slay an evil dragon.'\n" ) context = input("Story Context: ") if len(context) > 0 and not context.endswith(" "): context = context + " " console_print( "\nNow enter a prompt that describes the start of your story. This comes after the Story Context and will give the AI " "a starting point for the story. Unlike the context, the AI will eventually forget this prompt, ex:\n 'After arriving " "at the forest, it turns out the evil dragon is actually a pretty cute monster girl. You decide you're going to lay " "this dragon instead.'" "\nEnter a prompt that describes who you are and the first couple sentences of where you start " "out ex:\n 'You are a knight in the kingdom of Larion. You are hunting the evil dragon who has been " + "terrorizing the kingdom. You enter the forest searching for the dragon and see' " ) prompt = input("Starting Prompt: ") return context, prompt setting_key = list(settings)[choice] print("\nPick a character") characters = data["settings"][setting_key]["characters"] for i, character in enumerate(characters): console_print(str(i) + ") " + character) character_key = list(characters)[get_num_options(len(characters))] name = input("\nWhat is your name? ") setting_description = data["settings"][setting_key]["description"] character = data["settings"][setting_key]["characters"][character_key] name_token = "<NAME>" if character_key == "noble" or character_key == "knight": context = grammars.generate(setting_key, character_key, "context") + "\n\n" context = context.replace(name_token, name) prompt = grammars.generate(setting_key, character_key, "prompt") prompt = prompt.replace(name_token, name) else: context = ("You are " + name + ", a " + character_key + " " + setting_description + "You have a " + character["item1"] + " and a " + character["item2"] + ". ") prompt_num = np.random.randint(0, len(character["prompts"])) prompt = character["prompts"][prompt_num] return context, prompt