Load the prompt template from config.
(config: dict)
| 107 | |
| 108 | |
| 109 | def _load_prompt(config: dict) -> PromptTemplate: |
| 110 | """Load the prompt template from config.""" |
| 111 | # Load the template from disk if necessary. |
| 112 | config = _load_template("template", config) |
| 113 | config = _load_output_parser(config) |
| 114 | |
| 115 | template_format = config.get("template_format", "f-string") |
| 116 | if template_format == "jinja2": |
| 117 | # Disabled due to: |
| 118 | # https://github.com/langchain-ai/langchain/issues/4394 |
| 119 | raise ValueError( |
| 120 | f"Loading templates with '{template_format}' format is no longer supported " |
| 121 | f"since it can lead to arbitrary code execution. Please migrate to using " |
| 122 | f"the 'f-string' template format, which does not suffer from this issue." |
| 123 | ) |
| 124 | |
| 125 | return PromptTemplate(**config) |
| 126 | |
| 127 | |
| 128 | def load_prompt( |
nothing calls this directly
no test coverage detected