Skip to content

Commit 6dcca35

Browse files
authored
fix(core): correct return type hints in BaseChatPromptTemplate (#32009)
This PR changes the return type hints of the `format_prompt` and `aformat_prompt` methods in `BaseChatPromptTemplate` from `PromptValue` to `ChatPromptValue`. Since both methods always return a `ChatPromptValue`.
1 parent d57216c commit 6dcca35

File tree

1 file changed

+6
-6
lines changed
  • libs/core/langchain_core/prompts

1 file changed

+6
-6
lines changed

libs/core/langchain_core/prompts/chat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
convert_to_messages,
3636
)
3737
from langchain_core.messages.base import get_msg_title_repr
38-
from langchain_core.prompt_values import ChatPromptValue, ImageURL, PromptValue
38+
from langchain_core.prompt_values import ChatPromptValue, ImageURL
3939
from langchain_core.prompts.base import BasePromptTemplate
4040
from langchain_core.prompts.dict import DictPromptTemplate
4141
from langchain_core.prompts.image import ImagePromptTemplate
@@ -715,20 +715,20 @@ async def aformat(self, **kwargs: Any) -> str:
715715
"""
716716
return (await self.aformat_prompt(**kwargs)).to_string()
717717

718-
def format_prompt(self, **kwargs: Any) -> PromptValue:
719-
"""Format prompt. Should return a PromptValue.
718+
def format_prompt(self, **kwargs: Any) -> ChatPromptValue:
719+
"""Format prompt. Should return a ChatPromptValue.
720720
721721
Args:
722722
**kwargs: Keyword arguments to use for formatting.
723723
724724
Returns:
725-
PromptValue.
725+
ChatPromptValue.
726726
"""
727727
messages = self.format_messages(**kwargs)
728728
return ChatPromptValue(messages=messages)
729729

730-
async def aformat_prompt(self, **kwargs: Any) -> PromptValue:
731-
"""Async format prompt. Should return a PromptValue.
730+
async def aformat_prompt(self, **kwargs: Any) -> ChatPromptValue:
731+
"""Async format prompt. Should return a ChatPromptValue.
732732
733733
Args:
734734
**kwargs: Keyword arguments to use for formatting.

0 commit comments

Comments
 (0)