From ee13a3b6fa44518dcb1993247b4576538dec3112 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Fri, 25 Jul 2025 10:16:35 -0400 Subject: [PATCH] nit: rearrange `index` to be grouped with other always-present fields --- .../langchain_core/messages/content_blocks.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/core/langchain_core/messages/content_blocks.py b/libs/core/langchain_core/messages/content_blocks.py index 5f873e0172e..30398998b13 100644 --- a/libs/core/langchain_core/messages/content_blocks.py +++ b/libs/core/langchain_core/messages/content_blocks.py @@ -470,15 +470,15 @@ class ImageContentBlock(TypedDict): `Examples from IANA `__ """ + index: NotRequired[int] + """Index of block in aggregate response. Used during streaming.""" + url: NotRequired[str] """URL of the image.""" base64: NotRequired[str] """Data as a base64 string.""" - index: NotRequired[int] - """Index of block in aggregate response. Used during streaming.""" - # title: NotRequired[str] # """Title of the image.""" @@ -508,15 +508,15 @@ class VideoContentBlock(TypedDict): `Examples from IANA `__ """ + index: NotRequired[int] + """Index of block in aggregate response. Used during streaming.""" + url: NotRequired[str] """URL of the video.""" base64: NotRequired[str] """Data as a base64 string.""" - index: NotRequired[int] - """Index of block in aggregate response. Used during streaming.""" - # title: NotRequired[str] # """Title of the video.""" @@ -546,15 +546,15 @@ class AudioContentBlock(TypedDict): `Examples from IANA `__ """ + index: NotRequired[int] + """Index of block in aggregate response. Used during streaming.""" + url: NotRequired[str] """URL of the audio.""" base64: NotRequired[str] """Data as a base64 string.""" - index: NotRequired[int] - """Index of block in aggregate response. Used during streaming.""" - # title: NotRequired[str] # """Title of the audio.""" @@ -586,6 +586,9 @@ class PlainTextContentBlock(TypedDict): mime_type: Literal["text/plain"] """MIME type of the file. Required for base64.""" + index: NotRequired[int] + """Index of block in aggregate response. Used during streaming.""" + url: NotRequired[str] """URL of the plaintext.""" @@ -595,9 +598,6 @@ class PlainTextContentBlock(TypedDict): text: NotRequired[str] """Plaintext content. This is optional if the data is provided as base64.""" - index: NotRequired[int] - """Index of block in aggregate response. Used during streaming.""" - title: NotRequired[str] """Title of the text data, e.g., the title of a document.""" @@ -635,15 +635,15 @@ class FileContentBlock(TypedDict): `Examples from IANA `__ """ + index: NotRequired[int] + """Index of block in aggregate response. Used during streaming.""" + url: NotRequired[str] """URL of the file.""" base64: NotRequired[str] """Data as a base64 string.""" - index: NotRequired[int] - """Index of block in aggregate response. Used during streaming.""" - # title: NotRequired[str] # """Title of the file, e.g., the name of a document or file."""