langchain-core 1.0.0a8__py3-none-any.whl → 1.0.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of langchain-core might be problematic. Click here for more details.

Files changed (135) hide show
  1. langchain_core/__init__.py +1 -1
  2. langchain_core/_api/__init__.py +0 -1
  3. langchain_core/_api/beta_decorator.py +17 -20
  4. langchain_core/_api/deprecation.py +30 -35
  5. langchain_core/_import_utils.py +1 -1
  6. langchain_core/agents.py +7 -6
  7. langchain_core/caches.py +4 -10
  8. langchain_core/callbacks/__init__.py +1 -8
  9. langchain_core/callbacks/base.py +232 -243
  10. langchain_core/callbacks/file.py +33 -33
  11. langchain_core/callbacks/manager.py +353 -416
  12. langchain_core/callbacks/stdout.py +21 -22
  13. langchain_core/callbacks/streaming_stdout.py +32 -32
  14. langchain_core/callbacks/usage.py +54 -51
  15. langchain_core/chat_history.py +42 -57
  16. langchain_core/document_loaders/langsmith.py +21 -21
  17. langchain_core/documents/__init__.py +0 -1
  18. langchain_core/documents/base.py +37 -40
  19. langchain_core/documents/transformers.py +28 -29
  20. langchain_core/embeddings/fake.py +46 -52
  21. langchain_core/exceptions.py +5 -5
  22. langchain_core/indexing/api.py +11 -11
  23. langchain_core/indexing/base.py +24 -24
  24. langchain_core/language_models/__init__.py +0 -2
  25. langchain_core/language_models/_utils.py +51 -53
  26. langchain_core/language_models/base.py +23 -24
  27. langchain_core/language_models/chat_models.py +121 -144
  28. langchain_core/language_models/fake_chat_models.py +5 -5
  29. langchain_core/language_models/llms.py +10 -12
  30. langchain_core/load/dump.py +1 -1
  31. langchain_core/load/load.py +16 -16
  32. langchain_core/load/serializable.py +35 -34
  33. langchain_core/messages/__init__.py +1 -16
  34. langchain_core/messages/ai.py +105 -104
  35. langchain_core/messages/base.py +26 -26
  36. langchain_core/messages/block_translators/__init__.py +17 -17
  37. langchain_core/messages/block_translators/anthropic.py +2 -2
  38. langchain_core/messages/block_translators/bedrock_converse.py +2 -2
  39. langchain_core/messages/block_translators/google_genai.py +2 -2
  40. langchain_core/messages/block_translators/groq.py +117 -21
  41. langchain_core/messages/block_translators/langchain_v0.py +2 -2
  42. langchain_core/messages/block_translators/openai.py +4 -4
  43. langchain_core/messages/chat.py +1 -1
  44. langchain_core/messages/content.py +189 -193
  45. langchain_core/messages/function.py +5 -5
  46. langchain_core/messages/human.py +15 -17
  47. langchain_core/messages/modifier.py +1 -1
  48. langchain_core/messages/system.py +12 -14
  49. langchain_core/messages/tool.py +45 -49
  50. langchain_core/messages/utils.py +384 -396
  51. langchain_core/output_parsers/__init__.py +1 -14
  52. langchain_core/output_parsers/base.py +22 -23
  53. langchain_core/output_parsers/json.py +3 -3
  54. langchain_core/output_parsers/list.py +1 -1
  55. langchain_core/output_parsers/openai_functions.py +46 -44
  56. langchain_core/output_parsers/openai_tools.py +7 -7
  57. langchain_core/output_parsers/pydantic.py +10 -11
  58. langchain_core/output_parsers/string.py +1 -1
  59. langchain_core/output_parsers/transform.py +2 -2
  60. langchain_core/output_parsers/xml.py +1 -1
  61. langchain_core/outputs/__init__.py +1 -1
  62. langchain_core/outputs/chat_generation.py +14 -14
  63. langchain_core/outputs/generation.py +5 -5
  64. langchain_core/outputs/llm_result.py +5 -5
  65. langchain_core/prompt_values.py +5 -5
  66. langchain_core/prompts/__init__.py +3 -23
  67. langchain_core/prompts/base.py +32 -37
  68. langchain_core/prompts/chat.py +216 -222
  69. langchain_core/prompts/dict.py +2 -2
  70. langchain_core/prompts/few_shot.py +76 -83
  71. langchain_core/prompts/few_shot_with_templates.py +6 -8
  72. langchain_core/prompts/image.py +11 -13
  73. langchain_core/prompts/loading.py +1 -1
  74. langchain_core/prompts/message.py +2 -2
  75. langchain_core/prompts/prompt.py +14 -16
  76. langchain_core/prompts/string.py +19 -7
  77. langchain_core/prompts/structured.py +24 -25
  78. langchain_core/rate_limiters.py +36 -38
  79. langchain_core/retrievers.py +41 -182
  80. langchain_core/runnables/base.py +565 -590
  81. langchain_core/runnables/branch.py +7 -7
  82. langchain_core/runnables/config.py +37 -44
  83. langchain_core/runnables/configurable.py +8 -9
  84. langchain_core/runnables/fallbacks.py +8 -8
  85. langchain_core/runnables/graph.py +28 -27
  86. langchain_core/runnables/graph_ascii.py +19 -18
  87. langchain_core/runnables/graph_mermaid.py +20 -31
  88. langchain_core/runnables/graph_png.py +7 -7
  89. langchain_core/runnables/history.py +20 -20
  90. langchain_core/runnables/passthrough.py +8 -8
  91. langchain_core/runnables/retry.py +3 -3
  92. langchain_core/runnables/router.py +1 -1
  93. langchain_core/runnables/schema.py +33 -33
  94. langchain_core/runnables/utils.py +30 -34
  95. langchain_core/stores.py +72 -102
  96. langchain_core/sys_info.py +27 -29
  97. langchain_core/tools/__init__.py +1 -14
  98. langchain_core/tools/base.py +63 -63
  99. langchain_core/tools/convert.py +92 -92
  100. langchain_core/tools/render.py +9 -9
  101. langchain_core/tools/retriever.py +1 -1
  102. langchain_core/tools/simple.py +6 -7
  103. langchain_core/tools/structured.py +17 -18
  104. langchain_core/tracers/__init__.py +1 -9
  105. langchain_core/tracers/base.py +35 -35
  106. langchain_core/tracers/context.py +12 -17
  107. langchain_core/tracers/event_stream.py +3 -3
  108. langchain_core/tracers/langchain.py +8 -8
  109. langchain_core/tracers/log_stream.py +17 -18
  110. langchain_core/tracers/memory_stream.py +2 -2
  111. langchain_core/tracers/schemas.py +0 -129
  112. langchain_core/utils/aiter.py +31 -31
  113. langchain_core/utils/env.py +5 -5
  114. langchain_core/utils/function_calling.py +48 -120
  115. langchain_core/utils/html.py +4 -4
  116. langchain_core/utils/input.py +2 -2
  117. langchain_core/utils/interactive_env.py +1 -1
  118. langchain_core/utils/iter.py +19 -19
  119. langchain_core/utils/json.py +1 -1
  120. langchain_core/utils/json_schema.py +2 -2
  121. langchain_core/utils/mustache.py +5 -5
  122. langchain_core/utils/pydantic.py +17 -17
  123. langchain_core/utils/strings.py +4 -4
  124. langchain_core/utils/utils.py +25 -28
  125. langchain_core/vectorstores/base.py +43 -64
  126. langchain_core/vectorstores/in_memory.py +83 -85
  127. langchain_core/version.py +1 -1
  128. {langchain_core-1.0.0a8.dist-info → langchain_core-1.0.0rc1.dist-info}/METADATA +23 -11
  129. langchain_core-1.0.0rc1.dist-info/RECORD +172 -0
  130. langchain_core/memory.py +0 -120
  131. langchain_core/pydantic_v1/__init__.py +0 -30
  132. langchain_core/pydantic_v1/dataclasses.py +0 -23
  133. langchain_core/pydantic_v1/main.py +0 -23
  134. langchain_core-1.0.0a8.dist-info/RECORD +0 -176
  135. {langchain_core-1.0.0a8.dist-info → langchain_core-1.0.0rc1.dist-info}/WHEEL +0 -0
