langchain-core 1.0.0a8__py3-none-any.whl → 1.0.0rc2__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.
- langchain_core/__init__.py +1 -1
- langchain_core/_api/__init__.py +0 -1
- langchain_core/_api/beta_decorator.py +17 -20
- langchain_core/_api/deprecation.py +30 -35
- langchain_core/_import_utils.py +1 -1
- langchain_core/agents.py +10 -9
- langchain_core/caches.py +46 -56
- langchain_core/callbacks/__init__.py +1 -8
- langchain_core/callbacks/base.py +232 -243
- langchain_core/callbacks/file.py +33 -33
- langchain_core/callbacks/manager.py +353 -416
- langchain_core/callbacks/stdout.py +21 -22
- langchain_core/callbacks/streaming_stdout.py +32 -32
- langchain_core/callbacks/usage.py +54 -51
- langchain_core/chat_history.py +43 -58
- langchain_core/document_loaders/base.py +21 -21
- langchain_core/document_loaders/langsmith.py +22 -22
- langchain_core/documents/__init__.py +0 -1
- langchain_core/documents/base.py +46 -49
- langchain_core/documents/transformers.py +28 -29
- langchain_core/embeddings/fake.py +50 -54
- langchain_core/example_selectors/semantic_similarity.py +4 -6
- langchain_core/exceptions.py +7 -8
- langchain_core/indexing/api.py +19 -25
- langchain_core/indexing/base.py +24 -24
- langchain_core/language_models/__init__.py +11 -27
- langchain_core/language_models/_utils.py +53 -54
- langchain_core/language_models/base.py +30 -24
- langchain_core/language_models/chat_models.py +123 -148
- langchain_core/language_models/fake_chat_models.py +7 -7
- langchain_core/language_models/llms.py +14 -16
- langchain_core/load/dump.py +3 -4
- langchain_core/load/load.py +7 -16
- langchain_core/load/serializable.py +37 -36
- langchain_core/messages/__init__.py +1 -16
- langchain_core/messages/ai.py +122 -123
- langchain_core/messages/base.py +31 -31
- langchain_core/messages/block_translators/__init__.py +17 -17
- langchain_core/messages/block_translators/anthropic.py +3 -3
- langchain_core/messages/block_translators/bedrock_converse.py +3 -3
- langchain_core/messages/block_translators/google_genai.py +5 -4
- 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 +3 -3
- langchain_core/messages/block_translators/openai.py +5 -5
- langchain_core/messages/chat.py +2 -6
- langchain_core/messages/content.py +222 -209
- langchain_core/messages/function.py +6 -10
- langchain_core/messages/human.py +17 -24
- langchain_core/messages/modifier.py +2 -2
- langchain_core/messages/system.py +12 -22
- langchain_core/messages/tool.py +53 -69
- langchain_core/messages/utils.py +399 -417
- langchain_core/output_parsers/__init__.py +1 -14
- langchain_core/output_parsers/base.py +46 -47
- langchain_core/output_parsers/json.py +3 -4
- langchain_core/output_parsers/list.py +2 -2
- langchain_core/output_parsers/openai_functions.py +46 -44
- langchain_core/output_parsers/openai_tools.py +11 -16
- langchain_core/output_parsers/pydantic.py +10 -11
- langchain_core/output_parsers/string.py +2 -2
- langchain_core/output_parsers/transform.py +2 -2
- langchain_core/output_parsers/xml.py +1 -1
- langchain_core/outputs/__init__.py +1 -1
- langchain_core/outputs/chat_generation.py +14 -14
- langchain_core/outputs/generation.py +6 -6
- langchain_core/outputs/llm_result.py +5 -5
- langchain_core/prompt_values.py +11 -11
- langchain_core/prompts/__init__.py +3 -23
- langchain_core/prompts/base.py +33 -38
- langchain_core/prompts/chat.py +222 -229
- langchain_core/prompts/dict.py +3 -3
- langchain_core/prompts/few_shot.py +76 -83
- langchain_core/prompts/few_shot_with_templates.py +7 -9
- langchain_core/prompts/image.py +12 -14
- langchain_core/prompts/loading.py +1 -1
- langchain_core/prompts/message.py +3 -3
- langchain_core/prompts/prompt.py +20 -23
- langchain_core/prompts/string.py +20 -8
- langchain_core/prompts/structured.py +26 -27
- langchain_core/rate_limiters.py +50 -58
- langchain_core/retrievers.py +41 -182
- langchain_core/runnables/base.py +565 -597
- langchain_core/runnables/branch.py +8 -8
- langchain_core/runnables/config.py +37 -44
- langchain_core/runnables/configurable.py +9 -10
- langchain_core/runnables/fallbacks.py +9 -9
- langchain_core/runnables/graph.py +46 -50
- langchain_core/runnables/graph_ascii.py +19 -18
- langchain_core/runnables/graph_mermaid.py +20 -31
- langchain_core/runnables/graph_png.py +7 -7
- langchain_core/runnables/history.py +22 -22
- langchain_core/runnables/passthrough.py +11 -11
- langchain_core/runnables/retry.py +3 -3
- langchain_core/runnables/router.py +2 -2
- langchain_core/runnables/schema.py +33 -33
- langchain_core/runnables/utils.py +30 -34
- langchain_core/stores.py +72 -102
- langchain_core/sys_info.py +27 -29
- langchain_core/tools/__init__.py +1 -14
- langchain_core/tools/base.py +70 -71
- langchain_core/tools/convert.py +100 -104
- langchain_core/tools/render.py +9 -9
- langchain_core/tools/retriever.py +7 -7
- langchain_core/tools/simple.py +6 -7
- langchain_core/tools/structured.py +18 -24
- langchain_core/tracers/__init__.py +1 -9
- langchain_core/tracers/base.py +35 -35
- langchain_core/tracers/context.py +12 -17
- langchain_core/tracers/event_stream.py +3 -3
- langchain_core/tracers/langchain.py +8 -8
- langchain_core/tracers/log_stream.py +17 -18
- langchain_core/tracers/memory_stream.py +3 -3
- langchain_core/tracers/root_listeners.py +2 -2
- langchain_core/tracers/schemas.py +0 -129
- langchain_core/tracers/stdout.py +1 -2
- langchain_core/utils/__init__.py +1 -1
- langchain_core/utils/aiter.py +32 -32
- langchain_core/utils/env.py +5 -5
- langchain_core/utils/function_calling.py +59 -154
- langchain_core/utils/html.py +4 -4
- langchain_core/utils/input.py +3 -3
- langchain_core/utils/interactive_env.py +1 -1
- langchain_core/utils/iter.py +20 -20
- langchain_core/utils/json.py +1 -1
- langchain_core/utils/json_schema.py +2 -2
- langchain_core/utils/mustache.py +5 -5
- langchain_core/utils/pydantic.py +17 -17
- langchain_core/utils/strings.py +5 -5
- langchain_core/utils/utils.py +25 -28
- langchain_core/vectorstores/base.py +55 -87
- langchain_core/vectorstores/in_memory.py +83 -85
- langchain_core/vectorstores/utils.py +2 -2
- langchain_core/version.py +1 -1
- {langchain_core-1.0.0a8.dist-info → langchain_core-1.0.0rc2.dist-info}/METADATA +23 -11
- langchain_core-1.0.0rc2.dist-info/RECORD +172 -0
- langchain_core/memory.py +0 -120
- 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-1.0.0a8.dist-info/RECORD +0 -176
- {langchain_core-1.0.0a8.dist-info → langchain_core-1.0.0rc2.dist-info}/WHEEL +0 -0
langchain_core/utils/json.py
CHANGED
|
@@ -51,7 +51,7 @@ def parse_partial_json(s: str, *, strict: bool = False) -> Any:
|
|
|
51
51
|
|
|
52
52
|
Args:
|
|
53
53
|
s: The JSON string to parse.
|
|
54
|
-
strict: Whether to use strict parsing.
|
|
54
|
+
strict: Whether to use strict parsing.
|
|
55
55
|
|
|
56
56
|
Returns:
|
|
57
57
|
The parsed JSON object as a Python dictionary.
|
|
@@ -85,7 +85,7 @@ def _dereference_refs_helper(
|
|
|
85
85
|
full_schema: The complete schema containing all definitions
|
|
86
86
|
processed_refs: Set tracking currently processing refs (for cycle detection)
|
|
87
87
|
skip_keys: Keys under which to skip recursion
|
|
88
|
-
shallow_refs: If True
|
|
88
|
+
shallow_refs: If `True`, only break cycles; if False, deep-inline all refs
|
|
89
89
|
|
|
90
90
|
Returns:
|
|
91
91
|
The object with $ref properties resolved and merged with other properties.
|
|
@@ -184,7 +184,7 @@ def dereference_refs(
|
|
|
184
184
|
point to. If not provided, defaults to schema_obj (useful when the
|
|
185
185
|
schema is self-contained).
|
|
186
186
|
skip_keys: Controls recursion behavior and reference resolution depth:
|
|
187
|
-
- If None (
|
|
187
|
+
- If `None` (Default): Only recurse under '$defs' and use shallow reference
|
|
188
188
|
resolution (break cycles but don't deep-inline nested refs)
|
|
189
189
|
- If provided (even as []): Recurse under all keys and use deep reference
|
|
190
190
|
resolution (fully inline all nested references)
|
langchain_core/utils/mustache.py
CHANGED
|
@@ -46,7 +46,7 @@ def grab_literal(template: str, l_del: str) -> tuple[str, str]:
|
|
|
46
46
|
l_del: The left delimiter.
|
|
47
47
|
|
|
48
48
|
Returns:
|
|
49
|
-
|
|
49
|
+
The literal and the template.
|
|
50
50
|
"""
|
|
51
51
|
global _CURRENT_LINE
|
|
52
52
|
|
|
@@ -76,7 +76,7 @@ def l_sa_check(
|
|
|
76
76
|
is_standalone: Whether the tag is standalone.
|
|
77
77
|
|
|
78
78
|
Returns:
|
|
79
|
-
|
|
79
|
+
Whether the tag could be a standalone.
|
|
80
80
|
"""
|
|
81
81
|
# If there is a newline, or the previous tag was a standalone
|
|
82
82
|
if literal.find("\n") != -1 or is_standalone:
|
|
@@ -102,7 +102,7 @@ def r_sa_check(
|
|
|
102
102
|
is_standalone: Whether the tag is standalone.
|
|
103
103
|
|
|
104
104
|
Returns:
|
|
105
|
-
|
|
105
|
+
Whether the tag could be a standalone.
|
|
106
106
|
"""
|
|
107
107
|
# Check right side if we might be a standalone
|
|
108
108
|
if is_standalone and tag_type not in {"variable", "no escape"}:
|
|
@@ -124,7 +124,7 @@ def parse_tag(template: str, l_del: str, r_del: str) -> tuple[tuple[str, str], s
|
|
|
124
124
|
r_del: The right delimiter.
|
|
125
125
|
|
|
126
126
|
Returns:
|
|
127
|
-
|
|
127
|
+
The tag and the template.
|
|
128
128
|
|
|
129
129
|
Raises:
|
|
130
130
|
ChevronError: If the tag is unclosed.
|
|
@@ -329,7 +329,7 @@ def tokenize(
|
|
|
329
329
|
|
|
330
330
|
|
|
331
331
|
def _html_escape(string: str) -> str:
|
|
332
|
-
"""Return the HTML-escaped string with these characters escaped:
|
|
332
|
+
"""Return the HTML-escaped string with these characters escaped: `" & < >`."""
|
|
333
333
|
html_codes = {
|
|
334
334
|
'"': """,
|
|
335
335
|
"<": "<",
|
langchain_core/utils/pydantic.py
CHANGED
|
@@ -78,7 +78,7 @@ def is_pydantic_v1_subclass(cls: type) -> bool:
|
|
|
78
78
|
"""Check if the given class is Pydantic v1-like.
|
|
79
79
|
|
|
80
80
|
Returns:
|
|
81
|
-
True if the given class is a subclass of Pydantic
|
|
81
|
+
`True` if the given class is a subclass of Pydantic `BaseModel` 1.x.
|
|
82
82
|
"""
|
|
83
83
|
return issubclass(cls, BaseModelV1)
|
|
84
84
|
|
|
@@ -87,7 +87,7 @@ def is_pydantic_v2_subclass(cls: type) -> bool:
|
|
|
87
87
|
"""Check if the given class is Pydantic v2-like.
|
|
88
88
|
|
|
89
89
|
Returns:
|
|
90
|
-
True if the given class is a subclass of Pydantic BaseModel 2.x.
|
|
90
|
+
`True` if the given class is a subclass of Pydantic BaseModel 2.x.
|
|
91
91
|
"""
|
|
92
92
|
return issubclass(cls, BaseModel)
|
|
93
93
|
|
|
@@ -101,7 +101,7 @@ def is_basemodel_subclass(cls: type) -> bool:
|
|
|
101
101
|
* pydantic.v1.BaseModel in Pydantic 2.x
|
|
102
102
|
|
|
103
103
|
Returns:
|
|
104
|
-
True if the given class is a subclass of Pydantic
|
|
104
|
+
`True` if the given class is a subclass of Pydantic `BaseModel`.
|
|
105
105
|
"""
|
|
106
106
|
# Before we can use issubclass on the cls we need to check if it is a class
|
|
107
107
|
if not inspect.isclass(cls) or isinstance(cls, GenericAlias):
|
|
@@ -119,7 +119,7 @@ def is_basemodel_instance(obj: Any) -> bool:
|
|
|
119
119
|
* pydantic.v1.BaseModel in Pydantic 2.x
|
|
120
120
|
|
|
121
121
|
Returns:
|
|
122
|
-
True if the given class is an instance of Pydantic
|
|
122
|
+
`True` if the given class is an instance of Pydantic `BaseModel`.
|
|
123
123
|
"""
|
|
124
124
|
return isinstance(obj, (BaseModel, BaseModelV1))
|
|
125
125
|
|
|
@@ -129,10 +129,10 @@ def pre_init(func: Callable) -> Any:
|
|
|
129
129
|
"""Decorator to run a function before model initialization.
|
|
130
130
|
|
|
131
131
|
Args:
|
|
132
|
-
func
|
|
132
|
+
func: The function to run before model initialization.
|
|
133
133
|
|
|
134
134
|
Returns:
|
|
135
|
-
|
|
135
|
+
The decorated function.
|
|
136
136
|
"""
|
|
137
137
|
with warnings.catch_warnings():
|
|
138
138
|
warnings.filterwarnings(action="ignore", category=PydanticDeprecationWarning)
|
|
@@ -146,11 +146,11 @@ def pre_init(func: Callable) -> Any:
|
|
|
146
146
|
"""Decorator to run a function before model initialization.
|
|
147
147
|
|
|
148
148
|
Args:
|
|
149
|
-
cls
|
|
150
|
-
values
|
|
149
|
+
cls: The model class.
|
|
150
|
+
values: The values to initialize the model with.
|
|
151
151
|
|
|
152
152
|
Returns:
|
|
153
|
-
|
|
153
|
+
The values to initialize the model with.
|
|
154
154
|
"""
|
|
155
155
|
# Insert default values
|
|
156
156
|
fields = cls.model_fields
|
|
@@ -206,7 +206,7 @@ def _create_subset_model_v1(
|
|
|
206
206
|
descriptions: dict | None = None,
|
|
207
207
|
fn_description: str | None = None,
|
|
208
208
|
) -> type[BaseModel]:
|
|
209
|
-
"""Create a
|
|
209
|
+
"""Create a Pydantic model with only a subset of model's fields."""
|
|
210
210
|
fields = {}
|
|
211
211
|
|
|
212
212
|
for field_name in field_names:
|
|
@@ -235,7 +235,7 @@ def _create_subset_model_v2(
|
|
|
235
235
|
descriptions: dict | None = None,
|
|
236
236
|
fn_description: str | None = None,
|
|
237
237
|
) -> type[BaseModel]:
|
|
238
|
-
"""Create a
|
|
238
|
+
"""Create a Pydantic model with a subset of the model fields."""
|
|
239
239
|
descriptions_ = descriptions or {}
|
|
240
240
|
fields = {}
|
|
241
241
|
for field_name in field_names:
|
|
@@ -438,9 +438,9 @@ def create_model(
|
|
|
438
438
|
/,
|
|
439
439
|
**field_definitions: Any,
|
|
440
440
|
) -> type[BaseModel]:
|
|
441
|
-
"""Create a
|
|
441
|
+
"""Create a Pydantic model with the given field definitions.
|
|
442
442
|
|
|
443
|
-
Please use create_model_v2 instead of this function.
|
|
443
|
+
Please use `create_model_v2` instead of this function.
|
|
444
444
|
|
|
445
445
|
Args:
|
|
446
446
|
model_name: The name of the model.
|
|
@@ -449,7 +449,7 @@ def create_model(
|
|
|
449
449
|
**field_definitions: The field definitions for the model.
|
|
450
450
|
|
|
451
451
|
Returns:
|
|
452
|
-
|
|
452
|
+
The created model.
|
|
453
453
|
"""
|
|
454
454
|
kwargs = {}
|
|
455
455
|
if "__root__" in field_definitions:
|
|
@@ -511,7 +511,7 @@ def create_model_v2(
|
|
|
511
511
|
field_definitions: dict[str, Any] | None = None,
|
|
512
512
|
root: Any | None = None,
|
|
513
513
|
) -> type[BaseModel]:
|
|
514
|
-
"""Create a
|
|
514
|
+
"""Create a Pydantic model with the given field definitions.
|
|
515
515
|
|
|
516
516
|
Attention:
|
|
517
517
|
Please do not use outside of langchain packages. This API
|
|
@@ -522,10 +522,10 @@ def create_model_v2(
|
|
|
522
522
|
module_name: The name of the module where the model is defined.
|
|
523
523
|
This is used by Pydantic to resolve any forward references.
|
|
524
524
|
field_definitions: The field definitions for the model.
|
|
525
|
-
root: Type for a root model (RootModel)
|
|
525
|
+
root: Type for a root model (`RootModel`)
|
|
526
526
|
|
|
527
527
|
Returns:
|
|
528
|
-
|
|
528
|
+
The created model.
|
|
529
529
|
"""
|
|
530
530
|
field_definitions = field_definitions or {}
|
|
531
531
|
|
langchain_core/utils/strings.py
CHANGED
|
@@ -10,7 +10,7 @@ def stringify_value(val: Any) -> str:
|
|
|
10
10
|
val: The value to stringify.
|
|
11
11
|
|
|
12
12
|
Returns:
|
|
13
|
-
|
|
13
|
+
The stringified value.
|
|
14
14
|
"""
|
|
15
15
|
if isinstance(val, str):
|
|
16
16
|
return val
|
|
@@ -28,7 +28,7 @@ def stringify_dict(data: dict) -> str:
|
|
|
28
28
|
data: The dictionary to stringify.
|
|
29
29
|
|
|
30
30
|
Returns:
|
|
31
|
-
|
|
31
|
+
The stringified dictionary.
|
|
32
32
|
"""
|
|
33
33
|
text = ""
|
|
34
34
|
for key, value in data.items():
|
|
@@ -43,7 +43,7 @@ def comma_list(items: list[Any]) -> str:
|
|
|
43
43
|
items: The list to convert.
|
|
44
44
|
|
|
45
45
|
Returns:
|
|
46
|
-
|
|
46
|
+
The comma-separated string.
|
|
47
47
|
"""
|
|
48
48
|
return ", ".join(str(item) for item in items)
|
|
49
49
|
|
|
@@ -57,10 +57,10 @@ def sanitize_for_postgres(text: str, replacement: str = "") -> str:
|
|
|
57
57
|
|
|
58
58
|
Args:
|
|
59
59
|
text: The text to sanitize.
|
|
60
|
-
replacement: String to replace NUL bytes with.
|
|
60
|
+
replacement: String to replace NUL bytes with.
|
|
61
61
|
|
|
62
62
|
Returns:
|
|
63
|
-
|
|
63
|
+
The sanitized text with NUL bytes removed or replaced.
|
|
64
64
|
|
|
65
65
|
Example:
|
|
66
66
|
>>> sanitize_for_postgres("Hello\\x00world")
|
langchain_core/utils/utils.py
CHANGED
|
@@ -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):
|
|
@@ -120,14 +122,12 @@ def guard_import(
|
|
|
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.
|
|
@@ -154,15 +154,12 @@ def check_package_version(
|
|
|
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):
|
|
@@ -228,7 +225,7 @@ def _build_model_kwargs(
|
|
|
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
231
|
ValueError: If a field is specified in both values and extra_kwargs.
|
|
@@ -276,7 +273,7 @@ def build_extra_kwargs(
|
|
|
276
273
|
all_required_field_names: All required field names for the pydantic class.
|
|
277
274
|
|
|
278
275
|
Returns:
|
|
279
|
-
|
|
276
|
+
Extra kwargs.
|
|
280
277
|
|
|
281
278
|
Raises:
|
|
282
279
|
ValueError: If a field is specified in both values and extra_kwargs.
|
|
@@ -310,10 +307,10 @@ def convert_to_secret_str(value: SecretStr | str) -> SecretStr:
|
|
|
310
307
|
"""Convert a string to a SecretStr if needed.
|
|
311
308
|
|
|
312
309
|
Args:
|
|
313
|
-
value
|
|
310
|
+
value: The value to convert.
|
|
314
311
|
|
|
315
312
|
Returns:
|
|
316
|
-
|
|
313
|
+
The SecretStr value.
|
|
317
314
|
"""
|
|
318
315
|
if isinstance(value, SecretStr):
|
|
319
316
|
return value
|
|
@@ -501,7 +498,7 @@ Used for:
|
|
|
501
498
|
def ensure_id(id_val: str | None) -> str:
|
|
502
499
|
"""Ensure the ID is a valid string, generating a new UUID if not provided.
|
|
503
500
|
|
|
504
|
-
Auto-generated UUIDs are prefixed by
|
|
501
|
+
Auto-generated UUIDs are prefixed by `'lc_'` to indicate they are
|
|
505
502
|
LangChain-generated IDs.
|
|
506
503
|
|
|
507
504
|
Args:
|