MCPcopy
hub / github.com/langchain-ai/langchain / from_file

Method from_file

libs/core/langchain_core/prompts/prompt.py:198–222  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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(

Callers 4

test_prompt_from_fileFunction · 0.45
from_template_fileMethod · 0.45
base.pyFile · 0.45

Calls 2

readMethod · 0.45
from_templateMethod · 0.45