style: address Sphinx double-backtick snippet syntax (#33389)

This commit is contained in:
Mason Daugherty
2025-10-09 13:35:51 -04:00
committed by GitHub
parent f405a2c57d
commit d8a680ee57
145 changed files with 1306 additions and 1307 deletions

View File

@@ -99,7 +99,7 @@ class BasePromptTemplate(
"""Get the namespace of the langchain object.
Returns:
``["langchain", "schema", "prompt_template"]``
`["langchain", "schema", "prompt_template"]`
"""
return ["langchain", "schema", "prompt_template"]

View File

@@ -238,11 +238,11 @@ class BaseStringMessagePromptTemplate(BaseMessagePromptTemplate, ABC):
template: a template.
template_format: format of the template. Defaults to "f-string".
partial_variables: A dictionary of variables that can be used to partially
fill in the template. For example, if the template is
`"{variable1} {variable2}"`, and `partial_variables` is
`{"variable1": "foo"}`, then the final prompt will be
`"foo {variable2}"`.
Defaults to `None`.
fill in the template. For example, if the template is
`"{variable1} {variable2}"`, and `partial_variables` is
`{"variable1": "foo"}`, then the final prompt will be
`"foo {variable2}"`.
Defaults to `None`.
**kwargs: keyword arguments to pass to the constructor.
Returns:
@@ -685,7 +685,7 @@ class BaseChatPromptTemplate(BasePromptTemplate, ABC):
Args:
**kwargs: keyword arguments to use for filling in template variables
in all the template messages in this chat template.
in all the template messages in this chat template.
Returns:
formatted string.
@@ -697,7 +697,7 @@ class BaseChatPromptTemplate(BasePromptTemplate, ABC):
Args:
**kwargs: keyword arguments to use for filling in template variables
in all the template messages in this chat template.
in all the template messages in this chat template.
Returns:
formatted string.
@@ -781,7 +781,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Examples:
!!! warning "Behavior changed in 0.2.24"
You can pass any Message-like formats supported by
``ChatPromptTemplate.from_messages()`` directly to ``ChatPromptTemplate()``
`ChatPromptTemplate.from_messages()` directly to `ChatPromptTemplate()`
init.
.. code-block:: python
@@ -902,11 +902,11 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Args:
messages: sequence of message representations.
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}".
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}".
template_format: format of the template. Defaults to "f-string".
input_variables: A list of the names of the variables whose values are
required as inputs to the prompt.
@@ -977,7 +977,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "chat"]``
`["langchain", "prompts", "chat"]`
"""
return ["langchain", "prompts", "chat"]
@@ -1127,11 +1127,11 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Args:
messages: sequence of message representations.
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}".
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}".
template_format: format of the template. Defaults to "f-string".
Returns:
@@ -1145,7 +1145,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Args:
**kwargs: keyword arguments to use for filling in template variables
in all the template messages in this chat template.
in all the template messages in this chat template.
Raises:
ValueError: if messages are of unexpected types.
@@ -1173,7 +1173,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Args:
**kwargs: keyword arguments to use for filling in template variables
in all the template messages in this chat template.
in all the template messages in this chat template.
Returns:
list of formatted messages.
@@ -1262,7 +1262,7 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
Returns:
If index is an int, returns the message at that index.
If index is a slice, returns a new ``ChatPromptTemplate``
If index is a slice, returns a new `ChatPromptTemplate`
containing the messages in that slice.
"""
if isinstance(index, slice):

View File

@@ -77,7 +77,7 @@ class DictPromptTemplate(RunnableSerializable[dict, dict]):
"""Get the namespace of the langchain object.
Returns:
``["langchain_core", "prompts", "dict"]``
`["langchain_core", "prompts", "dict"]`
"""
return ["langchain_core", "prompts", "dict"]

View File

@@ -49,7 +49,7 @@ class FewShotPromptWithTemplates(StringPromptTemplate):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "few_shot_with_templates"]``
`["langchain", "prompts", "few_shot_with_templates"]`
"""
return ["langchain", "prompts", "few_shot_with_templates"]

View File

@@ -26,8 +26,8 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
"""Create an image prompt template.
Raises:
ValueError: If the input variables contain ``'url'``, ``'path'``, or
``'detail'``.
ValueError: If the input variables contain `'url'`, `'path'`, or
`'detail'`.
"""
if "input_variables" not in kwargs:
kwargs["input_variables"] = []
@@ -52,7 +52,7 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "image"]``
`["langchain", "prompts", "image"]`
"""
return ["langchain", "prompts", "image"]
@@ -93,7 +93,7 @@ class ImagePromptTemplate(BasePromptTemplate[ImageURL]):
Raises:
ValueError: If the url is not provided.
ValueError: If the url is not a string.
ValueError: If ``'path'`` is provided in the template or kwargs.
ValueError: If `'path'` is provided in the template or kwargs.
Example:

View File

@@ -26,7 +26,7 @@ class BaseMessagePromptTemplate(Serializable, ABC):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "chat"]``
`["langchain", "prompts", "chat"]`
"""
return ["langchain", "prompts", "chat"]

View File

@@ -71,7 +71,7 @@ class PromptTemplate(StringPromptTemplate):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "prompt"]``
`["langchain", "prompts", "prompt"]`
"""
return ["langchain", "prompts", "prompt"]
@@ -144,10 +144,10 @@ class PromptTemplate(StringPromptTemplate):
Raises:
ValueError: If the template formats are not f-string or if there are
conflicting partial variables.
NotImplementedError: If the other object is not a ``PromptTemplate`` or str.
NotImplementedError: If the other object is not a `PromptTemplate` or str.
Returns:
A new ``PromptTemplate`` that is the combination of the two.
A new `PromptTemplate` that is the combination of the two.
"""
# Allow for easy combining
if isinstance(other, PromptTemplate):

View File

@@ -276,7 +276,7 @@ class StringPromptTemplate(BasePromptTemplate, ABC):
"""Get the namespace of the langchain object.
Returns:
``["langchain", "prompts", "base"]``
`["langchain", "prompts", "base"]`
"""
return ["langchain", "prompts", "base"]

View File

@@ -65,8 +65,8 @@ class StructuredPrompt(ChatPromptTemplate):
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the langchain object.
For example, if the class is ``langchain.llms.openai.OpenAI``, then the
namespace is ``["langchain", "llms", "openai"]``
For example, if the class is `langchain.llms.openai.OpenAI`, then the
namespace is `["langchain", "llms", "openai"]`
Returns:
The namespace of the langchain object.
@@ -106,14 +106,14 @@ class StructuredPrompt(ChatPromptTemplate):
Args:
messages: sequence of message representations.
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}"
A message can be represented using the following formats:
(1) BaseMessagePromptTemplate, (2) BaseMessage, (3) 2-tuple of
(message type, template); e.g., ("human", "{user_input}"),
(4) 2-tuple of (message class, template), (5) a string which is
shorthand for ("human", template); e.g., "{user_input}"
schema: a dictionary representation of function call, or a Pydantic model.
**kwargs: Any additional kwargs to pass through to
``ChatModel.with_structured_output(schema, **kwargs)``.
`ChatModel.with_structured_output(schema, **kwargs)`.
Returns:
a structured prompt template