from_template() — langchain Function Reference
Architecture documentation for the from_template() function in chat.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD fb7525a5_49cc_cee5_9a12_dffafec8f35b["from_template()"] 6be4a9a5_5fe4_e64f_c374_e63767576bf6["ChatPromptTemplate"] fb7525a5_49cc_cee5_9a12_dffafec8f35b -->|defined in| 6be4a9a5_5fe4_e64f_c374_e63767576bf6 868943e8_3763_c08b_6ee7_cd2801948c3a["from_messages()"] fb7525a5_49cc_cee5_9a12_dffafec8f35b -->|calls| 868943e8_3763_c08b_6ee7_cd2801948c3a 6966af16_ade2_de3e_4f06_f97eca43d8e0["from_template()"] fb7525a5_49cc_cee5_9a12_dffafec8f35b -->|calls| 6966af16_ade2_de3e_4f06_f97eca43d8e0 style fb7525a5_49cc_cee5_9a12_dffafec8f35b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/chat.py lines 1101–1116
def from_template(cls, template: str, **kwargs: Any) -> ChatPromptTemplate:
"""Create a chat prompt template from a template string.
Creates a chat template consisting of a single message assumed to be from the
human.
Args:
template: Template string
**kwargs: Keyword arguments to pass to the constructor.
Returns:
A new instance of this class.
"""
prompt_template = PromptTemplate.from_template(template, **kwargs)
message = HumanMessagePromptTemplate(prompt=prompt_template)
return cls.from_messages([message])
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does from_template() do?
from_template() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/chat.py.
Where is from_template() defined?
from_template() is defined in libs/core/langchain_core/prompts/chat.py at line 1101.
What does from_template() call?
from_template() calls 2 function(s): from_messages, from_template.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free