From 1c753d1e813bca25dda5a873bf61012d83cbb8b5 Mon Sep 17 00:00:00 2001 From: Tibor Reiss <75096465+tibor-reiss@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:09:42 +0200 Subject: [PATCH] core[patch]: Update typing for template format to include jinja2 as a Literal (#24144) Fixes #23929 via adjusting the typing --- libs/core/langchain_core/prompts/chat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/core/langchain_core/prompts/chat.py b/libs/core/langchain_core/prompts/chat.py index 82b1478d687..dc13609b89f 100644 --- a/libs/core/langchain_core/prompts/chat.py +++ b/libs/core/langchain_core/prompts/chat.py @@ -1060,7 +1060,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate): def from_messages( cls, messages: Sequence[MessageLikeRepresentation], - template_format: Literal["f-string", "mustache"] = "f-string", + template_format: Literal["f-string", "mustache", "jinja2"] = "f-string", ) -> ChatPromptTemplate: """Create a chat prompt template from a variety of message formats. @@ -1274,7 +1274,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate): def _create_template_from_message_type( message_type: str, template: Union[str, list], - template_format: Literal["f-string", "mustache"] = "f-string", + template_format: Literal["f-string", "mustache", "jinja2"] = "f-string", ) -> BaseMessagePromptTemplate: """Create a message prompt template from a message type and template string. @@ -1341,7 +1341,7 @@ def _create_template_from_message_type( def _convert_to_message( message: MessageLikeRepresentation, - template_format: Literal["f-string", "mustache"] = "f-string", + template_format: Literal["f-string", "mustache", "jinja2"] = "f-string", ) -> Union[BaseMessage, BaseMessagePromptTemplate, BaseChatPromptTemplate]: """Instantiate a message from a variety of message formats.