ar08's picture
Upload 1040 files
246d201 verified
raw
history blame contribute delete
689 Bytes
import os
from utils import load_file
PROMPT_DIR = os.path.dirname(__file__)
TEMPLATE_WITH_TOOL = load_file(os.path.join(PROMPT_DIR, 'template_with_tool.txt'))
class PromptTemplate:
"""A prompt template."""
def __init__(self, template: str):
self.template: str = template
def __call__(self, **kwargs) -> str:
return self.template.format(**kwargs)
class ToolPromptTemplate(PromptTemplate):
def __init__(self, use_tool: bool):
if use_tool:
template = TEMPLATE_WITH_TOOL
else:
raise NotImplementedError('Evaluation without tool is not supported yet.')
super().__init__(template)