mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-16 17:53:37 +00:00
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`.
This commit is contained in:
parent
d57216c295
commit
6dcca35a34
@ -35,7 +35,7 @@ from langchain_core.messages import (
|
||||
convert_to_messages,
|
||||
)
|
||||
from langchain_core.messages.base import get_msg_title_repr
|
||||
from langchain_core.prompt_values import ChatPromptValue, ImageURL, PromptValue
|
||||
from langchain_core.prompt_values import ChatPromptValue, ImageURL
|
||||
from langchain_core.prompts.base import BasePromptTemplate
|
||||
from langchain_core.prompts.dict import DictPromptTemplate
|
||||
from langchain_core.prompts.image import ImagePromptTemplate
|
||||
@ -715,20 +715,20 @@ class BaseChatPromptTemplate(BasePromptTemplate, ABC):
|
||||
"""
|
||||
return (await self.aformat_prompt(**kwargs)).to_string()
|
||||
|
||||
def format_prompt(self, **kwargs: Any) -> PromptValue:
|
||||
"""Format prompt. Should return a PromptValue.
|
||||
def format_prompt(self, **kwargs: Any) -> ChatPromptValue:
|
||||
"""Format prompt. Should return a ChatPromptValue.
|
||||
|
||||
Args:
|
||||
**kwargs: Keyword arguments to use for formatting.
|
||||
|
||||
Returns:
|
||||
PromptValue.
|
||||
ChatPromptValue.
|
||||
"""
|
||||
messages = self.format_messages(**kwargs)
|
||||
return ChatPromptValue(messages=messages)
|
||||
|
||||
async def aformat_prompt(self, **kwargs: Any) -> PromptValue:
|
||||
"""Async format prompt. Should return a PromptValue.
|
||||
async def aformat_prompt(self, **kwargs: Any) -> ChatPromptValue:
|
||||
"""Async format prompt. Should return a ChatPromptValue.
|
||||
|
||||
Args:
|
||||
**kwargs: Keyword arguments to use for formatting.
|
||||
|
Loading…
Reference in New Issue
Block a user