partial() — langchain Function Reference
Architecture documentation for the partial() function in chat.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 490adae9_6c8b_f224_cfeb_133ca6ea29c8["partial()"] 6be4a9a5_5fe4_e64f_c374_e63767576bf6["ChatPromptTemplate"] 490adae9_6c8b_f224_cfeb_133ca6ea29c8 -->|defined in| 6be4a9a5_5fe4_e64f_c374_e63767576bf6 05fbd76f_5319_5d90_fd32_8ae595f01924["__add__()"] 05fbd76f_5319_5d90_fd32_8ae595f01924 -->|calls| 490adae9_6c8b_f224_cfeb_133ca6ea29c8 868943e8_3763_c08b_6ee7_cd2801948c3a["from_messages()"] 490adae9_6c8b_f224_cfeb_133ca6ea29c8 -->|calls| 868943e8_3763_c08b_6ee7_cd2801948c3a a912d932_8157_994e_b37d_ed55e4821d34["format_messages()"] 490adae9_6c8b_f224_cfeb_133ca6ea29c8 -->|calls| a912d932_8157_994e_b37d_ed55e4821d34 style 490adae9_6c8b_f224_cfeb_133ca6ea29c8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/chat.py lines 1225–1258
def partial(self, **kwargs: Any) -> ChatPromptTemplate:
"""Get a new `ChatPromptTemplate` with some input variables already filled in.
Args:
**kwargs: Keyword arguments to use for filling in template variables.
Ought to be a subset of the input variables.
Returns:
A new `ChatPromptTemplate`.
Example:
```python
from langchain_core.prompts import ChatPromptTemplate
template = ChatPromptTemplate.from_messages(
[
("system", "You are an AI assistant named {name}."),
("human", "Hi I'm {user}"),
("ai", "Hi there, {user}, I'm {name}."),
("human", "{input}"),
]
)
template2 = template.partial(user="Lucy", name="R2D2")
template2.format_messages(input="hello")
```
"""
prompt_dict = self.__dict__.copy()
prompt_dict["input_variables"] = list(
set(self.input_variables).difference(kwargs)
)
prompt_dict["partial_variables"] = {**self.partial_variables, **kwargs}
return type(self)(**prompt_dict)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does partial() do?
partial() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/chat.py.
Where is partial() defined?
partial() is defined in libs/core/langchain_core/prompts/chat.py at line 1225.
What does partial() call?
partial() calls 2 function(s): format_messages, from_messages.
What calls partial()?
partial() is called by 1 function(s): __add__.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free