langchain-core 1.0.0a5__py3-none-any.whl → 1.0.3__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.
- langchain_core/__init__.py +1 -1
- langchain_core/_api/__init__.py +3 -4
- langchain_core/_api/beta_decorator.py +23 -26
- langchain_core/_api/deprecation.py +51 -64
- langchain_core/_api/path.py +3 -6
- langchain_core/_import_utils.py +3 -4
- langchain_core/agents.py +20 -22
- langchain_core/caches.py +65 -66
- langchain_core/callbacks/__init__.py +1 -8
- langchain_core/callbacks/base.py +321 -336
- langchain_core/callbacks/file.py +44 -44
- langchain_core/callbacks/manager.py +436 -513
- langchain_core/callbacks/stdout.py +29 -30
- langchain_core/callbacks/streaming_stdout.py +32 -32
- langchain_core/callbacks/usage.py +60 -57
- langchain_core/chat_history.py +53 -68
- langchain_core/document_loaders/base.py +27 -25
- langchain_core/document_loaders/blob_loaders.py +1 -1
- langchain_core/document_loaders/langsmith.py +44 -48
- langchain_core/documents/__init__.py +23 -3
- langchain_core/documents/base.py +98 -90
- langchain_core/documents/compressor.py +10 -10
- langchain_core/documents/transformers.py +34 -35
- langchain_core/embeddings/fake.py +50 -54
- langchain_core/example_selectors/length_based.py +1 -1
- langchain_core/example_selectors/semantic_similarity.py +28 -32
- langchain_core/exceptions.py +21 -20
- langchain_core/globals.py +3 -151
- langchain_core/indexing/__init__.py +1 -1
- langchain_core/indexing/api.py +121 -126
- langchain_core/indexing/base.py +73 -75
- langchain_core/indexing/in_memory.py +4 -6
- langchain_core/language_models/__init__.py +14 -29
- langchain_core/language_models/_utils.py +58 -61
- langchain_core/language_models/base.py +53 -162
- langchain_core/language_models/chat_models.py +298 -387
- langchain_core/language_models/fake.py +11 -11
- langchain_core/language_models/fake_chat_models.py +42 -36
- langchain_core/language_models/llms.py +125 -235
- langchain_core/load/dump.py +9 -12
- langchain_core/load/load.py +18 -28
- langchain_core/load/mapping.py +2 -4
- langchain_core/load/serializable.py +42 -40
- langchain_core/messages/__init__.py +10 -16
- langchain_core/messages/ai.py +148 -148
- langchain_core/messages/base.py +58 -52
- langchain_core/messages/block_translators/__init__.py +27 -17
- langchain_core/messages/block_translators/anthropic.py +6 -6
- langchain_core/messages/block_translators/bedrock_converse.py +5 -5
- langchain_core/messages/block_translators/google_genai.py +505 -20
- langchain_core/messages/block_translators/google_vertexai.py +4 -32
- langchain_core/messages/block_translators/groq.py +117 -21
- langchain_core/messages/block_translators/langchain_v0.py +5 -5
- langchain_core/messages/block_translators/openai.py +11 -11
- langchain_core/messages/chat.py +2 -6
- langchain_core/messages/content.py +337 -328
- langchain_core/messages/function.py +6 -10
- langchain_core/messages/human.py +24 -31
- langchain_core/messages/modifier.py +2 -2
- langchain_core/messages/system.py +19 -29
- langchain_core/messages/tool.py +74 -90
- langchain_core/messages/utils.py +474 -504
- langchain_core/output_parsers/__init__.py +13 -10
- langchain_core/output_parsers/base.py +61 -61
- langchain_core/output_parsers/format_instructions.py +9 -4
- langchain_core/output_parsers/json.py +12 -10
- langchain_core/output_parsers/list.py +21 -23
- langchain_core/output_parsers/openai_functions.py +49 -47
- langchain_core/output_parsers/openai_tools.py +16 -21
- langchain_core/output_parsers/pydantic.py +13 -14
- langchain_core/output_parsers/string.py +5 -5
- langchain_core/output_parsers/transform.py +15 -17
- langchain_core/output_parsers/xml.py +35 -34
- langchain_core/outputs/__init__.py +1 -1
- langchain_core/outputs/chat_generation.py +18 -18
- langchain_core/outputs/chat_result.py +1 -3
- langchain_core/outputs/generation.py +10 -11
- langchain_core/outputs/llm_result.py +10 -10
- langchain_core/prompt_values.py +11 -17
- langchain_core/prompts/__init__.py +3 -27
- langchain_core/prompts/base.py +48 -56
- langchain_core/prompts/chat.py +275 -325
- langchain_core/prompts/dict.py +5 -5
- langchain_core/prompts/few_shot.py +81 -88
- langchain_core/prompts/few_shot_with_templates.py +11 -13
- langchain_core/prompts/image.py +12 -14
- langchain_core/prompts/loading.py +4 -6
- langchain_core/prompts/message.py +3 -3
- langchain_core/prompts/prompt.py +24 -39
- langchain_core/prompts/string.py +26 -10
- langchain_core/prompts/structured.py +49 -53
- langchain_core/rate_limiters.py +51 -60
- langchain_core/retrievers.py +61 -198
- langchain_core/runnables/base.py +1478 -1630
- langchain_core/runnables/branch.py +53 -57
- langchain_core/runnables/config.py +72 -89
- langchain_core/runnables/configurable.py +120 -137
- langchain_core/runnables/fallbacks.py +83 -79
- langchain_core/runnables/graph.py +91 -97
- langchain_core/runnables/graph_ascii.py +27 -28
- langchain_core/runnables/graph_mermaid.py +38 -50
- langchain_core/runnables/graph_png.py +15 -16
- langchain_core/runnables/history.py +135 -148
- langchain_core/runnables/passthrough.py +124 -150
- langchain_core/runnables/retry.py +46 -51
- langchain_core/runnables/router.py +25 -30
- langchain_core/runnables/schema.py +75 -80
- langchain_core/runnables/utils.py +60 -67
- langchain_core/stores.py +85 -121
- langchain_core/structured_query.py +8 -8
- langchain_core/sys_info.py +27 -29
- langchain_core/tools/__init__.py +1 -14
- langchain_core/tools/base.py +285 -229
- langchain_core/tools/convert.py +160 -155
- langchain_core/tools/render.py +10 -10
- langchain_core/tools/retriever.py +12 -11
- langchain_core/tools/simple.py +19 -24
- langchain_core/tools/structured.py +32 -39
- langchain_core/tracers/__init__.py +1 -9
- langchain_core/tracers/base.py +97 -99
- langchain_core/tracers/context.py +29 -52
- langchain_core/tracers/core.py +49 -53
- langchain_core/tracers/evaluation.py +11 -11
- langchain_core/tracers/event_stream.py +65 -64
- langchain_core/tracers/langchain.py +21 -21
- langchain_core/tracers/log_stream.py +45 -45
- langchain_core/tracers/memory_stream.py +3 -3
- langchain_core/tracers/root_listeners.py +16 -16
- langchain_core/tracers/run_collector.py +2 -4
- langchain_core/tracers/schemas.py +0 -129
- langchain_core/tracers/stdout.py +3 -3
- langchain_core/utils/__init__.py +1 -4
- langchain_core/utils/_merge.py +2 -2
- langchain_core/utils/aiter.py +57 -61
- langchain_core/utils/env.py +9 -9
- langchain_core/utils/function_calling.py +89 -186
- langchain_core/utils/html.py +7 -8
- langchain_core/utils/input.py +6 -6
- langchain_core/utils/interactive_env.py +1 -1
- langchain_core/utils/iter.py +36 -40
- langchain_core/utils/json.py +4 -3
- langchain_core/utils/json_schema.py +9 -9
- langchain_core/utils/mustache.py +8 -10
- langchain_core/utils/pydantic.py +33 -35
- langchain_core/utils/strings.py +6 -9
- langchain_core/utils/usage.py +1 -1
- langchain_core/utils/utils.py +66 -62
- langchain_core/vectorstores/base.py +182 -216
- langchain_core/vectorstores/in_memory.py +101 -176
- langchain_core/vectorstores/utils.py +5 -5
- langchain_core/version.py +1 -1
- langchain_core-1.0.3.dist-info/METADATA +69 -0
- langchain_core-1.0.3.dist-info/RECORD +172 -0
- {langchain_core-1.0.0a5.dist-info → langchain_core-1.0.3.dist-info}/WHEEL +1 -1
- langchain_core/memory.py +0 -120
- langchain_core/messages/block_translators/ollama.py +0 -47
- langchain_core/prompts/pipeline.py +0 -138
- langchain_core/pydantic_v1/__init__.py +0 -30
- langchain_core/pydantic_v1/dataclasses.py +0 -23
- langchain_core/pydantic_v1/main.py +0 -23
- langchain_core/tracers/langchain_v1.py +0 -31
- langchain_core/utils/loading.py +0 -35
- langchain_core-1.0.0a5.dist-info/METADATA +0 -77
- langchain_core-1.0.0a5.dist-info/RECORD +0 -181
- langchain_core-1.0.0a5.dist-info/entry_points.txt +0 -4
langchain_core/utils/utils.py
CHANGED
|
@@ -6,9 +6,9 @@ import functools
|
|
|
6
6
|
import importlib
|
|
7
7
|
import os
|
|
8
8
|
import warnings
|
|
9
|
-
from collections.abc import Iterator, Sequence
|
|
9
|
+
from collections.abc import Callable, Iterator, Sequence
|
|
10
10
|
from importlib.metadata import version
|
|
11
|
-
from typing import Any,
|
|
11
|
+
from typing import Any, overload
|
|
12
12
|
from uuid import uuid4
|
|
13
13
|
|
|
14
14
|
from packaging.version import parse
|
|
@@ -25,11 +25,11 @@ def xor_args(*arg_groups: tuple[str, ...]) -> Callable:
|
|
|
25
25
|
"""Validate specified keyword args are mutually exclusive.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
*arg_groups
|
|
28
|
+
*arg_groups: Groups of mutually exclusive keyword args.
|
|
29
29
|
|
|
30
30
|
Returns:
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Decorator that validates the specified keyword args
|
|
32
|
+
are mutually exclusive.
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
35
|
def decorator(func: Callable) -> Callable:
|
|
@@ -60,7 +60,7 @@ def raise_for_status_with_text(response: Response) -> None:
|
|
|
60
60
|
"""Raise an error with the response text.
|
|
61
61
|
|
|
62
62
|
Args:
|
|
63
|
-
response
|
|
63
|
+
response: The response to check for errors.
|
|
64
64
|
|
|
65
65
|
Raises:
|
|
66
66
|
ValueError: If the response has an error status code.
|
|
@@ -79,11 +79,13 @@ def mock_now(dt_value: datetime.datetime) -> Iterator[type]:
|
|
|
79
79
|
dt_value: The datetime value to use for datetime.now().
|
|
80
80
|
|
|
81
81
|
Yields:
|
|
82
|
-
|
|
82
|
+
The mocked datetime class.
|
|
83
83
|
|
|
84
84
|
Example:
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
```python
|
|
86
|
+
with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):
|
|
87
|
+
assert datetime.datetime.now() == datetime.datetime(2011, 2, 3, 10, 11)
|
|
88
|
+
```
|
|
87
89
|
"""
|
|
88
90
|
|
|
89
91
|
class MockDateTime(datetime.datetime):
|
|
@@ -91,7 +93,7 @@ def mock_now(dt_value: datetime.datetime) -> Iterator[type]:
|
|
|
91
93
|
|
|
92
94
|
@classmethod
|
|
93
95
|
@override
|
|
94
|
-
def now(cls, tz:
|
|
96
|
+
def now(cls, tz: datetime.tzinfo | None = None) -> "MockDateTime":
|
|
95
97
|
# Create a copy of dt_value.
|
|
96
98
|
return MockDateTime(
|
|
97
99
|
dt_value.year,
|
|
@@ -113,21 +115,19 @@ def mock_now(dt_value: datetime.datetime) -> Iterator[type]:
|
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
def guard_import(
|
|
116
|
-
module_name: str, *, pip_name:
|
|
118
|
+
module_name: str, *, pip_name: str | None = None, package: str | None = None
|
|
117
119
|
) -> Any:
|
|
118
120
|
"""Dynamically import a module.
|
|
119
121
|
|
|
120
122
|
Raise an exception if the module is not installed.
|
|
121
123
|
|
|
122
124
|
Args:
|
|
123
|
-
module_name
|
|
124
|
-
pip_name
|
|
125
|
-
|
|
126
|
-
package (str, optional): The package to import the module from.
|
|
127
|
-
Defaults to None.
|
|
125
|
+
module_name: The name of the module to import.
|
|
126
|
+
pip_name: The name of the module to install with pip.
|
|
127
|
+
package: The package to import the module from.
|
|
128
128
|
|
|
129
129
|
Returns:
|
|
130
|
-
|
|
130
|
+
The imported module.
|
|
131
131
|
|
|
132
132
|
Raises:
|
|
133
133
|
ImportError: If the module is not installed.
|
|
@@ -146,23 +146,20 @@ def guard_import(
|
|
|
146
146
|
|
|
147
147
|
def check_package_version(
|
|
148
148
|
package: str,
|
|
149
|
-
lt_version:
|
|
150
|
-
lte_version:
|
|
151
|
-
gt_version:
|
|
152
|
-
gte_version:
|
|
149
|
+
lt_version: str | None = None,
|
|
150
|
+
lte_version: str | None = None,
|
|
151
|
+
gt_version: str | None = None,
|
|
152
|
+
gte_version: str | None = None,
|
|
153
153
|
) -> None:
|
|
154
154
|
"""Check the version of a package.
|
|
155
155
|
|
|
156
156
|
Args:
|
|
157
|
-
package
|
|
158
|
-
lt_version
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
Defaults to None.
|
|
164
|
-
gte_version (str, optional): The version must be greater than or equal to this.
|
|
165
|
-
Defaults to None.
|
|
157
|
+
package: The name of the package.
|
|
158
|
+
lt_version: The version must be less than this.
|
|
159
|
+
lte_version: The version must be less than or equal to this.
|
|
160
|
+
gt_version: The version must be greater than this.
|
|
161
|
+
gte_version: The version must be greater than or equal to this.
|
|
162
|
+
|
|
166
163
|
|
|
167
164
|
Raises:
|
|
168
165
|
ValueError: If the package version does not meet the requirements.
|
|
@@ -201,7 +198,7 @@ def get_pydantic_field_names(pydantic_cls: Any) -> set[str]:
|
|
|
201
198
|
pydantic_cls: Pydantic class.
|
|
202
199
|
|
|
203
200
|
Returns:
|
|
204
|
-
|
|
201
|
+
Field names.
|
|
205
202
|
"""
|
|
206
203
|
all_required_field_names = set()
|
|
207
204
|
if is_pydantic_v1_subclass(pydantic_cls):
|
|
@@ -221,18 +218,18 @@ def _build_model_kwargs(
|
|
|
221
218
|
values: dict[str, Any],
|
|
222
219
|
all_required_field_names: set[str],
|
|
223
220
|
) -> dict[str, Any]:
|
|
224
|
-
"""Build
|
|
221
|
+
"""Build `model_kwargs` param from Pydantic constructor values.
|
|
225
222
|
|
|
226
223
|
Args:
|
|
227
224
|
values: All init args passed in by user.
|
|
228
225
|
all_required_field_names: All required field names for the pydantic class.
|
|
229
226
|
|
|
230
227
|
Returns:
|
|
231
|
-
|
|
228
|
+
Extra kwargs.
|
|
232
229
|
|
|
233
230
|
Raises:
|
|
234
|
-
ValueError: If a field is specified in both values and extra_kwargs
|
|
235
|
-
ValueError: If a field is specified in model_kwargs
|
|
231
|
+
ValueError: If a field is specified in both `values` and `extra_kwargs`.
|
|
232
|
+
ValueError: If a field is specified in `model_kwargs`.
|
|
236
233
|
"""
|
|
237
234
|
extra_kwargs = values.get("model_kwargs", {})
|
|
238
235
|
for field_name in list(values):
|
|
@@ -270,18 +267,23 @@ def build_extra_kwargs(
|
|
|
270
267
|
) -> dict[str, Any]:
|
|
271
268
|
"""Build extra kwargs from values and extra_kwargs.
|
|
272
269
|
|
|
270
|
+
!!! danger "DON'T USE"
|
|
271
|
+
Kept for backwards-compatibility but should never have been public. Use the
|
|
272
|
+
internal `_build_model_kwargs` function instead.
|
|
273
|
+
|
|
273
274
|
Args:
|
|
274
275
|
extra_kwargs: Extra kwargs passed in by user.
|
|
275
276
|
values: Values passed in by user.
|
|
276
277
|
all_required_field_names: All required field names for the pydantic class.
|
|
277
278
|
|
|
278
279
|
Returns:
|
|
279
|
-
|
|
280
|
+
Extra kwargs.
|
|
280
281
|
|
|
281
282
|
Raises:
|
|
282
|
-
ValueError: If a field is specified in both values and extra_kwargs
|
|
283
|
-
ValueError: If a field is specified in model_kwargs
|
|
283
|
+
ValueError: If a field is specified in both `values` and `extra_kwargs`.
|
|
284
|
+
ValueError: If a field is specified in `model_kwargs`.
|
|
284
285
|
"""
|
|
286
|
+
# DON'T USE! Kept for backwards-compatibility but should never have been public.
|
|
285
287
|
for field_name in list(values):
|
|
286
288
|
if field_name in extra_kwargs:
|
|
287
289
|
msg = f"Found {field_name} supplied twice."
|
|
@@ -295,6 +297,7 @@ def build_extra_kwargs(
|
|
|
295
297
|
)
|
|
296
298
|
extra_kwargs[field_name] = values.pop(field_name)
|
|
297
299
|
|
|
300
|
+
# DON'T USE! Kept for backwards-compatibility but should never have been public.
|
|
298
301
|
invalid_model_kwargs = all_required_field_names.intersection(extra_kwargs.keys())
|
|
299
302
|
if invalid_model_kwargs:
|
|
300
303
|
msg = (
|
|
@@ -303,17 +306,18 @@ def build_extra_kwargs(
|
|
|
303
306
|
)
|
|
304
307
|
raise ValueError(msg)
|
|
305
308
|
|
|
309
|
+
# DON'T USE! Kept for backwards-compatibility but should never have been public.
|
|
306
310
|
return extra_kwargs
|
|
307
311
|
|
|
308
312
|
|
|
309
|
-
def convert_to_secret_str(value:
|
|
313
|
+
def convert_to_secret_str(value: SecretStr | str) -> SecretStr:
|
|
310
314
|
"""Convert a string to a SecretStr if needed.
|
|
311
315
|
|
|
312
316
|
Args:
|
|
313
|
-
value
|
|
317
|
+
value: The value to convert.
|
|
314
318
|
|
|
315
319
|
Returns:
|
|
316
|
-
|
|
320
|
+
The SecretStr value.
|
|
317
321
|
"""
|
|
318
322
|
if isinstance(value, SecretStr):
|
|
319
323
|
return value
|
|
@@ -345,29 +349,29 @@ def from_env(key: str, /, *, error_message: str) -> Callable[[], str]: ...
|
|
|
345
349
|
|
|
346
350
|
@overload
|
|
347
351
|
def from_env(
|
|
348
|
-
key:
|
|
352
|
+
key: str | Sequence[str], /, *, default: str, error_message: str | None
|
|
349
353
|
) -> Callable[[], str]: ...
|
|
350
354
|
|
|
351
355
|
|
|
352
356
|
@overload
|
|
353
357
|
def from_env(
|
|
354
|
-
key: str, /, *, default: None, error_message:
|
|
355
|
-
) -> Callable[[],
|
|
358
|
+
key: str, /, *, default: None, error_message: str | None
|
|
359
|
+
) -> Callable[[], str | None]: ...
|
|
356
360
|
|
|
357
361
|
|
|
358
362
|
@overload
|
|
359
363
|
def from_env(
|
|
360
|
-
key:
|
|
361
|
-
) -> Callable[[],
|
|
364
|
+
key: str | Sequence[str], /, *, default: None
|
|
365
|
+
) -> Callable[[], str | None]: ...
|
|
362
366
|
|
|
363
367
|
|
|
364
368
|
def from_env(
|
|
365
|
-
key:
|
|
369
|
+
key: str | Sequence[str],
|
|
366
370
|
/,
|
|
367
371
|
*,
|
|
368
|
-
default:
|
|
369
|
-
error_message:
|
|
370
|
-
) ->
|
|
372
|
+
default: str | _NoDefaultType | None = _NoDefault,
|
|
373
|
+
error_message: str | None = None,
|
|
374
|
+
) -> Callable[[], str] | Callable[[], str | None]:
|
|
371
375
|
"""Create a factory method that gets a value from an environment variable.
|
|
372
376
|
|
|
373
377
|
Args:
|
|
@@ -384,7 +388,7 @@ def from_env(
|
|
|
384
388
|
factory method that will look up the value from the environment.
|
|
385
389
|
"""
|
|
386
390
|
|
|
387
|
-
def get_from_env_fn() ->
|
|
391
|
+
def get_from_env_fn() -> str | None:
|
|
388
392
|
"""Get a value from an environment variable.
|
|
389
393
|
|
|
390
394
|
Raises:
|
|
@@ -416,7 +420,7 @@ def from_env(
|
|
|
416
420
|
|
|
417
421
|
|
|
418
422
|
@overload
|
|
419
|
-
def secret_from_env(key:
|
|
423
|
+
def secret_from_env(key: str | Sequence[str], /) -> Callable[[], SecretStr]: ...
|
|
420
424
|
|
|
421
425
|
|
|
422
426
|
@overload
|
|
@@ -425,8 +429,8 @@ def secret_from_env(key: str, /, *, default: str) -> Callable[[], SecretStr]: ..
|
|
|
425
429
|
|
|
426
430
|
@overload
|
|
427
431
|
def secret_from_env(
|
|
428
|
-
key:
|
|
429
|
-
) -> Callable[[],
|
|
432
|
+
key: str | Sequence[str], /, *, default: None
|
|
433
|
+
) -> Callable[[], SecretStr | None]: ...
|
|
430
434
|
|
|
431
435
|
|
|
432
436
|
@overload
|
|
@@ -434,12 +438,12 @@ def secret_from_env(key: str, /, *, error_message: str) -> Callable[[], SecretSt
|
|
|
434
438
|
|
|
435
439
|
|
|
436
440
|
def secret_from_env(
|
|
437
|
-
key:
|
|
441
|
+
key: str | Sequence[str],
|
|
438
442
|
/,
|
|
439
443
|
*,
|
|
440
|
-
default:
|
|
441
|
-
error_message:
|
|
442
|
-
) ->
|
|
444
|
+
default: str | _NoDefaultType | None = _NoDefault,
|
|
445
|
+
error_message: str | None = None,
|
|
446
|
+
) -> Callable[[], SecretStr | None] | Callable[[], SecretStr]:
|
|
443
447
|
"""Secret from env.
|
|
444
448
|
|
|
445
449
|
Args:
|
|
@@ -453,7 +457,7 @@ def secret_from_env(
|
|
|
453
457
|
factory method that will look up the secret from the environment.
|
|
454
458
|
"""
|
|
455
459
|
|
|
456
|
-
def get_secret_from_env() ->
|
|
460
|
+
def get_secret_from_env() -> SecretStr | None:
|
|
457
461
|
"""Get a value from an environment variable.
|
|
458
462
|
|
|
459
463
|
Raises:
|
|
@@ -498,10 +502,10 @@ Used for:
|
|
|
498
502
|
"""
|
|
499
503
|
|
|
500
504
|
|
|
501
|
-
def ensure_id(id_val:
|
|
505
|
+
def ensure_id(id_val: str | None) -> str:
|
|
502
506
|
"""Ensure the ID is a valid string, generating a new UUID if not provided.
|
|
503
507
|
|
|
504
|
-
Auto-generated UUIDs are prefixed by
|
|
508
|
+
Auto-generated UUIDs are prefixed by `'lc_'` to indicate they are
|
|
505
509
|
LangChain-generated IDs.
|
|
506
510
|
|
|
507
511
|
Args:
|
|
@@ -510,4 +514,4 @@ def ensure_id(id_val: Optional[str]) -> str:
|
|
|
510
514
|
Returns:
|
|
511
515
|
A string ID, either the validated provided value or a newly generated UUID4.
|
|
512
516
|
"""
|
|
513
|
-
return id_val or
|
|
517
|
+
return id_val or f"{LC_AUTO_PREFIX}{uuid4()}"
|