mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 04:04:14 +00:00
26 lines
554 B
Python
26 lines
554 B
Python
from dataclasses import dataclass
|
|
from typing import Any, Dict, List
|
|
|
|
from jinja2 import Template
|
|
|
|
|
|
@dataclass
|
|
class PromptTemplate:
|
|
template: str
|
|
data: Dict[str, Any]
|
|
|
|
def render(self):
|
|
template = Template(self.template)
|
|
return template.render(self.data)
|
|
|
|
|
|
class PromptTemplateGeneratorBase:
|
|
"""
|
|
Base class for prompt template generators.
|
|
"""
|
|
|
|
def gen(self, *args, **kwargs) -> PromptTemplate:
|
|
raise NotImplementedError()
|
|
|
|
def data_examples(self) -> List[Any]:
|
|
raise NotImplementedError()
|