mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
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:
@@ -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))
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -90,6 +90,7 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
|
||||
.. code-block:: python
|
||||
|
||||
prompt.format(variable1="foo")
|
||||
|
||||
"""
|
||||
formatted = {}
|
||||
for k, v in self.template.items():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -56,6 +56,7 @@ class PromptTemplate(StringPromptTemplate):
|
||||
|
||||
# Instantiation using initializer
|
||||
prompt = PromptTemplate(template="Say {foo}")
|
||||
|
||||
"""
|
||||
|
||||
@property
|
||||
|
||||
@@ -115,6 +115,7 @@ class StructuredPrompt(ChatPromptTemplate):
|
||||
|
||||
Returns:
|
||||
a structured prompt template
|
||||
|
||||
"""
|
||||
return cls(messages, schema, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user