Load a prompt from a file. Args: template_file: The path to the file containing the prompt template. input_variables: [DEPRECATED] A list of variable names the final prompt template will expect. input_variables is ignored as from_file now del
(
cls,
template_file: Union[str, Path],
input_variables: Optional[List[str]] = None,
**kwargs: Any,
)
| 196 | |
| 197 | @classmethod |
| 198 | def from_file( |
| 199 | cls, |
| 200 | template_file: Union[str, Path], |
| 201 | input_variables: Optional[List[str]] = None, |
| 202 | **kwargs: Any, |
| 203 | ) -> PromptTemplate: |
| 204 | """Load a prompt from a file. |
| 205 | |
| 206 | Args: |
| 207 | template_file: The path to the file containing the prompt template. |
| 208 | input_variables: [DEPRECATED] A list of variable names the final prompt |
| 209 | template will expect. |
| 210 | |
| 211 | input_variables is ignored as from_file now delegates to from_template(). |
| 212 | |
| 213 | Returns: |
| 214 | The prompt loaded from the file. |
| 215 | """ |
| 216 | with open(str(template_file), "r") as f: |
| 217 | template = f.read() |
| 218 | if input_variables: |
| 219 | warnings.warn( |
| 220 | "`input_variables' is deprecated and ignored.", DeprecationWarning |
| 221 | ) |
| 222 | return cls.from_template(template=template, **kwargs) |
| 223 | |
| 224 | @classmethod |
| 225 | def from_template( |