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
@@ -56,22 +56,17 @@ def draw_mermaid(
56
56
  """Draws a Mermaid graph using the provided graph data.
57
57
 
58
58
  Args:
59
- nodes (dict[str, str]): List of node ids.
60
- edges (list[Edge]): List of edges, object with a source,
61
- target and data.
62
- first_node (str, optional): Id of the first node. Defaults to None.
63
- last_node (str, optional): Id of the last node. Defaults to None.
64
- with_styles (bool, optional): Whether to include styles in the graph.
65
- Defaults to True.
66
- curve_style (CurveStyle, optional): Curve style for the edges.
67
- Defaults to CurveStyle.LINEAR.
68
- node_styles (NodeStyles, optional): Node colors for different types.
69
- Defaults to NodeStyles().
70
- wrap_label_n_words (int, optional): Words to wrap the edge labels.
71
- Defaults to 9.
72
- frontmatter_config (dict[str, Any], optional): Mermaid frontmatter config.
59
+ nodes: List of node ids.
60
+ edges: List of edges, object with a source, target and data.
61
+ first_node: Id of the first node.
62
+ last_node: Id of the last node.
63
+ with_styles: Whether to include styles in the graph. Defaults to `True`.
64
+ curve_style: Curve style for the edges. Defaults to CurveStyle.LINEAR.
65
+ node_styles: Node colors for different types. Defaults to NodeStyles().
66
+ wrap_label_n_words: Words to wrap the edge labels. Defaults to 9.
67
+ frontmatter_config: Mermaid frontmatter config.
73
68
  Can be used to customize theme and styles. Will be converted to YAML and
74
- added to the beginning of the mermaid graph. Defaults to None.
69
+ added to the beginning of the mermaid graph.
75
70
 
76
71
  See more here: https://mermaid.js.org/config/configuration.html.
77
72
 
@@ -87,7 +82,7 @@ def draw_mermaid(
87
82
  }
88
83
  ```
89
84
  Returns:
90
- str: Mermaid graph syntax.
85
+ Mermaid graph syntax.
91
86
 
92
87
  """
93
88
  # Initialize Mermaid graph configuration
@@ -290,23 +285,17 @@ def draw_mermaid_png(
290
285
  """Draws a Mermaid graph as PNG using provided syntax.
291
286
 
292
287
  Args:
293
- mermaid_syntax (str): Mermaid graph syntax.
294
- output_file_path (str, optional): Path to save the PNG image.
295
- Defaults to None.
296
- draw_method (MermaidDrawMethod, optional): Method to draw the graph.
297
- Defaults to MermaidDrawMethod.API.
298
- background_color (str, optional): Background color of the image.
299
- Defaults to "white".
300
- padding (int, optional): Padding around the image. Defaults to 10.
301
- max_retries (int, optional): Maximum number of retries (MermaidDrawMethod.API).
302
- Defaults to 1.
303
- retry_delay (float, optional): Delay between retries (MermaidDrawMethod.API).
304
- Defaults to 1.0.
305
- base_url (str, optional): Base URL for the Mermaid.ink API.
306
- Defaults to None.
288
+ mermaid_syntax: Mermaid graph syntax.
289
+ output_file_path: Path to save the PNG image.
290
+ draw_method: Method to draw the graph. Defaults to MermaidDrawMethod.API.
291
+ background_color: Background color of the image. Defaults to "white".
292
+ padding: Padding around the image. Defaults to 10.
293
+ max_retries: Maximum number of retries (MermaidDrawMethod.API). Defaults to 1.
294
+ retry_delay: Delay between retries (MermaidDrawMethod.API). Defaults to 1.0.
295
+ base_url: Base URL for the Mermaid.ink API.
307
296
 
308
297
  Returns:
309
- bytes: PNG image bytes.
298
+ PNG image bytes.
310
299
 
311
300
  Raises:
312
301
  ValueError: If an invalid draw method is provided.
@@ -15,7 +15,7 @@ except ImportError:
15
15
  class PngDrawer:
16
16
  """Helper class to draw a state graph into a PNG file.
17
17
 
18
- It requires ``graphviz`` and ``pygraphviz`` to be installed.
18
+ It requires `graphviz` and `pygraphviz` to be installed.
19
19
 
20
20
  Example:
21
21
  ```python
@@ -45,7 +45,7 @@ class PngDrawer:
45
45
  }
46
46
  }
47
47
  The keys are the original labels, and the values are the new labels.
48
- Defaults to None.
48
+
49
49
  """
50
50
  self.fontname = fontname or "arial"
51
51
  self.labels = labels or LabelsDict(nodes={}, edges={})
@@ -104,8 +104,8 @@ class PngDrawer:
104
104
  viz: The graphviz object.
105
105
  source: The source node.
106
106
  target: The target node.
107
- label: The label for the edge. Defaults to None.
108
- conditional: Whether the edge is conditional. Defaults to False.
107
+ label: The label for the edge.
108
+ conditional: Whether the edge is conditional. Defaults to `False`.
109
109
  """
110
110
  viz.add_edge(
111
111
  source,
@@ -123,13 +123,13 @@ class PngDrawer:
123
123
 
124
124
  Args:
125
125
  graph: The graph to draw
126
- output_path: The path to save the PNG. If None, PNG bytes are returned.
126
+ output_path: The path to save the PNG. If `None`, PNG bytes are returned.
127
127
 
128
128
  Raises:
129
- ImportError: If ``pygraphviz`` is not installed.
129
+ ImportError: If `pygraphviz` is not installed.
130
130
 
131
131
  Returns:
132
- The PNG bytes if ``output_path`` is None, else None.
132
+ The PNG bytes if `output_path` is None, else None.
133
133
  """
134
134
  if not _HAS_PYGRAPHVIZ:
135
135
  msg = "Install pygraphviz to draw graphs: `pip install pygraphviz`."
@@ -57,17 +57,17 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
57
57
  In this case, the invocation would look like this:
58
58
 
59
59
  `with_history.invoke(..., config={"configurable": {"session_id": "bar"}})`
60
- ; e.g., ``{"configurable": {"session_id": "<SESSION_ID>"}}``.
60
+ ; e.g., `{"configurable": {"session_id": "<SESSION_ID>"}}`.
61
61
 
62
62
  The configuration can be customized by passing in a list of
63
- ``ConfigurableFieldSpec`` objects to the ``history_factory_config`` parameter (see
63
+ `ConfigurableFieldSpec` objects to the `history_factory_config` parameter (see
64
64
  example below).
65
65
 
66
66
  In the examples, we will use a chat message history with an in-memory
67
67
  implementation to make it easy to experiment and see the results.
68
68
 
69
69
  For production use cases, you will want to use a persistent implementation
70
- of chat message history, such as ``RedisChatMessageHistory``.
70
+ of chat message history, such as `RedisChatMessageHistory`.
71
71
 
72
72
  Example: Chat message history with an in-memory implementation for testing.
73
73
 
@@ -224,7 +224,7 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
224
224
 
225
225
  get_session_history: GetSessionHistoryCallable
226
226
  """Function that returns a new BaseChatMessageHistory.
227
- This function should either take a single positional argument ``session_id`` of type
227
+ This function should either take a single positional argument `session_id` of type
228
228
  string and return a corresponding chat message history instance"""
229
229
  input_messages_key: str | None = None
230
230
  """Must be specified if the base runnable accepts a dict as input.
@@ -237,7 +237,7 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
237
237
  separate key for historical messages."""
238
238
  history_factory_config: Sequence[ConfigurableFieldSpec]
239
239
  """Configure fields that should be passed to the chat history factory.
240
- See ``ConfigurableFieldSpec`` for more details."""
240
+ See `ConfigurableFieldSpec` for more details."""
241
241
 
242
242
  def __init__(
243
243
  self,
@@ -260,18 +260,18 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
260
260
  runnable: The base Runnable to be wrapped.
261
261
  Must take as input one of:
262
262
 
263
- 1. A list of ``BaseMessage``
263
+ 1. A list of `BaseMessage`
264
264
  2. A dict with one key for all messages
265
265
  3. A dict with one key for the current input string/message(s) and
266
- a separate key for historical messages. If the input key points
267
- to a string, it will be treated as a ``HumanMessage`` in history.
266
+ a separate key for historical messages. If the input key points
267
+ to a string, it will be treated as a `HumanMessage` in history.
268
268
 
269
269
  Must return as output one of:
270
270
 
271
- 1. A string which can be treated as an ``AIMessage``
272
- 2. A ``BaseMessage`` or sequence of ``BaseMessage``
273
- 3. A dict with a key for a ``BaseMessage`` or sequence of
274
- ``BaseMessage``
271
+ 1. A string which can be treated as an `AIMessage`
272
+ 2. A `BaseMessage` or sequence of `BaseMessage`
273
+ 3. A dict with a key for a `BaseMessage` or sequence of
274
+ `BaseMessage`
275
275
 
276
276
  get_session_history: Function that returns a new BaseChatMessageHistory.
277
277
  This function should either take a single positional argument
@@ -279,7 +279,7 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
279
279
  chat message history instance.
280
280
  ```python
281
281
  def get_session_history(
282
- session_id: str, *, user_id: Optional[str] = None
282
+ session_id: str, *, user_id: str | None = None
283
283
  ) -> BaseChatMessageHistory: ...
284
284
  ```
285
285
 
@@ -302,11 +302,11 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
302
302
  history_messages_key: Must be specified if the base runnable accepts a dict
303
303
  as input and expects a separate key for historical messages.
304
304
  history_factory_config: Configure fields that should be passed to the
305
- chat history factory. See ``ConfigurableFieldSpec`` for more details.
305
+ chat history factory. See `ConfigurableFieldSpec` for more details.
306
306
  Specifying these allows you to pass multiple config keys
307
307
  into the get_session_history factory.
308
308
  **kwargs: Arbitrary additional kwargs to pass to parent class
309
- ``RunnableBindingBase`` init.
309
+ `RunnableBindingBase` init.
310
310
 
311
311
  """
312
312
  history_chain: Runnable = RunnableLambda(
@@ -400,11 +400,11 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
400
400
  def get_output_schema(
401
401
  self, config: RunnableConfig | None = None
402
402
  ) -> type[BaseModel]:
403
- """Get a pydantic model that can be used to validate output to the Runnable.
403
+ """Get a Pydantic model that can be used to validate output to the `Runnable`.
404
404
 
405
- Runnables that leverage the configurable_fields and configurable_alternatives
406
- methods will have a dynamic output schema that depends on which
407
- configuration the Runnable is invoked with.
405
+ `Runnable` objects that leverage the `configurable_fields` and
406
+ `configurable_alternatives` methods will have a dynamic output schema that
407
+ depends on which configuration the `Runnable` is invoked with.
408
408
 
409
409
  This method allows to get an output schema for a specific configuration.
410
410
 
@@ -412,7 +412,7 @@ class RunnableWithMessageHistory(RunnableBindingBase): # type: ignore[no-redef]
412
412
  config: A config to use when generating the schema.
413
413
 
414
414
  Returns:
415
- A pydantic model that can be used to validate output.
415
+ A Pydantic model that can be used to validate output.
416
416
  """
417
417
  root_type = self.OutputType
418
418
 
@@ -51,10 +51,10 @@ def identity(x: Other) -> Other:
51
51
  """Identity function.
52
52
 
53
53
  Args:
54
- x (Other): input.
54
+ x: input.
55
55
 
56
56
  Returns:
57
- Other: output.
57
+ output.
58
58
  """
59
59
  return x
60
60
 
@@ -63,10 +63,10 @@ async def aidentity(x: Other) -> Other:
63
63
  """Async identity function.
64
64
 
65
65
  Args:
66
- x (Other): input.
66
+ x: input.
67
67
 
68
68
  Returns:
69
- Other: output.
69
+ output.
70
70
  """
71
71
  return x
72
72
 
@@ -188,7 +188,7 @@ class RunnablePassthrough(RunnableSerializable[Other, Other]):
188
188
  """Get the namespace of the langchain object.
189
189
 
190
190
  Returns:
191
- ``["langchain", "schema", "runnable"]``
191
+ `["langchain", "schema", "runnable"]`
192
192
  """
193
193
  return ["langchain", "schema", "runnable"]
194
194
 
@@ -395,7 +395,7 @@ class RunnableAssign(RunnableSerializable[dict[str, Any], dict[str, Any]]):
395
395
  """Create a RunnableAssign.
396
396
 
397
397
  Args:
398
- mapper: A ``RunnableParallel`` instance that will be used to transform the
398
+ mapper: A `RunnableParallel` instance that will be used to transform the
399
399
  input dictionary.
400
400
  """
401
401
  super().__init__(mapper=mapper, **kwargs)
@@ -412,7 +412,7 @@ class RunnableAssign(RunnableSerializable[dict[str, Any], dict[str, Any]]):
412
412
  """Get the namespace of the langchain object.
413
413
 
414
414
  Returns:
415
- ``["langchain", "schema", "runnable"]``
415
+ `["langchain", "schema", "runnable"]`
416
416
  """
417
417
  return ["langchain", "schema", "runnable"]
418
418
 
@@ -717,7 +717,7 @@ class RunnablePick(RunnableSerializable[dict[str, Any], dict[str, Any]]):
717
717
  """Get the namespace of the langchain object.
718
718
 
719
719
  Returns:
720
- ``["langchain", "schema", "runnable"]``
720
+ `["langchain", "schema", "runnable"]`
721
721
  """
722
722
  return ["langchain", "schema", "runnable"]
723
723
 
@@ -33,7 +33,7 @@ U = TypeVar("U")
33
33
 
34
34
 
35
35
  class ExponentialJitterParams(TypedDict, total=False):
36
- """Parameters for ``tenacity.wait_exponential_jitter``."""
36
+ """Parameters for `tenacity.wait_exponential_jitter`."""
37
37
 
38
38
  initial: float
39
39
  """Initial wait."""
@@ -125,8 +125,8 @@ class RunnableRetry(RunnableBindingBase[Input, Output]): # type: ignore[no-rede
125
125
  """Whether to add jitter to the exponential backoff."""
126
126
 
127
127
  exponential_jitter_params: ExponentialJitterParams | None = None
128
- """Parameters for ``tenacity.wait_exponential_jitter``. Namely: ``initial``,
129
- ``max``, ``exp_base``, and ``jitter`` (all float values).
128
+ """Parameters for `tenacity.wait_exponential_jitter`. Namely: `initial`,
129
+ `max`, `exp_base`, and `jitter` (all float values).
130
130
  """
131
131
 
132
132
  max_attempt_number: int = 3
@@ -99,7 +99,7 @@ class RouterRunnable(RunnableSerializable[RouterInput, Output]):
99
99
  """Get the namespace of the langchain object.
100
100
 
101
101
  Returns:
102
- ``["langchain", "schema", "runnable"]``
102
+ `["langchain", "schema", "runnable"]`
103
103
  """
104
104
  return ["langchain", "schema", "runnable"]
105
105
 
@@ -1,4 +1,4 @@
1
- """Module contains typedefs that are used with Runnables."""
1
+ """Module contains typedefs that are used with `Runnable` objects."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -14,43 +14,43 @@ class EventData(TypedDict, total=False):
14
14
  """Data associated with a streaming event."""
15
15
 
16
16
  input: Any
17
- """The input passed to the Runnable that generated the event.
17
+ """The input passed to the `Runnable` that generated the event.
18
18
 
19
- Inputs will sometimes be available at the *START* of the Runnable, and
20
- sometimes at the *END* of the Runnable.
19
+ Inputs will sometimes be available at the *START* of the `Runnable`, and
20
+ sometimes at the *END* of the `Runnable`.
21
21
 
22
- If a Runnable is able to stream its inputs, then its input by definition
23
- won't be known until the *END* of the Runnable when it has finished streaming
22
+ If a `Runnable` is able to stream its inputs, then its input by definition
23
+ won't be known until the *END* of the `Runnable` when it has finished streaming
24
24
  its inputs.
25
25
  """
26
26
  error: NotRequired[BaseException]
27
- """The error that occurred during the execution of the Runnable.
27
+ """The error that occurred during the execution of the `Runnable`.
28
28
 
29
- This field is only available if the Runnable raised an exception.
29
+ This field is only available if the `Runnable` raised an exception.
30
30
 
31
31
  !!! version-added "Added in version 1.0.0"
32
32
  """
33
33
  output: Any
34
- """The output of the Runnable that generated the event.
34
+ """The output of the `Runnable` that generated the event.
35
35
 
36
- Outputs will only be available at the *END* of the Runnable.
36
+ Outputs will only be available at the *END* of the `Runnable`.
37
37
 
38
- For most Runnables, this field can be inferred from the `chunk` field,
39
- though there might be some exceptions for special cased Runnables (e.g., like
38
+ For most `Runnable` objects, this field can be inferred from the `chunk` field,
39
+ though there might be some exceptions for special a cased `Runnable` (e.g., like
40
40
  chat models), which may return more information.
41
41
  """
42
42
  chunk: Any
43
43
  """A streaming chunk from the output that generated the event.
44
44
 
45
45
  chunks support addition in general, and adding them up should result
46
- in the output of the Runnable that generated the event.
46
+ in the output of the `Runnable` that generated the event.
47
47
  """
48
48
 
49
49
 
50
50
  class BaseStreamEvent(TypedDict):
51
51
  """Streaming event.
52
52
 
53
- Schema of a streaming event which is produced from the astream_events method.
53
+ Schema of a streaming event which is produced from the `astream_events` method.
54
54
 
55
55
  Example:
56
56
  ```python
@@ -94,45 +94,45 @@ class BaseStreamEvent(TypedDict):
94
94
  """
95
95
 
96
96
  event: str
97
- """Event names are of the format: on_[runnable_type]_(start|stream|end).
97
+ """Event names are of the format: `on_[runnable_type]_(start|stream|end)`.
98
98
 
99
99
  Runnable types are one of:
100
100
 
101
101
  - **llm** - used by non chat models
102
102
  - **chat_model** - used by chat models
103
- - **prompt** -- e.g., ChatPromptTemplate
104
- - **tool** -- from tools defined via @tool decorator or inheriting
105
- from Tool/BaseTool
106
- - **chain** - most Runnables are of this type
103
+ - **prompt** -- e.g., `ChatPromptTemplate`
104
+ - **tool** -- from tools defined via `@tool` decorator or inheriting
105
+ from `Tool`/`BaseTool`
106
+ - **chain** - most `Runnable` objects are of this type
107
107
 
108
108
  Further, the events are categorized as one of:
109
109
 
110
- - **start** - when the Runnable starts
111
- - **stream** - when the Runnable is streaming
112
- - **end* - when the Runnable ends
110
+ - **start** - when the `Runnable` starts
111
+ - **stream** - when the `Runnable` is streaming
112
+ - **end* - when the `Runnable` ends
113
113
 
114
114
  start, stream and end are associated with slightly different `data` payload.
115
115
 
116
116
  Please see the documentation for `EventData` for more details.
117
117
  """
118
118
  run_id: str
119
- """An randomly generated ID to keep track of the execution of the given Runnable.
119
+ """An randomly generated ID to keep track of the execution of the given `Runnable`.
120
120
 
121
- Each child Runnable that gets invoked as part of the execution of a parent Runnable
122
- is assigned its own unique ID.
121
+ Each child `Runnable` that gets invoked as part of the execution of a parent
122
+ `Runnable` is assigned its own unique ID.
123
123
  """
124
124
  tags: NotRequired[list[str]]
125
- """Tags associated with the Runnable that generated this event.
125
+ """Tags associated with the `Runnable` that generated this event.
126
126
 
127
- Tags are always inherited from parent Runnables.
127
+ Tags are always inherited from parent `Runnable` objects.
128
128
 
129
- Tags can either be bound to a Runnable using `.with_config({"tags": ["hello"]})`
129
+ Tags can either be bound to a `Runnable` using `.with_config({"tags": ["hello"]})`
130
130
  or passed at run time using `.astream_events(..., {"tags": ["hello"]})`.
131
131
  """
132
132
  metadata: NotRequired[dict[str, Any]]
133
- """Metadata associated with the Runnable that generated this event.
133
+ """Metadata associated with the `Runnable` that generated this event.
134
134
 
135
- Metadata can either be bound to a Runnable using
135
+ Metadata can either be bound to a `Runnable` using
136
136
 
137
137
  `.with_config({"metadata": { "foo": "bar" }})`
138
138
 
@@ -146,8 +146,8 @@ class BaseStreamEvent(TypedDict):
146
146
 
147
147
  Root Events will have an empty list.
148
148
 
149
- For example, if a Runnable A calls Runnable B, then the event generated by Runnable
150
- B will have Runnable A's ID in the parent_ids field.
149
+ For example, if a `Runnable` A calls `Runnable` B, then the event generated by
150
+ `Runnable` B will have `Runnable` A's ID in the `parent_ids` field.
151
151
 
152
152
  The order of the parent IDs is from the root parent to the immediate parent.
153
153
 
@@ -164,7 +164,7 @@ class StandardStreamEvent(BaseStreamEvent):
164
164
  The contents of the event data depend on the event type.
165
165
  """
166
166
  name: str
167
- """The name of the Runnable that generated the event."""
167
+ """The name of the `Runnable` that generated the event."""
168
168
 
169
169
 
170
170
  class CustomStreamEvent(BaseStreamEvent):