Spaces:
Sleeping
Sleeping
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 | |