Skip to content

Commit b9d3020

Browse files
committed
add extra
1 parent c9411b5 commit b9d3020

File tree

4 files changed

+495
-20
lines changed

4 files changed

+495
-20
lines changed

libs/core/langchain_core/messages/content_blocks.py

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ class Citation(TypedDict):
185185
# is difficult to reliably extract spans from the raw document text across file
186186
# formats or encoding schemes.
187187

188+
extras: NotRequired[dict[str, Any]]
189+
"""Provider-specific metadata."""
190+
188191

189192
class NonStandardAnnotation(TypedDict):
190193
"""Provider-specific annotation format."""
@@ -240,6 +243,9 @@ class TextContentBlock(TypedDict):
240243
index: NotRequired[int]
241244
"""Index of block in aggregate response. Used during streaming."""
242245

246+
extras: NotRequired[dict[str, Any]]
247+
"""Provider-specific metadata."""
248+
243249

244250
class ToolCall(TypedDict):
245251
"""Represents a request to call a tool.
@@ -286,6 +292,9 @@ class ToolCall(TypedDict):
286292
index: NotRequired[int]
287293
"""Index of block in aggregate response. Used during streaming."""
288294

295+
extras: NotRequired[dict[str, Any]]
296+
"""Provider-specific metadata."""
297+
289298

290299
class ToolCallChunk(TypedDict):
291300
"""A chunk of a tool call (e.g., as part of a stream).
@@ -324,6 +333,9 @@ class ToolCallChunk(TypedDict):
324333
index: Optional[int]
325334
"""The index of the tool call in a sequence."""
326335

336+
extras: NotRequired[dict[str, Any]]
337+
"""Provider-specific metadata."""
338+
327339

328340
class InvalidToolCall(TypedDict):
329341
"""Allowance for errors made by LLM.
@@ -349,6 +361,9 @@ class InvalidToolCall(TypedDict):
349361
error: Optional[str]
350362
"""An error message associated with the tool call."""
351363

364+
extras: NotRequired[dict[str, Any]]
365+
"""Provider-specific metadata."""
366+
352367

353368
# Note: These are not standard tool calls, but rather provider-specific built-in tools.
354369
# Web search
@@ -371,6 +386,9 @@ class WebSearchCall(TypedDict):
371386
index: NotRequired[int]
372387
"""Index of block in aggregate response. Used during streaming."""
373388

389+
extras: NotRequired[dict[str, Any]]
390+
"""Provider-specific metadata."""
391+
374392

375393
class WebSearchResult(TypedDict):
376394
"""Result of a built-in web search tool call."""
@@ -391,6 +409,9 @@ class WebSearchResult(TypedDict):
391409
index: NotRequired[int]
392410
"""Index of block in aggregate response. Used during streaming."""
393411

412+
extras: NotRequired[dict[str, Any]]
413+
"""Provider-specific metadata."""
414+
394415

395416
class CodeInterpreterCall(TypedDict):
396417
"""Built-in code interpreter tool call."""
@@ -414,6 +435,9 @@ class CodeInterpreterCall(TypedDict):
414435
index: NotRequired[int]
415436
"""Index of block in aggregate response. Used during streaming."""
416437

438+
extras: NotRequired[dict[str, Any]]
439+
"""Provider-specific metadata."""
440+
417441

418442
class CodeInterpreterOutput(TypedDict):
419443
"""Output of a singular code interpreter tool call.
@@ -450,6 +474,9 @@ class CodeInterpreterOutput(TypedDict):
450474
index: NotRequired[int]
451475
"""Index of block in aggregate response. Used during streaming."""
452476

477+
extras: NotRequired[dict[str, Any]]
478+
"""Provider-specific metadata."""
479+
453480

454481
class CodeInterpreterResult(TypedDict):
455482
"""Result of a code interpreter tool call."""
@@ -470,6 +497,9 @@ class CodeInterpreterResult(TypedDict):
470497
index: NotRequired[int]
471498
"""Index of block in aggregate response. Used during streaming."""
472499

500+
extras: NotRequired[dict[str, Any]]
501+
"""Provider-specific metadata."""
502+
473503

474504
class ReasoningContentBlock(TypedDict):
475505
"""Reasoning output from a LLM.
@@ -503,6 +533,9 @@ class ReasoningContentBlock(TypedDict):
503533
index: NotRequired[int]
504534
"""Index of block in aggregate response. Used during streaming."""
505535

536+
extras: NotRequired[dict[str, Any]]
537+
"""Provider-specific metadata."""
538+
506539

507540
# Note: `title` and `context` are fields that could be used to provide additional
508541
# information about the file, such as a description or summary of its content.
@@ -547,11 +580,8 @@ class ImageContentBlock(TypedDict):
547580
base64: NotRequired[str]
548581
"""Data as a base64 string."""
549582

550-
# title: NotRequired[str]
551-
# """Title of the image."""
552-
553-
# context: NotRequired[str]
554-
# """Context for the image, e.g., a description or summary of the image's content.""" # noqa: E501
583+
extras: NotRequired[dict[str, Any]]
584+
"""Provider-specific metadata."""
555585

556586

557587
class VideoContentBlock(TypedDict):
@@ -594,11 +624,8 @@ class VideoContentBlock(TypedDict):
594624
base64: NotRequired[str]
595625
"""Data as a base64 string."""
596626

597-
# title: NotRequired[str]
598-
# """Title of the video."""
599-
600-
# context: NotRequired[str]
601-
# """Context for the video, e.g., description or summary of the video's content."""
627+
extras: NotRequired[dict[str, Any]]
628+
"""Provider-specific metadata."""
602629

603630

604631
class AudioContentBlock(TypedDict):
@@ -641,11 +668,8 @@ class AudioContentBlock(TypedDict):
641668
base64: NotRequired[str]
642669
"""Data as a base64 string."""
643670

644-
# title: NotRequired[str]
645-
# """Title of the audio."""
646-
647-
# context: NotRequired[str]
648-
# """Context for the audio, e.g., description or summary of the audio's content."""
671+
extras: NotRequired[dict[str, Any]]
672+
"""Provider-specific metadata."""
649673

650674

651675
class PlainTextContentBlock(TypedDict):
@@ -698,6 +722,9 @@ class PlainTextContentBlock(TypedDict):
698722
context: NotRequired[str]
699723
"""Context for the text, e.g., a description or summary of the text's content."""
700724

725+
extras: NotRequired[dict[str, Any]]
726+
"""Provider-specific metadata."""
727+
701728

702729
class FileContentBlock(TypedDict):
703730
"""File data that doesn't fit into other multimodal blocks.
@@ -746,11 +773,8 @@ class FileContentBlock(TypedDict):
746773
base64: NotRequired[str]
747774
"""Data as a base64 string."""
748775

749-
# title: NotRequired[str]
750-
# """Title of the file, e.g., the name of a document or file."""
751-
752-
# context: NotRequired[str]
753-
# """Context for the file, e.g., a description or summary of the file's content."""
776+
extras: NotRequired[dict[str, Any]]
777+
"""Provider-specific metadata."""
754778

755779

756780
# Future modalities to consider:

0 commit comments

Comments
 (0)