From e635c86145729ef9d89f32bd4491b825f76a6ffa Mon Sep 17 00:00:00 2001 From: hitoshi44 <59504957+hitoshi44@users.noreply.github.com> Date: Mon, 20 Mar 2023 01:47:37 +0900 Subject: [PATCH] Slightly modified the docstring in `BasePromptTemplate` and `StringPromptTemplate`. (#1755) Regarding [this issue](https://github.com/hwchase17/langchain/issues/1754), `BasePromptTample` class docstring is a little outdated, thus it requires new method `format_prompt` for now. As such, I have made some modifications to the docstring to bring it up to date. I tried to adhere to the established document style, and would appreciate you for taking a look at this PR. --- langchain/prompts/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/langchain/prompts/base.py b/langchain/prompts/base.py index b85f3161..af431373 100644 --- a/langchain/prompts/base.py +++ b/langchain/prompts/base.py @@ -72,7 +72,7 @@ class StringPromptValue(PromptValue): class BasePromptTemplate(BaseModel, ABC): - """Base prompt should expose the format method, returning a prompt.""" + """Base class for all prompt templates, returning a prompt.""" input_variables: List[str] """A list of the names of the variables the prompt template expects.""" @@ -196,6 +196,8 @@ class BasePromptTemplate(BaseModel, ABC): class StringPromptTemplate(BasePromptTemplate, ABC): + """String prompt should expose the format method, returning a prompt.""" + def format_prompt(self, **kwargs: Any) -> PromptValue: """Create Chat Messages.""" return StringPromptValue(text=self.format(**kwargs))