Exemplo n.º 1
0
def newStory(generator, prompt, context):
    story = Story(generator, prompt)
    assert (story.prompt)
    first_result = story.act(context)
    colPrint(prompt, colors['user-text'], end='')
    colPrint(context, colors['user-text'], end='')
    colPrint(first_result[0], colors['ai-text'], end='')
    print("\n\n")
    return story
Exemplo n.º 2
0
def load_story(f, gen):
    with f.open('r', encoding="utf-8") as file:
        try:
            story = Story(gen, "")
            story.savefile = os.path.splitext(file.name.strip())[0]
            story.from_json(file.read())
            return story, story.context, story.actions[-1] if len(
                story.actions) > 0 else ""
        except FileNotFoundError:
            output("Save file not found. ", "error")
        except IOError:
            output("Something went wrong; aborting. ", "error")
    return None, None, None
Exemplo n.º 3
0
def new_story(generator, context, prompt, memory=None, first_result=None):
    if memory is None:
        memory = []
    context = context.strip()
    prompt = prompt.strip()
    story = Story(generator, context, memory)
    if first_result is None:
        story.act(prompt)
    else:
        story.actions.append(prompt)
        story.results.append(first_result)
    story.print_story()
    return story
Exemplo n.º 4
0
def new_story(generator, context, prompt, memory=None, first_result=None):
    if memory is None:
        memory = []
    context = context.strip()
    prompt = prompt.strip()
    erase = 0
    if use_ptoolkit():
        erase = output(context, 'user-text', prompt, 'user-text', sep="\n\n")
    story = Story(generator, context, memory)
    if first_result is None:
        story.act(prompt)
    else:
        story.actions.append(prompt)
        story.results.append(first_result)
    clear_lines(erase)
    story.print_story()
    return story