chore: more content block docstring formatting

This commit is contained in:
Mason Daugherty
2025-08-15 14:39:13 -04:00
parent c9e847fcb8
commit 8d110599cb
5 changed files with 9 additions and 8 deletions

View File

@@ -201,7 +201,7 @@ class AIMessage(BaseMessage):
content_blocks: Optional[list[types.ContentBlock]] = None,
**kwargs: Any,
) -> None:
"""Specify content as a positional arg or content_blocks for typing support."""
"""Specify ``content`` as positional arg or ``content_blocks`` for typing."""
if content_blocks is not None:
# If there are tool calls in content_blocks, but not in tool_calls, add them
content_tool_calls = [

View File

@@ -83,7 +83,7 @@ class BaseMessage(Serializable):
content_blocks: Optional[list[types.ContentBlock]] = None,
**kwargs: Any,
) -> None:
"""Specify content as a positional arg or content_blocks for typing support."""
"""Specify ``content`` as positional arg or ``content_blocks`` for typing."""
if content_blocks is not None:
super().__init__(content=content_blocks, **kwargs)
else:
@@ -108,17 +108,18 @@ class BaseMessage(Serializable):
@property
def content_blocks(self) -> list[types.ContentBlock]:
"""Return the content as a list of standard ContentBlocks.
"""Return the content as a list of standard ``ContentBlock``s.
To use this property, the corresponding chat model must support
``message_version="v1"`` or higher:
``message_version='v1'`` or higher:
.. code-block:: python
from langchain.chat_models import init_chat_model
llm = init_chat_model("...", message_version="v1")
otherwise, does best-effort parsing to standard types.
Otherwise, does best-effort parsing to standard types.
"""
blocks: list[types.ContentBlock] = []
content = (

View File

@@ -63,7 +63,7 @@ class HumanMessage(BaseMessage):
content_blocks: Optional[list[types.ContentBlock]] = None,
**kwargs: Any,
) -> None:
"""Specify content as a positional arg or content_blocks for typing support."""
"""Specify ``content`` as positional arg or ``content_blocks`` for typing."""
if content_blocks is not None:
super().__init__(
content=cast("Union[str, list[Union[str, dict]]]", content_blocks),

View File

@@ -56,7 +56,7 @@ class SystemMessage(BaseMessage):
content_blocks: Optional[list[types.ContentBlock]] = None,
**kwargs: Any,
) -> None:
"""Specify content as a positional arg or content_blocks for typing support."""
"""Specify ``content`` as positional arg or ``content_blocks`` for typing."""
if content_blocks is not None:
super().__init__(
content=cast("Union[str, list[Union[str, dict]]]", content_blocks),

View File

@@ -157,7 +157,7 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
content_blocks: Optional[list[types.ContentBlock]] = None,
**kwargs: Any,
) -> None:
"""Specify content as a positional arg or content_blocks for typing support."""
"""Specify ``content`` as positional arg or ``content_blocks`` for typing."""
if content_blocks is not None:
super().__init__(
content=cast("Union[str, list[Union[str, dict]]]", content_blocks),