homeros_demo / prompts /__init__.py
papayaga's picture
voice generation and first story working
49a7070
raw
history blame contribute delete
699 Bytes
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