mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
50484be330
Added missed docstrings. Format docstrings to the consistent format (used in the API Reference) --------- Co-authored-by: ccurme <chester.curme@gmail.com>
17 lines
492 B
Python
17 lines
492 B
Python
from langchain_core.utils import mustache
|
|
from pydantic import BaseModel
|
|
|
|
from .core import Invoker, Prompty, SimpleModel
|
|
|
|
|
|
class MustacheRenderer(Invoker):
|
|
"""Render a mustache template."""
|
|
|
|
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)
|