Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12df938

Browse files
authored
docs(core): update docstrings inRunnableConfig,dereference_refs (#34131)
1 parent65ee43c commit12df938

File tree

2 files changed

+54
-41
lines changed

2 files changed

+54
-41
lines changed

‎libs/core/langchain_core/runnables/config.py‎

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,54 +47,59 @@ class EmptyDict(TypedDict, total=False):
4747

4848

4949
classRunnableConfig(TypedDict,total=False):
50-
"""Configuration for a Runnable."""
50+
"""Configuration for a`Runnable`.
5151
52-
tags:list[str]
52+
See the [reference docs](https://reference.langchain.com/python/langchain_core/runnables/#langchain_core.runnables.RunnableConfig)
53+
for more details.
5354
"""
54-
Tags for this call and any sub-calls (eg. a Chain calling an LLM).
55+
56+
tags:list[str]
57+
"""Tags for this call and any sub-calls (e.g. a Chain calling an LLM).
58+
5559
You can use these to filter calls.
5660
"""
5761

5862
metadata:dict[str,Any]
59-
"""
60-
Metadata for this call and any sub-calls (eg. a Chain calling an LLM).
63+
"""Metadata for this call and any sub-calls (e.g. a Chain calling an LLM).
64+
6165
Keys should be strings, values should be JSON-serializable.
6266
"""
6367

6468
callbacks:Callbacks
65-
"""
66-
Callbacks for this call and any sub-calls (eg. a Chain calling an LLM).
69+
"""Callbacks for this call and any sub-calls (e.g. a Chain calling an LLM).
70+
6771
Tags are passed to all callbacks, metadata is passed to handle*Start callbacks.
6872
"""
6973

7074
run_name:str
71-
"""
72-
Name for the tracer run for this call. Defaults to the name of the class.
73-
"""
75+
"""Name for the tracer run for this call.
76+
77+
Defaults to the name of the class."""
7478

7579
max_concurrency:int|None
76-
"""
77-
Maximum number of parallel calls to make. If not provided, defaults to
78-
`ThreadPoolExecutor`'s default.
80+
"""Maximum number of parallel calls to make.
81+
82+
If not provided, defaults to`ThreadPoolExecutor`'s default.
7983
"""
8084

8185
recursion_limit:int
82-
"""
83-
Maximum number of times a call can recurse. If not provided, defaults to `25`.
86+
"""Maximum number of times a call can recurse.
87+
88+
If not provided, defaults to `25`.
8489
"""
8590

8691
configurable:dict[str,Any]
87-
"""
88-
Runtime values for attributes previously made configurable on this `Runnable`,
92+
"""Runtime values for attributes previously made configurable on this `Runnable`,
8993
or sub-Runnables, through `configurable_fields` or `configurable_alternatives`.
94+
9095
Check `output_schema` for a description of the attributes that have been made
9196
configurable.
9297
"""
9398

9499
run_id:uuid.UUID|None
95-
"""
96-
Unique identifier for the tracer run for this call. If not provided, a new UUID
97-
will be generated.
100+
"""Unique identifier for the tracer run for this call.
101+
102+
If not provided, a new UUIDwill be generated.
98103
"""
99104

100105

‎libs/core/langchain_core/utils/json_schema.py‎

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,28 +170,33 @@ def dereference_refs(
170170
full_schema:dict|None=None,
171171
skip_keys:Sequence[str]|None=None,
172172
)->dict:
173-
"""Resolve and inline JSON Schema $ref references in a schema object.
173+
"""Resolve and inline JSON Schema`$ref` references in a schema object.
174174
175-
This function processes a JSON Schema and resolves all $ref references by replacing
176-
them with the actual referenced content. It handles both simple references and
177-
complex cases like circular references and mixed $ref objects that contain
178-
additional properties alongside the $ref.
175+
This function processes a JSON Schema and resolves all `$ref` references by
176+
replacing them with the actual referenced content.
177+
178+
Handles both simple references and complex cases like circular references and mixed
179+
`$ref` objects that contain additional properties alongside the `$ref`.
179180
180181
Args:
181-
schema_obj: The JSON Schema object or fragment to process. This can be a
182-
complete schema or just a portion of one.
183-
full_schema: The complete schema containing all definitions that $refs might
184-
point to. If not provided, defaults to schema_obj (useful when the
185-
schema is self-contained).
186-
skip_keys: Controls recursion behavior and reference resolution depth:
187-
- If `None` (Default): Only recurse under '$defs' and use shallow reference
188-
resolution (break cycles but don't deep-inline nested refs)
189-
- If provided (even as []): Recurse under all keys and use deep reference
190-
resolution (fully inline all nested references)
182+
schema_obj: The JSON Schema object or fragment to process.
183+
184+
This can be a complete schema or just a portion of one.
185+
full_schema: The complete schema containing all definitions that `$refs` might
186+
point to.
187+
188+
If not provided, defaults to `schema_obj` (useful when the schema is
189+
self-contained).
190+
skip_keys: Controls recursion behavior and reference resolution depth.
191+
192+
- If `None` (Default): Only recurse under `'$defs'` and use shallow
193+
reference resolution (break cycles but don't deep-inline nested refs)
194+
- If provided (even as `[]`): Recurse under all keys and use deep reference
195+
resolution (fully inline all nested references)
191196
192197
Returns:
193-
A new dictionary with all $ref references resolved and inlined. The original
194-
schema_obj is not modified.
198+
A new dictionary with all $ref references resolved and inlined.
199+
The original `schema_obj` is not modified.
195200
196201
Examples:
197202
Basic reference resolution:
@@ -203,7 +208,8 @@ def dereference_refs(
203208
>>> result = dereference_refs(schema)
204209
>>> result["properties"]["name"] # {"type": "string"}
205210
206-
Mixed $ref with additional properties:
211+
Mixed `$ref` with additional properties:
212+
207213
>>> schema = {
208214
... "properties": {
209215
... "name": {"$ref": "#/$defs/base", "description": "User name"}
@@ -215,6 +221,7 @@ def dereference_refs(
215221
# {"type": "string", "minLength": 1, "description": "User name"}
216222
217223
Handling circular references:
224+
218225
>>> schema = {
219226
... "properties": {"user": {"$ref": "#/$defs/User"}},
220227
... "$defs": {
@@ -227,10 +234,11 @@ def dereference_refs(
227234
>>> result = dereference_refs(schema) # Won't cause infinite recursion
228235
229236
!!! note
237+
230238
- Circular references are handled gracefully by breaking cycles
231-
- Mixed $ref objects (with both $ref and other properties) are supported
232-
- Additional properties in mixed $refs override resolved properties
233-
- The $defs section is preserved in the output by default
239+
- Mixed`$ref` objects (with both`$ref` and other properties) are supported
240+
- Additional properties in mixed`$refs` override resolved properties
241+
- The`$defs` section is preserved in the output by default
234242
"""
235243
full=full_schemaorschema_obj
236244
keys_to_skip=list(skip_keys)ifskip_keysisnotNoneelse ["$defs"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp