langchain-core 1.0.0a7__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 +76 -55
  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.0a7.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.0a7.dist-info/RECORD +0 -176
  135. {langchain_core-1.0.0a7.dist-info → langchain_core-1.0.0rc1.dist-info}/WHEEL +0 -0
@@ -1,12 +1,4 @@
1
- """**Tracers** are classes for tracing runs.
2
-
3
- **Class hierarchy:**
4
-
5
- .. code-block::
6
-
7
- BaseCallbackHandler --> BaseTracer --> <name>Tracer # Examples: LangChainTracer, RootListenersTracer
8
- --> <name> # Examples: LogStreamCallbackHandler
9
- """ # noqa: E501
1
+ """**Tracers** are classes for tracing runs."""
10
2
 
11
3
  from typing import TYPE_CHECKING
12
4
 
@@ -67,11 +67,11 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
67
67
  serialized: The serialized model.
68
68
  messages: The messages to start the chat with.
69
69
  run_id: The run ID.
70
- tags: The tags for the run. Defaults to None.
71
- parent_run_id: The parent run ID. Defaults to None.
72
- metadata: The metadata for the run. Defaults to None.
70
+ tags: The tags for the run.
71
+ parent_run_id: The parent run ID.
72
+ metadata: The metadata for the run.
73
73
  name: The name of the run.
74
- kwargs: Additional arguments.
74
+ **kwargs: Additional arguments.
75
75
 
76
76
  Returns:
77
77
  The run.
@@ -108,11 +108,11 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
108
108
  serialized: The serialized model.
109
109
  prompts: The prompts to start the LLM with.
110
110
  run_id: The run ID.
111
- tags: The tags for the run. Defaults to None.
112
- parent_run_id: The parent run ID. Defaults to None.
113
- metadata: The metadata for the run. Defaults to None.
111
+ tags: The tags for the run.
112
+ parent_run_id: The parent run ID.
113
+ metadata: The metadata for the run.
114
114
  name: The name of the run.
115
- kwargs: Additional arguments.
115
+ **kwargs: Additional arguments.
116
116
 
117
117
  Returns:
118
118
  The run.
@@ -145,10 +145,10 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
145
145
 
146
146
  Args:
147
147
  token: The token.
148
- chunk: The chunk. Defaults to None.
148
+ chunk: The chunk.
149
149
  run_id: The run ID.
150
- parent_run_id: The parent run ID. Defaults to None.
151
- kwargs: Additional arguments.
150
+ parent_run_id: The parent run ID.
151
+ **kwargs: Additional arguments.
152
152
 
153
153
  Returns:
154
154
  The run.
@@ -177,7 +177,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
177
177
  Args:
178
178
  retry_state: The retry state.
179
179
  run_id: The run ID.
180
- kwargs: Additional arguments.
180
+ **kwargs: Additional arguments.
181
181
 
182
182
  Returns:
183
183
  The run.
@@ -194,7 +194,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
194
194
  Args:
195
195
  response: The response.
196
196
  run_id: The run ID.
197
- kwargs: Additional arguments.
197
+ **kwargs: Additional arguments.
198
198
 
199
199
  Returns:
200
200
  The run.
@@ -221,7 +221,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
221
221
  Args:
222
222
  error: The error.
223
223
  run_id: The run ID.
224
- kwargs: Additional arguments.
224
+ **kwargs: Additional arguments.
225
225
 
226
226
  Returns:
227
227
  The run.
@@ -255,12 +255,12 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
255
255
  serialized: The serialized chain.
256
256
  inputs: The inputs for the chain.
257
257
  run_id: The run ID.
258
- tags: The tags for the run. Defaults to None.
259
- parent_run_id: The parent run ID. Defaults to None.
260
- metadata: The metadata for the run. Defaults to None.
261
- run_type: The type of the run. Defaults to None.
258
+ tags: The tags for the run.
259
+ parent_run_id: The parent run ID.
260
+ metadata: The metadata for the run.
261
+ run_type: The type of the run.
262
262
  name: The name of the run.
263
- kwargs: Additional arguments.
263
+ **kwargs: Additional arguments.
264
264
 
265
265
  Returns:
266
266
  The run.
@@ -294,8 +294,8 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
294
294
  Args:
295
295
  outputs: The outputs for the chain.
296
296
  run_id: The run ID.
297
- inputs: The inputs for the chain. Defaults to None.
298
- kwargs: Additional arguments.
297
+ inputs: The inputs for the chain.
298
+ **kwargs: Additional arguments.
299
299
 
300
300
  Returns:
301
301
  The run.
@@ -322,9 +322,9 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
322
322
 
323
323
  Args:
324
324
  error: The error.
325
- inputs: The inputs for the chain. Defaults to None.
325
+ inputs: The inputs for the chain.
326
326
  run_id: The run ID.
327
- kwargs: Additional arguments.
327
+ **kwargs: Additional arguments.
328
328
 
329
329
  Returns:
330
330
  The run.
@@ -357,12 +357,12 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
357
357
  serialized: The serialized tool.
358
358
  input_str: The input string.
359
359
  run_id: The run ID.
360
- tags: The tags for the run. Defaults to None.
361
- parent_run_id: The parent run ID. Defaults to None.
362
- metadata: The metadata for the run. Defaults to None.
360
+ tags: The tags for the run.
361
+ parent_run_id: The parent run ID.
362
+ metadata: The metadata for the run.
363
363
  name: The name of the run.
364
364
  inputs: The inputs for the tool.
365
- kwargs: Additional arguments.
365
+ **kwargs: Additional arguments.
366
366
 
367
367
  Returns:
368
368
  The run.
@@ -389,7 +389,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
389
389
  Args:
390
390
  output: The output for the tool.
391
391
  run_id: The run ID.
392
- kwargs: Additional arguments.
392
+ **kwargs: Additional arguments.
393
393
 
394
394
  Returns:
395
395
  The run.
@@ -415,7 +415,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
415
415
  Args:
416
416
  error: The error.
417
417
  run_id: The run ID.
418
- kwargs: Additional arguments.
418
+ **kwargs: Additional arguments.
419
419
 
420
420
  Returns:
421
421
  The run.
@@ -446,11 +446,11 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
446
446
  serialized: The serialized retriever.
447
447
  query: The query.
448
448
  run_id: The run ID.
449
- parent_run_id: The parent run ID. Defaults to None.
450
- tags: The tags for the run. Defaults to None.
451
- metadata: The metadata for the run. Defaults to None.
449
+ parent_run_id: The parent run ID.
450
+ tags: The tags for the run.
451
+ metadata: The metadata for the run.
452
452
  name: The name of the run.
453
- kwargs: Additional arguments.
453
+ **kwargs: Additional arguments.
454
454
 
455
455
  Returns:
456
456
  The run.
@@ -482,7 +482,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
482
482
  Args:
483
483
  error: The error.
484
484
  run_id: The run ID.
485
- kwargs: Additional arguments.
485
+ **kwargs: Additional arguments.
486
486
 
487
487
  Returns:
488
488
  The run.
@@ -504,7 +504,7 @@ class BaseTracer(_TracerCore, BaseCallbackHandler, ABC):
504
504
  Args:
505
505
  documents: The documents.
506
506
  run_id: The run ID.
507
- kwargs: Additional arguments.
507
+ **kwargs: Additional arguments.
508
508
 
509
509
  Returns:
510
510
  The run.
@@ -47,17 +47,13 @@ def tracing_v2_enabled(
47
47
  """Instruct LangChain to log all runs in context to LangSmith.
48
48
 
49
49
  Args:
50
- project_name (str, optional): The name of the project.
51
- Defaults to ``'default'``.
52
- example_id (str or UUID, optional): The ID of the example.
53
- Defaults to None.
54
- tags (list[str], optional): The tags to add to the run.
55
- Defaults to None.
56
- client (LangSmithClient, optional): The client of the langsmith.
57
- Defaults to None.
50
+ project_name: The name of the project. Defaults to `'default'`.
51
+ example_id: The ID of the example.
52
+ tags: The tags to add to the run.
53
+ client: The client of the langsmith.
58
54
 
59
55
  Yields:
60
- LangChainTracer: The LangChain tracer.
56
+ The LangChain tracer.
61
57
 
62
58
  Example:
63
59
  >>> with tracing_v2_enabled():
@@ -89,7 +85,7 @@ def collect_runs() -> Generator[RunCollectorCallbackHandler, None, None]:
89
85
  """Collect all run traces in context.
90
86
 
91
87
  Yields:
92
- run_collector.RunCollectorCallbackHandler: The run collector callback handler.
88
+ The run collector callback handler.
93
89
 
94
90
  Example:
95
91
  >>> with collect_runs() as runs_cb:
@@ -179,15 +175,14 @@ def register_configure_hook(
179
175
  """Register a configure hook.
180
176
 
181
177
  Args:
182
- context_var (ContextVar[Optional[Any]]): The context variable.
183
- inheritable (bool): Whether the context variable is inheritable.
184
- handle_class (Optional[Type[BaseCallbackHandler]], optional):
185
- The callback handler class. Defaults to None.
186
- env_var (Optional[str], optional): The environment variable. Defaults to None.
178
+ context_var: The context variable.
179
+ inheritable: Whether the context variable is inheritable.
180
+ handle_class: The callback handler class.
181
+ env_var: The environment variable.
187
182
 
188
183
  Raises:
189
- ValueError: If env_var is set, handle_class must also be set
190
- to a non-None value.
184
+ ValueError: If env_var is set, handle_class must also be set to a non-None
185
+ value.
191
186
  """
192
187
  if env_var is not None and handle_class is None:
193
188
  msg = "If env_var is set, handle_class must also be set to a non-None value."
@@ -179,7 +179,7 @@ class _AstreamEventsCallbackHandler(AsyncCallbackHandler, _StreamingCallbackHand
179
179
  output: The output of the Runnable.
180
180
 
181
181
  Yields:
182
- T: The output of the Runnable.
182
+ The output of the Runnable.
183
183
  """
184
184
  sentinel = object()
185
185
  # atomic check and set
@@ -229,7 +229,7 @@ class _AstreamEventsCallbackHandler(AsyncCallbackHandler, _StreamingCallbackHand
229
229
  output: The output of the Runnable.
230
230
 
231
231
  Yields:
232
- T: The output of the Runnable.
232
+ The output of the Runnable.
233
233
  """
234
234
  sentinel = object()
235
235
  # atomic check and set
@@ -473,7 +473,7 @@ class _AstreamEventsCallbackHandler(AsyncCallbackHandler, _StreamingCallbackHand
473
473
  For both chat models and non-chat models (legacy LLMs).
474
474
 
475
475
  Raises:
476
- ValueError: If the run type is not ``'llm'`` or ``'chat_model'``.
476
+ ValueError: If the run type is not `'llm'` or `'chat_model'`.
477
477
  """
478
478
  run_info = self.run_map.pop(run_id)
479
479
  inputs_ = run_info.get("inputs")
@@ -89,7 +89,7 @@ class LangChainTracer(BaseTracer):
89
89
  project_name: The project name. Defaults to the tracer project.
90
90
  client: The client. Defaults to the global client.
91
91
  tags: The tags. Defaults to an empty list.
92
- kwargs: Additional keyword arguments.
92
+ **kwargs: Additional keyword arguments.
93
93
  """
94
94
  super().__init__(**kwargs)
95
95
  self.example_id = (
@@ -134,14 +134,14 @@ class LangChainTracer(BaseTracer):
134
134
  serialized: The serialized model.
135
135
  messages: The messages.
136
136
  run_id: The run ID.
137
- tags: The tags. Defaults to None.
138
- parent_run_id: The parent run ID. Defaults to None.
139
- metadata: The metadata. Defaults to None.
140
- name: The name. Defaults to None.
141
- kwargs: Additional keyword arguments.
137
+ tags: The tags.
138
+ parent_run_id: The parent run ID.
139
+ metadata: The metadata.
140
+ name: The name.
141
+ **kwargs: Additional keyword arguments.
142
142
 
143
143
  Returns:
144
- Run: The run.
144
+ The run.
145
145
  """
146
146
  start_time = datetime.now(timezone.utc)
147
147
  if metadata:
@@ -175,7 +175,7 @@ class LangChainTracer(BaseTracer):
175
175
  """Get the LangSmith root run URL.
176
176
 
177
177
  Returns:
178
- str: The LangSmith root run URL.
178
+ The LangSmith root run URL.
179
179
 
180
180
  Raises:
181
181
  ValueError: If no traced run is found.
@@ -111,16 +111,16 @@ class RunLogPatch:
111
111
  self.ops = list(ops)
112
112
 
113
113
  def __add__(self, other: RunLogPatch | Any) -> RunLog:
114
- """Combine two ``RunLogPatch`` instances.
114
+ """Combine two `RunLogPatch` instances.
115
115
 
116
116
  Args:
117
- other: The other ``RunLogPatch`` to combine with.
117
+ other: The other `RunLogPatch` to combine with.
118
118
 
119
119
  Raises:
120
- TypeError: If the other object is not a ``RunLogPatch``.
120
+ TypeError: If the other object is not a `RunLogPatch`.
121
121
 
122
122
  Returns:
123
- A new ``RunLog`` representing the combination of the two.
123
+ A new `RunLog` representing the combination of the two.
124
124
  """
125
125
  if type(other) is RunLogPatch:
126
126
  ops = self.ops + other.ops
@@ -159,16 +159,16 @@ class RunLog(RunLogPatch):
159
159
  self.state = state
160
160
 
161
161
  def __add__(self, other: RunLogPatch | Any) -> RunLog:
162
- """Combine two ``RunLog``s.
162
+ """Combine two `RunLog`s.
163
163
 
164
164
  Args:
165
- other: The other ``RunLog`` or ``RunLogPatch`` to combine with.
165
+ other: The other `RunLog` or `RunLogPatch` to combine with.
166
166
 
167
167
  Raises:
168
- TypeError: If the other object is not a ``RunLog`` or ``RunLogPatch``.
168
+ TypeError: If the other object is not a `RunLog` or `RunLogPatch`.
169
169
 
170
170
  Returns:
171
- A new ``RunLog`` representing the combination of the two.
171
+ A new `RunLog` representing the combination of the two.
172
172
  """
173
173
  if type(other) is RunLogPatch:
174
174
  ops = self.ops + other.ops
@@ -184,13 +184,13 @@ class RunLog(RunLogPatch):
184
184
 
185
185
  @override
186
186
  def __eq__(self, other: object) -> bool:
187
- """Check if two ``RunLog``s are equal.
187
+ """Check if two `RunLog`s are equal.
188
188
 
189
189
  Args:
190
- other: The other ``RunLog`` to compare to.
190
+ other: The other `RunLog` to compare to.
191
191
 
192
192
  Returns:
193
- True if the ``RunLog``s are equal, False otherwise.
193
+ `True` if the `RunLog`s are equal, `False` otherwise.
194
194
  """
195
195
  # First compare that the state is the same
196
196
  if not isinstance(other, RunLog):
@@ -288,8 +288,7 @@ class LogStreamCallbackHandler(BaseTracer, _StreamingCallbackHandler):
288
288
  *ops: The operations to send to the stream.
289
289
 
290
290
  Returns:
291
- bool: True if the patch was sent successfully, False if the stream
292
- is closed.
291
+ `True` if the patch was sent successfully, False if the stream is closed.
293
292
  """
294
293
  # We will likely want to wrap this in try / except at some point
295
294
  # to handle exceptions that might arise at run time.
@@ -308,7 +307,7 @@ class LogStreamCallbackHandler(BaseTracer, _StreamingCallbackHandler):
308
307
  output: The output async iterator.
309
308
 
310
309
  Yields:
311
- T: The output value.
310
+ The output value.
312
311
  """
313
312
  async for chunk in output:
314
313
  # root run is handled in .astream_log()
@@ -339,7 +338,7 @@ class LogStreamCallbackHandler(BaseTracer, _StreamingCallbackHandler):
339
338
  output: The output iterator.
340
339
 
341
340
  Yields:
342
- T: The output value.
341
+ The output value.
343
342
  """
344
343
  for chunk in output:
345
344
  # root run is handled in .astream_log()
@@ -369,7 +368,7 @@ class LogStreamCallbackHandler(BaseTracer, _StreamingCallbackHandler):
369
368
  run: The Run to check.
370
369
 
371
370
  Returns:
372
- bool: True if the run should be included, False otherwise.
371
+ `True` if the run should be included, `False` otherwise.
373
372
  """
374
373
  if run.id == self.root_id:
375
374
  return False
@@ -659,7 +658,7 @@ async def _astream_log_implementation(
659
658
  stream: The stream to send the run logs to.
660
659
  diff: Whether to yield run log patches (True) or full run logs (False).
661
660
  with_streamed_output_list: Whether to include a list of all streamed
662
- outputs in each patch. If False, only the final output will be included
661
+ outputs in each patch. If `False`, only the final output will be included
663
662
  in the patches.
664
663
  **kwargs: Additional keyword arguments to pass to the runnable.
665
664
 
@@ -667,7 +666,7 @@ async def _astream_log_implementation(
667
666
  ValueError: If the callbacks in the config are of an unexpected type.
668
667
 
669
668
  Yields:
670
- The run log patches or states, depending on the value of ``diff``.
669
+ The run log patches or states, depending on the value of `diff`.
671
670
  """
672
671
  # Assign the stream handler to the config
673
672
  config = ensure_config(config)
@@ -130,7 +130,7 @@ class _MemoryStream(Generic[T]):
130
130
  """Get a writer for the channel.
131
131
 
132
132
  Returns:
133
- _SendStream: The writer for the channel.
133
+ The writer for the channel.
134
134
  """
135
135
  return _SendStream[T](
136
136
  reader_loop=self._loop, queue=self._queue, done=self._done
@@ -140,6 +140,6 @@ class _MemoryStream(Generic[T]):
140
140
  """Get a reader for the channel.
141
141
 
142
142
  Returns:
143
- _ReceiveStream: The reader for the channel.
143
+ The reader for the channel.
144
144
  """
145
145
  return _ReceiveStream[T](queue=self._queue, done=self._done)
@@ -2,142 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import warnings
6
- from datetime import datetime, timezone
7
- from typing import Any
8
- from uuid import UUID
9
-
10
5
  from langsmith import RunTree
11
- from langsmith.schemas import RunTypeEnum as RunTypeEnumDep
12
- from pydantic import PydanticDeprecationWarning
13
- from pydantic.v1 import BaseModel as BaseModelV1
14
- from pydantic.v1 import Field as FieldV1
15
-
16
- from langchain_core._api import deprecated
17
-
18
-
19
- @deprecated("0.1.0", alternative="Use string instead.", removal="1.0")
20
- def RunTypeEnum() -> type[RunTypeEnumDep]: # noqa: N802
21
- """``RunTypeEnum``.
22
-
23
- Returns:
24
- The ``RunTypeEnum`` class.
25
- """
26
- warnings.warn(
27
- "RunTypeEnum is deprecated. Please directly use a string instead"
28
- " (e.g. 'llm', 'chain', 'tool').",
29
- DeprecationWarning,
30
- stacklevel=2,
31
- )
32
- return RunTypeEnumDep
33
-
34
-
35
- @deprecated("0.1.0", removal="1.0")
36
- class TracerSessionV1Base(BaseModelV1):
37
- """Base class for TracerSessionV1."""
38
-
39
- start_time: datetime = FieldV1(default_factory=lambda: datetime.now(timezone.utc))
40
- name: str | None = None
41
- extra: dict[str, Any] | None = None
42
-
43
-
44
- @deprecated("0.1.0", removal="1.0")
45
- class TracerSessionV1Create(TracerSessionV1Base):
46
- """Create class for TracerSessionV1."""
47
-
48
-
49
- @deprecated("0.1.0", removal="1.0")
50
- class TracerSessionV1(TracerSessionV1Base):
51
- """TracerSessionV1 schema."""
52
-
53
- id: int
54
-
55
-
56
- @deprecated("0.1.0", removal="1.0")
57
- class TracerSessionBase(TracerSessionV1Base):
58
- """Base class for TracerSession."""
59
-
60
- tenant_id: UUID
61
-
62
-
63
- @deprecated("0.1.0", removal="1.0")
64
- class TracerSession(TracerSessionBase):
65
- """TracerSessionV1 schema for the V2 API."""
66
-
67
- id: UUID
68
-
69
-
70
- @deprecated("0.1.0", alternative="Run", removal="1.0")
71
- class BaseRun(BaseModelV1):
72
- """Base class for Run."""
73
-
74
- uuid: str
75
- parent_uuid: str | None = None
76
- start_time: datetime = FieldV1(default_factory=lambda: datetime.now(timezone.utc))
77
- end_time: datetime = FieldV1(default_factory=lambda: datetime.now(timezone.utc))
78
- extra: dict[str, Any] | None = None
79
- execution_order: int
80
- child_execution_order: int
81
- serialized: dict[str, Any]
82
- session_id: int
83
- error: str | None = None
84
-
85
-
86
- @deprecated("0.1.0", alternative="Run", removal="1.0")
87
- class LLMRun(BaseRun):
88
- """Class for LLMRun."""
89
-
90
- prompts: list[str]
91
- # Temporarily, remove but we will completely remove LLMRun
92
- # response: Optional[LLMResult] = None
93
-
94
-
95
- @deprecated("0.1.0", alternative="Run", removal="1.0")
96
- class ChainRun(BaseRun):
97
- """Class for ChainRun."""
98
-
99
- inputs: dict[str, Any]
100
- outputs: dict[str, Any] | None = None
101
- child_llm_runs: list[LLMRun] = FieldV1(default_factory=list)
102
- child_chain_runs: list[ChainRun] = FieldV1(default_factory=list)
103
- child_tool_runs: list[ToolRun] = FieldV1(default_factory=list)
104
-
105
-
106
- @deprecated("0.1.0", alternative="Run", removal="1.0")
107
- class ToolRun(BaseRun):
108
- """Class for ToolRun."""
109
-
110
- tool_input: str
111
- output: str | None = None
112
- action: str
113
- child_llm_runs: list[LLMRun] = FieldV1(default_factory=list)
114
- child_chain_runs: list[ChainRun] = FieldV1(default_factory=list)
115
- child_tool_runs: list[ToolRun] = FieldV1(default_factory=list)
116
-
117
6
 
118
7
  # Begin V2 API Schemas
119
8
 
120
9
 
121
10
  Run = RunTree # For backwards compatibility
122
11
 
123
- # TODO: Update once langsmith moves to Pydantic V2 and we can swap Run.model_rebuild
124
- # for Run.update_forward_refs
125
- with warnings.catch_warnings():
126
- warnings.simplefilter("ignore", category=PydanticDeprecationWarning)
127
-
128
- ChainRun.update_forward_refs()
129
- ToolRun.update_forward_refs()
130
-
131
12
  __all__ = [
132
- "BaseRun",
133
- "ChainRun",
134
- "LLMRun",
135
13
  "Run",
136
- "RunTypeEnum",
137
- "ToolRun",
138
- "TracerSession",
139
- "TracerSessionBase",
140
- "TracerSessionV1",
141
- "TracerSessionV1Base",
142
- "TracerSessionV1Create",
143
14
  ]