Skip to content

Commit

Permalink
Slightly modified the docstring in BasePromptTemplate and `StringPr…
Browse files Browse the repository at this point in the history
…omptTemplate`. (#1755)

Regarding [this
issue](#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.
  • Loading branch information
hitoshi44 committed Mar 19, 2023
1 parent 7797901 commit e635c86
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion langchain/prompts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def to_messages(self) -> List[BaseMessage]:


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."""
Expand Down Expand Up @@ -196,6 +196,8 @@ def save(self, file_path: Union[Path, str]) -> None:


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))

0 comments on commit e635c86

Please sign in to comment.