From 8f33fce87159fd6a8e96d3b6c4bc27c8d4298cc8 Mon Sep 17 00:00:00 2001 From: BhujayKumarBhatta Date: Tue, 6 Aug 2024 05:27:44 +0530 Subject: [PATCH] docs: change for optional variables in chatprompt (#25017) Fixes #24884 --- libs/core/langchain_core/prompts/base.py | 4 +++- libs/core/langchain_core/prompts/chat.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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.