Skip to content

The agent engineering platform.

docs: change for optional variables in chatprompt (#25017)

BhujayKumarBhatta8f33fce87159
diff --git a/libs/core/langchain_core/prompts/base.py b/libs/core/langchain_core/prompts/base.py
index 6b0db3598f..a58f916d4a 100644
--- a/libs/core/langchain_core/prompts/base.py
+++ b/libs/core/langchain_core/prompts/base.py
@@ -46,7 +46,9 @@ class BasePromptTemplate(
"""A list of the names of the variables whose values are required as inputs to the
prompt."""
optional_variables: List[str] = Field(default=[])
- """A list of the names of the variables that are optional in the prompt."""
+ """optional_variables: A list of the names of the variables for placeholder
+ or MessagePlaceholder that are optional. These variables are auto inferred
+ from the prompt and user need not provide them."""
input_types: Dict[str, Any] = Field(default_factory=dict, exclude=True)
"""A dictionary of the types of the variables the prompt template expects.
If not provided, all variables are assumed to be strings."""
diff --git a/libs/core/langchain_core/prompts/chat.py b/libs/core/langchain_core/prompts/chat.py
index fed0438b00..bf8596c759 100644
--- a/libs/core/langchain_core/prompts/chat.py
+++ b/libs/core/langchain_core/prompts/chat.py
@@ -946,8 +946,9 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
template_format: format of the template. Defaults to "f-string".
input_variables: A list of the names of the variables whose values are
required as inputs to the prompt.
- optional_variables: A list of the names of the variables that are optional
- in the prompt.
+ optional_variables: A list of the names of the variables for placeholder
+ or MessagePlaceholder that are optional. These variables are auto inferred
+ from the prompt and user need not provide them.
partial_variables: A dictionary of the partial variables the prompt
template carries. Partial variables populate the template so that you
don't need to pass them in every time you call the prompt.