@@ -5,7 +5,7 @@
5
5
  change in future releases.
6
6
 
7
7
  This module provides standardized data structures for representing inputs to and
8
- outputs from LLMs. The core abstraction is the **Content Block**, a ``TypedDict``.
8
+ outputs from LLMs. The core abstraction is the **Content Block**, a `TypedDict`.
9
9
 
10
10
  **Rationale**
11
11
 
@@ -20,59 +20,59 @@ blocks into the format required by its API.
20
20
  **Extensibility**
21
21
 
22
22
  Data **not yet mapped** to a standard block may be represented using the
23
- ``NonStandardContentBlock``, which allows for provider-specific data to be included
23
+ `NonStandardContentBlock`, which allows for provider-specific data to be included
24
24
  without losing the benefits of type checking and validation.
25
25
 
26
26
  Furthermore, provider-specific fields **within** a standard block are fully supported
27
- by default in the ``extras`` field of each block. This allows for additional metadata
27
+ by default in the `extras` field of each block. This allows for additional metadata
28
28
  to be included without breaking the standard structure.
29
29
 
30
30
  !!! warning
31
- Do not heavily rely on the ``extras`` field for provider-specific data! This field
31
+ Do not heavily rely on the `extras` field for provider-specific data! This field
32
32
  is subject to deprecation in future releases as we move towards PEP 728.
33
33
 
34
34
  !!! note
