mirror of
https://github.com/langgenius/dify.git
synced 2026-03-27 01:00:13 +08:00
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WH-2099 <wh2099@pm.me>
19 lines
530 B
Python
19 lines
530 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
|
|
class TemplateRenderError(ValueError):
|
|
"""Raised when rendering a template fails."""
|
|
|
|
|
|
class Jinja2TemplateRenderer(ABC):
|
|
"""Nominal renderer contract for Jinja2 template rendering in graph nodes."""
|
|
|
|
@abstractmethod
|
|
def render_template(self, template: str, variables: Mapping[str, Any]) -> str:
|
|
"""Render the template into plain text."""
|
|
raise NotImplementedError
|