fix: formatting issues in docstrings (#32265)

Ensures proper reStructuredText formatting by adding the required blank
line before closing docstring quotes, which resolves the "Block quote
ends without a blank line; unexpected unindent" warning.
This commit is contained in:
Mason Daugherty
2025-07-27 23:37:47 -04:00
committed by GitHub
parent a8a2cff129
commit 96cbd90cba
129 changed files with 234 additions and 3 deletions

View File

@@ -307,6 +307,7 @@ class BasePromptTemplate(
.. code-block:: python
prompt.format(variable1="foo")
"""
async def aformat(self, **kwargs: Any) -> FormatOutputType:
@@ -323,6 +324,7 @@ class BasePromptTemplate(
.. code-block:: python
await prompt.aformat(variable1="foo")
"""
return self.format(**kwargs)
@@ -363,6 +365,7 @@ class BasePromptTemplate(
.. code-block:: python
prompt.save(file_path="path/prompt.yaml")
"""
if self.partial_variables:
msg = "Cannot save prompt with partial variables."
@@ -442,6 +445,7 @@ def format_document(doc: Document, prompt: BasePromptTemplate[str]) -> str:
prompt = PromptTemplate.from_template("Page {page}: {page_content}")
format_document(doc, prompt)
>>> "Page 1: This is a joke"
"""
return prompt.format(**_get_document_info(doc, prompt))

View File

@@ -126,6 +126,7 @@ class MessagesPlaceholder(BaseMessagePromptTemplate):
# -> [
# HumanMessage(content="Hello!"),
# ]
"""
variable_name: str
@@ -1164,6 +1165,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Returns:
a chat prompt template.
"""
return cls(messages, template_format=template_format)
@@ -1248,6 +1250,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
template2 = template.partial(user="Lucy", name="R2D2")
template2.format_messages(input="hello")
"""
prompt_dict = self.__dict__.copy()
prompt_dict["input_variables"] = list(

View File

@@ -357,6 +357,7 @@ class FewShotChatMessagePromptTemplate(
from langchain_core.chat_models import ChatAnthropic
chain = final_prompt | ChatAnthropic(model="claude-3-haiku-20240307")
chain.invoke({"input": "What's 3+3?"})
"""
input_variables: list[str] = Field(default_factory=list)

View File

@@ -122,6 +122,7 @@ class FewShotPromptWithTemplates(StringPromptTemplate):
.. code-block:: python
prompt.format(variable1="foo")
"""
kwargs = self._merge_partial_and_user_variables(**kwargs)
# Get the examples to use.

View File

@@ -90,6 +90,7 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
.. code-block:: python
prompt.format(variable1="foo")
"""
formatted = {}
for k, v in self.template.items():

View File

@@ -45,6 +45,7 @@ class PipelinePromptTemplate(BasePromptTemplate):
Each PromptTemplate will be formatted and then passed
to future prompt templates as a variable with
the same name as `name`
"""
final_prompt: BasePromptTemplate

View File

@@ -56,6 +56,7 @@ class PromptTemplate(StringPromptTemplate):
# Instantiation using initializer
prompt = PromptTemplate(template="Say {foo}")
"""
@property

View File

@@ -115,6 +115,7 @@ class StructuredPrompt(ChatPromptTemplate):
Returns:
a structured prompt template
"""
return cls(messages, schema, **kwargs)