langchain_core.prompts.string.jinja2_formatter¶

langchain_core.prompts.string.jinja2_formatter(template: str, **kwargs: Any) str[source]¶

Format a template using jinja2.

Security warning: As of LangChain 0.0.329, this method uses Jinja2’s

SandboxedEnvironment by default. However, this sand-boxing should be treated as a best-effort approach rather than a guarantee of security. Do not accept jinja2 templates from untrusted sources as they may lead to arbitrary Python code execution.

https://jinja.palletsprojects.com/en/3.1.x/sandbox/

Parameters
  • template (str) –

  • kwargs (Any) –

Return type

str