35
- Following widespread adoption of `PEP 728 <https://peps.python.org/pep-0728/>`__, we
36
- will add ``extra_items=Any`` as a param to Content Blocks. This will signify to type
35
+ Following widespread adoption of [PEP 728](https://peps.python.org/pep-0728/), we
36
+ will add `extra_items=Any` as a param to Content Blocks. This will signify to type
37
37
  checkers that additional provider-specific fields are allowed outside of the
38
- ``extras`` field, and that will become the new standard approach to adding
38
+ `extras` field, and that will become the new standard approach to adding
39
39
  provider-specific metadata.
40
40
 
41
41
  ??? note
42
42
 
43
43
  **Example with PEP 728 provider-specific fields:**
44
44
 
45
- .. code-block:: python
46
-
47
- # Content block definition
48
- # NOTE: `extra_items=Any`
49
- class TextContentBlock(TypedDict, extra_items=Any):
50
- type: Literal["text"]
51
- id: NotRequired[str]
52
- text: str
53
- annotations: NotRequired[list[Annotation]]
54
- index: NotRequired[int]
55
-
56
- .. code-block:: python
57
-
58
- from langchain_core.messages.content import TextContentBlock
59
-
60
- # Create a text content block with provider-specific fields
61
- my_block: TextContentBlock = {
62
- # Add required fields
63
- "type": "text",
64
- "text": "Hello, world!",
65
- # Additional fields not specified in the TypedDict
66
- # These are valid with PEP 728 and are typed as Any
67
- "openai_metadata": {"model": "gpt-4", "temperature": 0.7},
68
- "anthropic_usage": {"input_tokens": 10, "output_tokens": 20},
69
- "custom_field": "any value",
70
- }
71
-
72
- # Mutating an existing block to add provider-specific fields
73
- openai_data = my_block["openai_metadata"] # Type: Any
74
-
75
- PEP 728 is enabled with ``# type: ignore[call-arg]`` comments to suppress
45
+ ```python
46
+ # Content block definition
47
+ # NOTE: `extra_items=Any`
48
+ class TextContentBlock(TypedDict, extra_items=Any):
49
+ type: Literal["text"]
50
+ id: NotRequired[str]
51
+ text: str
52
+ annotations: NotRequired[list[Annotation]]
53
+ index: NotRequired[int]
54
+ ```
55
+
56
+ ```python
57
+ from langchain_core.messages.content import TextContentBlock
58
+
59
+ # Create a text content block with provider-specific fields
60
+ my_block: TextContentBlock = {
61
+ # Add required fields
62
+ "type": "text",
63
+ "text": "Hello, world!",
64
+ # Additional fields not specified in the TypedDict
65
+ # These are valid with PEP 728 and are typed as Any
66
+ "openai_metadata": {"model": "gpt-4", "temperature": 0.7},
67
+ "anthropic_usage": {"input_tokens": 10, "output_tokens": 20},
68
+ "custom_field": "any value",
69
+ }
70
+
71
+ # Mutating an existing block to add provider-specific fields
72
+ openai_data = my_block["openai_metadata"] # Type: Any
73
+ ```
74
+
75
+ PEP 728 is enabled with `# type: ignore[call-arg]` comments to suppress
76
76
  warnings from type checkers that don't yet support it. The functionality works
77
77
  correctly in Python 3.13+ and will be fully supported as the ecosystem catches
78
78
  up.
@@ -81,52 +81,51 @@ to be included without breaking the standard structure.
81
81
 
82
82
  The module defines several types of content blocks, including:
83
83
 
84
- - ``TextContentBlock``: Standard text output.
85
- - ``Citation``: For annotations that link text output to a source document.
86
- - ``ToolCall``: For function calling.
87
- - ``ReasoningContentBlock``: To capture a model's thought process.
84
+ - `TextContentBlock`: Standard text output.
85
+ - `Citation`: For annotations that link text output to a source document.
86
+ - `ToolCall`: For function calling.
87
+ - `ReasoningContentBlock`: To capture a model's thought process.
88
88
  - Multimodal data:
89
- - ``ImageContentBlock``
90
- - ``AudioContentBlock``
91
- - ``VideoContentBlock``
92
- - ``PlainTextContentBlock`` (e.g. .txt or .md files)
93
- - ``FileContentBlock`` (e.g. PDFs, etc.)
89
+ - `ImageContentBlock`
90
+ - `AudioContentBlock`
91
+ - `VideoContentBlock`
92
+ - `PlainTextContentBlock` (e.g. .txt or .md files)
93
+ - `FileContentBlock` (e.g. PDFs, etc.)
94
94
 
95
95
  **Example Usage**
96
96
 
97
- .. code-block:: python
98
-
99
- # Direct construction:
100
- from langchain_core.messages.content import TextContentBlock, ImageContentBlock
101
-
102
- multimodal_message: AIMessage(
103
- content_blocks=[
104
- TextContentBlock(type="text", text="What is shown in this image?"),
105
- ImageContentBlock(
106
- type="image",
107
- url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
108
- mime_type="image/png",
109
- ),
110
- ]
111
- )
97
+ ```python
98
+ # Direct construction:
99
+ from langchain_core.messages.content import TextContentBlock, ImageContentBlock
100
+
101
+ multimodal_message: AIMessage(
102
+ content_blocks=[
103
+ TextContentBlock(type="text", text="What is shown in this image?"),
104
+ ImageContentBlock(
105
+ type="image",
106
+ url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
107
+ mime_type="image/png",
108
+ ),
109
+ ]
110
+ )
112
111
 
113
- # Using factories:
114
- from langchain_core.messages.content import create_text_block, create_image_block
115
-
116
- multimodal_message: AIMessage(
117
- content=[
118
- create_text_block("What is shown in this image?"),
119
- create_image_block(
120
- url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
121
- mime_type="image/png",
122
- ),
123
- ]
124
- )
112
+ # Using factories:
113
+ from langchain_core.messages.content import create_text_block, create_image_block
114
+
115
+ multimodal_message: AIMessage(
116
+ content=[
117
+ create_text_block("What is shown in this image?"),
118
+ create_image_block(
119
+ url="https://www.langchain.com/images/brand/langchain_logo_text_w_white.png",
120
+ mime_type="image/png",
121
+ ),
122
+ ]
123
+ )
124
+ ```
125
125
 
126
126
  Factory functions offer benefits such as:
127
127
  - Automatic ID generation (when not provided)
128
- - No need to manually specify the ``type`` field
129
-
128
+ - No need to manually specify the `type` field
130
129
  """
131
130
 
132
131
  from typing import Any, Literal, get_args, get_type_hints
@@ -140,12 +139,12 @@ class Citation(TypedDict):
140
139
  """Annotation for citing data from a document.
141
140
 
142
141
  !!! note
143
- ``start``/``end`` indices refer to the **response text**,
142
+ `start`/`end` indices refer to the **response text**,
144
143
  not the source text. This means that the indices are relative to the model's
145
- response, not the original document (as specified in the ``url``).
144
+ response, not the original document (as specified in the `url`).
146
145
 
147
146
  !!! note
148
- ``create_citation`` may also be used as a factory to create a ``Citation``.
147
+ `create_citation` may also be used as a factory to create a `Citation`.
149
148
  Benefits include:
150
149
 
151
150
  * Automatic ID generation (when not provided)
@@ -160,7 +159,7 @@ class Citation(TypedDict):
160
159
  """Content block identifier. Either:
161
160
 
162
161
  - Generated by the provider (e.g., OpenAI's file ID)
163
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
162
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
164
163
 
165
164
  """
166
165
 
@@ -174,10 +173,10 @@ class Citation(TypedDict):
174
173
  """
175
174
 
176
175
  start_index: NotRequired[int]
177
- """Start index of the **response text** (``TextContentBlock.text``)."""
176
+ """Start index of the **response text** (`TextContentBlock.text`)."""
178
177
 
179
178
  end_index: NotRequired[int]
180
- """End index of the **response text** (``TextContentBlock.text``)"""
179
+ """End index of the **response text** (`TextContentBlock.text`)"""
181
180
 
182
181
  cited_text: NotRequired[str]
183
182
  """Excerpt of source text being cited."""
@@ -203,7 +202,7 @@ class NonStandardAnnotation(TypedDict):
203
202
 
204
203
  Either:
205
204
  - Generated by the provider (e.g., OpenAI's file ID)
206
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
205
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
207
206
 
208
207
  """
209
208
 
@@ -221,8 +220,8 @@ class TextContentBlock(TypedDict):
221
220
  from a language model or the text of a user message.
222
221
 
223
222
  !!! note
224
- ``create_text_block`` may also be used as a factory to create a
225
- ``TextContentBlock``. Benefits include:
223
+ `create_text_block` may also be used as a factory to create a
224
+ `TextContentBlock`. Benefits include:
226
225
 
227
226
  * Automatic ID generation (when not provided)
228
227
  * Required arguments strictly validated at creation time
@@ -237,7 +236,7 @@ class TextContentBlock(TypedDict):
237
236
 
238
237
  Either:
239
238
  - Generated by the provider (e.g., OpenAI's file ID)
240
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
239
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
241
240
 
242
241
  """
243
242
 
@@ -245,7 +244,7 @@ class TextContentBlock(TypedDict):
245
244
  """Block text."""
246
245
 
247
246
  annotations: NotRequired[list[Annotation]]
248
- """``Citation``s and other annotations."""
247
+ """`Citation`s and other annotations."""
249
248
 
250
249
  index: NotRequired[int | str]
251
250
  """Index of block in aggregate response. Used during streaming."""
@@ -258,17 +257,16 @@ class ToolCall(TypedDict):
258
257
  """Represents a request to call a tool.
259
258
 
260
259
  Example:
261
-
262
- .. code-block:: python
263
-
264
- {"name": "foo", "args": {"a": 1}, "id": "123"}
260
+ ```python
261
+ {"name": "foo", "args": {"a": 1}, "id": "123"}
262
+ ```
265
263
 
266
264
  This represents a request to call the tool named "foo" with arguments {"a": 1}
267
265
  and an identifier of "123".
268
266
 
269
267
  !!! note
270
- ``create_tool_call`` may also be used as a factory to create a
271
- ``ToolCall``. Benefits include:
268
+ `create_tool_call` may also be used as a factory to create a
269
+ `ToolCall`. Benefits include:
272
270
 
273
271
  * Automatic ID generation (when not provided)
274
272
  * Required arguments strictly validated at creation time
@@ -303,22 +301,20 @@ class ToolCall(TypedDict):
303
301
  class ToolCallChunk(TypedDict):
304
302
  """A chunk of a tool call (e.g., as part of a stream).
305
303
 
306
- When merging ``ToolCallChunks`` (e.g., via ``AIMessageChunk.__add__``),
304
+ When merging `ToolCallChunks` (e.g., via `AIMessageChunk.__add__`),
307
305
  all string attributes are concatenated. Chunks are only merged if their
308
- values of ``index`` are equal and not ``None``.
306
+ values of `index` are equal and not `None`.
309
307
 
310
308
  Example:
311
-
312
- .. code-block:: python
313
-
314
- left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
315
- right_chunks = [ToolCallChunk(name=None, args="1}", index=0)]
316
-
317
- (
318
- AIMessageChunk(content="", tool_call_chunks=left_chunks)
319
- + AIMessageChunk(content="", tool_call_chunks=right_chunks)
320
- ).tool_call_chunks == [ToolCallChunk(name="foo", args='{"a":1}', index=0)]
321
-
309
+ ```python
310
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
311
+ right_chunks = [ToolCallChunk(name=None, args="1}", index=0)]
312
+
313
+ (
314
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
315
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
316
+ ).tool_call_chunks == [ToolCallChunk(name="foo", args='{"a":1}', index=0)]
317
+ ```
322
318
  """
323
319
 
324
320
  # TODO: Consider making fields NotRequired[str] in the future.
@@ -350,7 +346,7 @@ class ToolCallChunk(TypedDict):
350
346
  class InvalidToolCall(TypedDict):
351
347
  """Allowance for errors made by LLM.
352
348
 
353
- Here we add an ``error`` key to surface errors made during generation
349
+ Here we add an `error` key to surface errors made during generation
354
350
  (e.g., invalid JSON arguments.)
355
351
 
356
352
  """
@@ -457,8 +453,8 @@ class ReasoningContentBlock(TypedDict):
457
453
  """Reasoning output from a LLM.
458
454
 
459
455
  !!! note
460
- ``create_reasoning_block`` may also be used as a factory to create a
461
- ``ReasoningContentBlock``. Benefits include:
456
+ `create_reasoning_block` may also be used as a factory to create a
457
+ `ReasoningContentBlock`. Benefits include:
462
458
 
463
459
  * Automatic ID generation (when not provided)
464
460
  * Required arguments strictly validated at creation time
@@ -473,7 +469,7 @@ class ReasoningContentBlock(TypedDict):
473
469
 
474
470
  Either:
475
471
  - Generated by the provider (e.g., OpenAI's file ID)
476
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
472
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
477
473
 
478
474
  """
479
475
 
@@ -481,7 +477,7 @@ class ReasoningContentBlock(TypedDict):
481
477
  """Reasoning text.
482
478
 
483
479
  Either the thought summary or the raw reasoning text itself. This is often parsed
484
- from ``<think>`` tags in the model's response.
480
+ from `<think>` tags in the model's response.
485
481
 
486
482
  """
487
483
 
@@ -499,8 +495,8 @@ class ImageContentBlock(TypedDict):
499
495
  """Image data.
500
496
 
501
497
  !!! note
502
- ``create_image_block`` may also be used as a factory to create a
503
- ``ImageContentBlock``. Benefits include:
498
+ `create_image_block` may also be used as a factory to create a
499
+ `ImageContentBlock`. Benefits include:
504
500
 
505
501
  * Automatic ID generation (when not provided)
506
502
  * Required arguments strictly validated at creation time
@@ -515,7 +511,7 @@ class ImageContentBlock(TypedDict):
515
511
 
516
512
  Either:
517
513
  - Generated by the provider (e.g., OpenAI's file ID)
518
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
514
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
519
515
 
520
516
  """
521
517
 
@@ -525,7 +521,7 @@ class ImageContentBlock(TypedDict):
525
521
  mime_type: NotRequired[str]
526
522
  """MIME type of the image. Required for base64.
527
523
 
528
- `Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#image>`__
524
+ [Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#image)
529
525
 
530
526
  """
531
527
 
@@ -546,8 +542,8 @@ class VideoContentBlock(TypedDict):
546
542
  """Video data.
547
543
 
548
544
  !!! note
549
- ``create_video_block`` may also be used as a factory to create a
550
- ``VideoContentBlock``. Benefits include:
545
+ `create_video_block` may also be used as a factory to create a
546
+ `VideoContentBlock`. Benefits include:
551
547
 
552
548
  * Automatic ID generation (when not provided)
553
549
  * Required arguments strictly validated at creation time
@@ -562,7 +558,7 @@ class VideoContentBlock(TypedDict):
562
558
 
563
559
  Either:
564
560
  - Generated by the provider (e.g., OpenAI's file ID)
565
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
561
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
566
562
 
567
563
  """
568
564
 
@@ -572,7 +568,7 @@ class VideoContentBlock(TypedDict):
572
568
  mime_type: NotRequired[str]
573
569
  """MIME type of the video. Required for base64.
574
570
 
575
- `Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#video>`__
571
+ [Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#video)
576
572
 
577
573
  """
578
574
 
@@ -593,8 +589,8 @@ class AudioContentBlock(TypedDict):
593
589
  """Audio data.
594
590
 
595
591
  !!! note
596
- ``create_audio_block`` may also be used as a factory to create an
597
- ``AudioContentBlock``. Benefits include:
592
+ `create_audio_block` may also be used as a factory to create an
593
+ `AudioContentBlock`. Benefits include:
598
594
  * Automatic ID generation (when not provided)
599
595
  * Required arguments strictly validated at creation time
600
596
 
@@ -608,7 +604,7 @@ class AudioContentBlock(TypedDict):
608
604
 
609
605
  Either:
610
606
  - Generated by the provider (e.g., OpenAI's file ID)
611
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
607
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
612
608
 
613
609
  """
614
610
 
@@ -618,7 +614,7 @@ class AudioContentBlock(TypedDict):
618
614
  mime_type: NotRequired[str]
619
615
  """MIME type of the audio. Required for base64.
620
616
 
621
- `Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml#audio>`__
617
+ [Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml#audio)
622
618
 
623
619
  """
624
620
 
@@ -639,18 +635,18 @@ class PlainTextContentBlock(TypedDict):
639
635
  """Plaintext data (e.g., from a document).
640
636
 
641
637
  !!! note
642
- A ``PlainTextContentBlock`` existed in ``langchain-core<1.0.0``. Although the
638
+ A `PlainTextContentBlock` existed in `langchain-core<1.0.0`. Although the
643
639
  name has carried over, the structure has changed significantly. The only shared
644
- keys between the old and new versions are ``type`` and ``text``, though the
645
- ``type`` value has changed from ``'text'`` to ``'text-plain'``.
640
+ keys between the old and new versions are `type` and `text`, though the
641
+ `type` value has changed from `'text'` to `'text-plain'`.
646
642
 
647
643
  !!! note
648
644
  Title and context are optional fields that may be passed to the model. See
649
- Anthropic `example <https://docs.anthropic.com/en/docs/build-with-claude/citations#citable-vs-non-citable-content>`__.
645
+ Anthropic [example](https://docs.anthropic.com/en/docs/build-with-claude/citations#citable-vs-non-citable-content).
650
646
 
651
647
  !!! note
652
- ``create_plaintext_block`` may also be used as a factory to create a
653
- ``PlainTextContentBlock``. Benefits include:
648
+ `create_plaintext_block` may also be used as a factory to create a
649
+ `PlainTextContentBlock`. Benefits include:
654
650
 
655
651
  * Automatic ID generation (when not provided)
656
652
  * Required arguments strictly validated at creation time
@@ -665,7 +661,7 @@ class PlainTextContentBlock(TypedDict):
665
661
 
666
662
  Either:
667
663
  - Generated by the provider (e.g., OpenAI's file ID)
668
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
664
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
669
665
 
670
666
  """
671
667
 
@@ -704,12 +700,12 @@ class FileContentBlock(TypedDict):
704
700
  example, it can be used for PDFs, Word documents, etc.
705
701
 
706
702
  If the file is an image, audio, or plaintext, you should use the corresponding
707
- content block type (e.g., ``ImageContentBlock``, ``AudioContentBlock``,
708
- ``PlainTextContentBlock``).
703
+ content block type (e.g., `ImageContentBlock`, `AudioContentBlock`,
704
+ `PlainTextContentBlock`).
709
705
 
710
706
  !!! note
711
- ``create_file_block`` may also be used as a factory to create a
712
- ``FileContentBlock``. Benefits include:
707
+ `create_file_block` may also be used as a factory to create a
708
+ `FileContentBlock`. Benefits include:
713
709
 
714
710
  * Automatic ID generation (when not provided)
715
711
  * Required arguments strictly validated at creation time
@@ -724,7 +720,7 @@ class FileContentBlock(TypedDict):
724
720
 
725
721
  Either:
726
722
  - Generated by the provider (e.g., OpenAI's file ID)
727
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
723
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
728
724
 
729
725
  """
730
726
 
@@ -734,7 +730,7 @@ class FileContentBlock(TypedDict):
734
730
  mime_type: NotRequired[str]
735
731
  """MIME type of the file. Required for base64.
736
732
 
737
- `Examples from IANA <https://www.iana.org/assignments/media-types/media-types.xhtml>`__
733
+ [Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml)
738
734
 
739
735
  """
740
736
 
@@ -764,14 +760,14 @@ class NonStandardContentBlock(TypedDict):
764
760
  The purpose of this block should be to simply hold a provider-specific payload.
765
761
  If a provider's non-standard output includes reasoning and tool calls, it should be
766
762
  the adapter's job to parse that payload and emit the corresponding standard
767
- ``ReasoningContentBlock`` and ``ToolCalls``.
763
+ `ReasoningContentBlock` and `ToolCalls`.
768
764
 
769
- Has no ``extras`` field, as provider-specific data should be included in the
770
- ``value`` field.
765
+ Has no `extras` field, as provider-specific data should be included in the
766
+ `value` field.
771
767
 
772
768
  !!! note
773
- ``create_non_standard_block`` may also be used as a factory to create a
774
- ``NonStandardContentBlock``. Benefits include:
769
+ `create_non_standard_block` may also be used as a factory to create a
770
+ `NonStandardContentBlock`. Benefits include:
775
771
 
776
772
  * Automatic ID generation (when not provided)
777
773
  * Required arguments strictly validated at creation time
@@ -786,7 +782,7 @@ class NonStandardContentBlock(TypedDict):
786
782
 
787
783
  Either:
788
784
  - Generated by the provider (e.g., OpenAI's file ID)
789
- - Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
785
+ - Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
790
786
 
791
787
  """
792
788
 
@@ -842,7 +838,7 @@ KNOWN_BLOCK_TYPES = {
842
838
  "non_standard",
843
839
  # citation and non_standard_annotation intentionally omitted
844
840
  }
845
- """These are block types known to ``langchain-core>=1.0.0``.
841
+ """These are block types known to `langchain-core>=1.0.0`.
846
842
 
847
843
  If a block has a type not in this set, it is considered to be provider-specific.
848
844
  """
@@ -881,7 +877,7 @@ def is_data_content_block(block: dict) -> bool:
881
877
  block: The content block to check.
882
878
 
883
879
  Returns:
884
- True if the content block is a data content block, False otherwise.
880
+ `True` if the content block is a data content block, `False` otherwise.
885
881
 
886
882
  """
887
883
  if block.get("type") not in _get_data_content_block_types():
@@ -923,20 +919,20 @@ def create_text_block(
923
919
  index: int | str | None = None,
924
920
  **kwargs: Any,
925
921
  ) -> TextContentBlock:
926
- """Create a ``TextContentBlock``.
922
+ """Create a `TextContentBlock`.
927
923
 
928
924
  Args:
929
925
  text: The text content of the block.
930
926
  id: Content block identifier. Generated automatically if not provided.
931
- annotations: ``Citation``s and other annotations for the text.
927
+ annotations: `Citation`s and other annotations for the text.
932
928
  index: Index of block in aggregate response. Used during streaming.
933
929
 
934
930
  Returns:
935
- A properly formatted ``TextContentBlock``.
931
+ A properly formatted `TextContentBlock`.
936
932
 
937
933
  !!! note
938
- The ``id`` is generated automatically if not provided, using a UUID4 format
939
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
934
+ The `id` is generated automatically if not provided, using a UUID4 format
935
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
940
936
 
941
937
  """
942
938
  block = TextContentBlock(
@@ -966,7 +962,7 @@ def create_image_block(
966
962
  index: int | str | None = None,
967
963
  **kwargs: Any,
968
964
  ) -> ImageContentBlock:
969
- """Create an ``ImageContentBlock``.
965
+ """Create an `ImageContentBlock`.
970
966
 
971
967
  Args:
972
968
  url: URL of the image.
@@ -977,15 +973,15 @@ def create_image_block(
977
973
  index: Index of block in aggregate response. Used during streaming.
978
974
 
979
975
  Returns:
980
- A properly formatted ``ImageContentBlock``.
976
+ A properly formatted `ImageContentBlock`.
981
977
 
982
978
  Raises:
983
- ValueError: If no image source is provided or if ``base64`` is used without
984
- ``mime_type``.
979
+ ValueError: If no image source is provided or if `base64` is used without
980
+ `mime_type`.
985
981
 
986
982
  !!! note
987
- The ``id`` is generated automatically if not provided, using a UUID4 format
988
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
983
+ The `id` is generated automatically if not provided, using a UUID4 format
984
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
989
985
 
990
986
  """
991
987
  if not any([url, base64, file_id]):
@@ -1022,7 +1018,7 @@ def create_video_block(
1022
1018
  index: int | str | None = None,
1023
1019
  **kwargs: Any,
1024
1020
  ) -> VideoContentBlock:
1025
- """Create a ``VideoContentBlock``.
1021
+ """Create a `VideoContentBlock`.
1026
1022
 
1027
1023
  Args:
1028
1024
  url: URL of the video.
@@ -1033,15 +1029,15 @@ def create_video_block(
1033
1029
  index: Index of block in aggregate response. Used during streaming.
1034
1030
 
1035
1031
  Returns:
1036
- A properly formatted ``VideoContentBlock``.
1032
+ A properly formatted `VideoContentBlock`.
1037
1033
 
1038
1034
  Raises:
1039
- ValueError: If no video source is provided or if ``base64`` is used without
1040
- ``mime_type``.
1035
+ ValueError: If no video source is provided or if `base64` is used without
1036
+ `mime_type`.
1041
1037
 
1042
1038
  !!! note
1043
- The ``id`` is generated automatically if not provided, using a UUID4 format
1044
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1039
+ The `id` is generated automatically if not provided, using a UUID4 format
1040
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1045
1041
 
1046
1042
  """
1047
1043
  if not any([url, base64, file_id]):
@@ -1082,7 +1078,7 @@ def create_audio_block(
1082
1078
  index: int | str | None = None,
1083
1079
  **kwargs: Any,
1084
1080
  ) -> AudioContentBlock:
1085
- """Create an ``AudioContentBlock``.
1081
+ """Create an `AudioContentBlock`.
1086
1082
 
1087
1083
  Args:
1088
1084
  url: URL of the audio.
@@ -1093,15 +1089,15 @@ def create_audio_block(
1093
1089
  index: Index of block in aggregate response. Used during streaming.
1094
1090
 
1095
1091
  Returns:
1096
- A properly formatted ``AudioContentBlock``.
1092
+ A properly formatted `AudioContentBlock`.
1097
1093
 
1098
1094
  Raises:
1099
- ValueError: If no audio source is provided or if ``base64`` is used without
1100
- ``mime_type``.
1095
+ ValueError: If no audio source is provided or if `base64` is used without
1096
+ `mime_type`.
1101
1097
 
1102
1098
  !!! note
1103
- The ``id`` is generated automatically if not provided, using a UUID4 format
1104
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1099
+ The `id` is generated automatically if not provided, using a UUID4 format
1100
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1105
1101
 
1106
1102
  """
1107
1103
  if not any([url, base64, file_id]):
@@ -1142,7 +1138,7 @@ def create_file_block(
1142
1138
  index: int | str | None = None,
1143
1139
  **kwargs: Any,
1144
1140
  ) -> FileContentBlock:
1145
- """Create a ``FileContentBlock``.
1141
+ """Create a `FileContentBlock`.
1146
1142
 
1147
1143
  Args:
1148
1144
  url: URL of the file.
@@ -1153,15 +1149,15 @@ def create_file_block(
1153
1149
  index: Index of block in aggregate response. Used during streaming.
1154
1150
 
1155
1151
  Returns:
1156
- A properly formatted ``FileContentBlock``.
1152
+ A properly formatted `FileContentBlock`.
1157
1153
 
1158
1154
  Raises:
1159
- ValueError: If no file source is provided or if ``base64`` is used without
1160
- ``mime_type``.
1155
+ ValueError: If no file source is provided or if `base64` is used without
1156
+ `mime_type`.
1161
1157
 
1162
1158
  !!! note
1163
- The ``id`` is generated automatically if not provided, using a UUID4 format
1164
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1159
+ The `id` is generated automatically if not provided, using a UUID4 format
1160
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1165
1161
 
1166
1162
  """
1167
1163
  if not any([url, base64, file_id]):
@@ -1203,7 +1199,7 @@ def create_plaintext_block(
1203
1199
  index: int | str | None = None,
1204
1200
  **kwargs: Any,
1205
1201
  ) -> PlainTextContentBlock:
1206
- """Create a ``PlainTextContentBlock``.
1202
+ """Create a `PlainTextContentBlock`.
1207
1203
 
1208
1204
  Args:
1209
1205
  text: The plaintext content.
@@ -1216,11 +1212,11 @@ def create_plaintext_block(
1216
1212
  index: Index of block in aggregate response. Used during streaming.
1217
1213
 
1218
1214
  Returns:
1219
- A properly formatted ``PlainTextContentBlock``.
1215
+ A properly formatted `PlainTextContentBlock`.
1220
1216
 
1221
1217
  !!! note
1222
- The ``id`` is generated automatically if not provided, using a UUID4 format
1223
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1218
+ The `id` is generated automatically if not provided, using a UUID4 format
1219
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1224
1220
 
1225
1221
  """
1226
1222
  block = PlainTextContentBlock(
@@ -1259,7 +1255,7 @@ def create_tool_call(
1259
1255
  index: int | str | None = None,
1260
1256
  **kwargs: Any,
1261
1257
  ) -> ToolCall:
1262
- """Create a ``ToolCall``.
1258
+ """Create a `ToolCall`.
1263
1259
 
1264
1260
  Args:
1265
1261
  name: The name of the tool to be called.
@@ -1268,11 +1264,11 @@ def create_tool_call(
1268
1264
  index: Index of block in aggregate response. Used during streaming.
1269
1265
 
1270
1266
  Returns:
1271
- A properly formatted ``ToolCall``.
1267
+ A properly formatted `ToolCall`.
1272
1268
 
1273
1269
  !!! note
1274
- The ``id`` is generated automatically if not provided, using a UUID4 format
1275
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1270
+ The `id` is generated automatically if not provided, using a UUID4 format
1271
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1276
1272
 
1277
1273
  """
1278
1274
  block = ToolCall(
@@ -1298,7 +1294,7 @@ def create_reasoning_block(
1298
1294
  index: int | str | None = None,
1299
1295
  **kwargs: Any,
1300
1296
  ) -> ReasoningContentBlock:
1301
- """Create a ``ReasoningContentBlock``.
1297
+ """Create a `ReasoningContentBlock`.
1302
1298
 
1303
1299
  Args:
1304
1300
  reasoning: The reasoning text or thought summary.
@@ -1306,11 +1302,11 @@ def create_reasoning_block(
1306
1302
  index: Index of block in aggregate response. Used during streaming.
1307
1303
 
1308
1304
  Returns:
1309
- A properly formatted ``ReasoningContentBlock``.
1305
+ A properly formatted `ReasoningContentBlock`.
1310
1306
 
1311
1307
  !!! note
1312
- The ``id`` is generated automatically if not provided, using a UUID4 format
1313
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1308
+ The `id` is generated automatically if not provided, using a UUID4 format
1309
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1314
1310
 
1315
1311
  """
1316
1312
  block = ReasoningContentBlock(
@@ -1339,7 +1335,7 @@ def create_citation(
1339
1335
  id: str | None = None,
1340
1336
  **kwargs: Any,
1341
1337
  ) -> Citation:
1342
- """Create a ``Citation``.
1338
+ """Create a `Citation`.
1343
1339
 
1344
1340
  Args:
1345
1341
  url: URL of the document source.
@@ -1350,11 +1346,11 @@ def create_citation(
1350
1346
  id: Content block identifier. Generated automatically if not provided.
1351
1347
 
1352
1348
  Returns:
1353
- A properly formatted ``Citation``.
1349
+ A properly formatted `Citation`.
1354
1350
 
1355
1351
  !!! note
1356
- The ``id`` is generated automatically if not provided, using a UUID4 format
1357
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1352
+ The `id` is generated automatically if not provided, using a UUID4 format
1353
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1358
1354
 
1359
1355
  """
1360
1356
  block = Citation(type="citation", id=ensure_id(id))
@@ -1383,7 +1379,7 @@ def create_non_standard_block(
1383
1379
  id: str | None = None,
1384
1380
  index: int | str | None = None,
1385
1381
  ) -> NonStandardContentBlock:
1386
- """Create a ``NonStandardContentBlock``.
1382
+ """Create a `NonStandardContentBlock`.
1387
1383
 
1388
1384
  Args:
1389
1385
  value: Provider-specific data.
@@ -1391,11 +1387,11 @@ def create_non_standard_block(
1391
1387
  index: Index of block in aggregate response. Used during streaming.
1392
1388
 
1393
1389
  Returns:
1394
- A properly formatted ``NonStandardContentBlock``.
1390
+ A properly formatted `NonStandardContentBlock`.
1395
1391
 
1396
1392
  !!! note
1397
- The ``id`` is generated automatically if not provided, using a UUID4 format
1398
- prefixed with ``'lc_'`` to indicate it is a LangChain-generated ID.
1393
+ The `id` is generated automatically if not provided, using a UUID4 format
1394
+ prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
1399
1395
 
1400
1396
  """
1401
1397
  block = NonStandardContentBlock(