File size: 699 Bytes
3eaf131
 
49a7070
3eaf131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pprint import pprint
from . import storyteller_general
from . import paraphraser

'''
basic function that substitues variables in the prompt template and returns a ready prompt
'''
def get(prompt_name, substitutions={}):

    pprint(prompt_name)

    #check if such a prompt template exists
    if prompt_name not in globals():
        raise NameError(f"The variable {prompt_name} is not defined.")

    #load the prompt_template
    prompt_template = globals().get(prompt_name).template

    if not prompt_template:
        raise NameError(f"The variable {prompt_name} is not loaded poperly.")

    prompt = prompt_template.substitute(substitutions)

    #return the propmt

    return prompt