Spaces:
Running
Running
File size: 453 Bytes
ed4d993 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from langchain_core.utils import mustache
from pydantic import BaseModel
from .core import Invoker, Prompty, SimpleModel
class MustacheRenderer(Invoker):
def __init__(self, prompty: Prompty) -> None:
self.prompty = prompty
def invoke(self, data: BaseModel) -> BaseModel:
assert isinstance(data, SimpleModel)
generated = mustache.render(self.prompty.content, data.item)
return SimpleModel[str](item=generated)
|