langchain-core 1.0.0a4__py3-none-any.whl → 1.0.0a5__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/_api/beta_decorator.py +6 -5
- langchain_core/_api/deprecation.py +11 -11
- langchain_core/callbacks/manager.py +2 -2
- langchain_core/callbacks/usage.py +2 -2
- langchain_core/document_loaders/langsmith.py +1 -1
- langchain_core/indexing/api.py +30 -30
- langchain_core/language_models/chat_models.py +1 -1
- langchain_core/language_models/fake_chat_models.py +5 -2
- langchain_core/load/serializable.py +1 -1
- langchain_core/messages/__init__.py +9 -15
- langchain_core/messages/ai.py +75 -9
- langchain_core/messages/base.py +75 -37
- langchain_core/messages/block_translators/__init__.py +11 -1
- langchain_core/messages/block_translators/anthropic.py +143 -128
- langchain_core/messages/block_translators/bedrock_converse.py +15 -1
- langchain_core/messages/block_translators/langchain_v0.py +180 -43
- langchain_core/messages/block_translators/openai.py +224 -42
- langchain_core/messages/chat.py +4 -1
- langchain_core/messages/content.py +56 -112
- langchain_core/messages/function.py +9 -5
- langchain_core/messages/human.py +6 -2
- langchain_core/messages/modifier.py +1 -0
- langchain_core/messages/system.py +9 -2
- langchain_core/messages/tool.py +31 -14
- langchain_core/messages/utils.py +89 -83
- langchain_core/outputs/chat_generation.py +10 -6
- langchain_core/prompt_values.py +6 -2
- langchain_core/prompts/chat.py +6 -3
- langchain_core/prompts/few_shot.py +4 -1
- langchain_core/runnables/base.py +4 -1
- langchain_core/runnables/graph_ascii.py +1 -1
- langchain_core/tools/base.py +1 -2
- langchain_core/tools/convert.py +1 -1
- langchain_core/utils/aiter.py +1 -1
- langchain_core/utils/function_calling.py +5 -6
- langchain_core/utils/iter.py +1 -1
- langchain_core/vectorstores/in_memory.py +5 -5
- langchain_core/version.py +1 -1
- {langchain_core-1.0.0a4.dist-info → langchain_core-1.0.0a5.dist-info}/METADATA +8 -8
- {langchain_core-1.0.0a4.dist-info → langchain_core-1.0.0a5.dist-info}/RECORD +42 -42
- {langchain_core-1.0.0a4.dist-info → langchain_core-1.0.0a5.dist-info}/WHEEL +0 -0
- {langchain_core-1.0.0a4.dist-info → langchain_core-1.0.0a5.dist-info}/entry_points.txt +0 -0
|
@@ -384,23 +384,20 @@ class InvalidToolCall(TypedDict):
|
|
|
384
384
|
"""Provider-specific metadata."""
|
|
385
385
|
|
|
386
386
|
|
|
387
|
-
class
|
|
388
|
-
"""
|
|
387
|
+
class ServerToolCall(TypedDict):
|
|
388
|
+
"""Tool call that is executed server-side."""
|
|
389
389
|
|
|
390
|
-
type: Literal["
|
|
391
|
-
"""
|
|
392
|
-
|
|
393
|
-
id: NotRequired[str]
|
|
394
|
-
"""Content block identifier.
|
|
390
|
+
type: Literal["server_tool_call"]
|
|
391
|
+
"""Used for discrimination."""
|
|
395
392
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
- Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
|
|
393
|
+
id: str
|
|
394
|
+
"""An identifier associated with the tool call."""
|
|
399
395
|
|
|
400
|
-
|
|
396
|
+
name: str
|
|
397
|
+
"""The name of the tool to be called."""
|
|
401
398
|
|
|
402
|
-
|
|
403
|
-
"""The
|
|
399
|
+
args: dict[str, Any]
|
|
400
|
+
"""The arguments to the tool call."""
|
|
404
401
|
|
|
405
402
|
index: NotRequired[Union[int, str]]
|
|
406
403
|
"""Index of block in aggregate response. Used during streaming."""
|
|
@@ -409,51 +406,20 @@ class WebSearchCall(TypedDict):
|
|
|
409
406
|
"""Provider-specific metadata."""
|
|
410
407
|
|
|
411
408
|
|
|
412
|
-
class
|
|
413
|
-
"""
|
|
414
|
-
|
|
415
|
-
type: Literal["web_search_result"]
|
|
416
|
-
"""Type of the content block. Used for discrimination."""
|
|
417
|
-
|
|
418
|
-
id: NotRequired[str]
|
|
419
|
-
"""Content block identifier.
|
|
420
|
-
|
|
421
|
-
Either:
|
|
422
|
-
- Generated by the provider (e.g., OpenAI's file ID)
|
|
423
|
-
- Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
|
|
424
|
-
|
|
425
|
-
"""
|
|
426
|
-
|
|
427
|
-
urls: NotRequired[list[str]]
|
|
428
|
-
"""List of URLs returned by the web search tool call."""
|
|
429
|
-
|
|
430
|
-
index: NotRequired[Union[int, str]]
|
|
431
|
-
"""Index of block in aggregate response. Used during streaming."""
|
|
432
|
-
|
|
433
|
-
extras: NotRequired[dict[str, Any]]
|
|
434
|
-
"""Provider-specific metadata."""
|
|
409
|
+
class ServerToolCallChunk(TypedDict):
|
|
410
|
+
"""A chunk of a tool call (as part of a stream)."""
|
|
435
411
|
|
|
412
|
+
type: Literal["server_tool_call_chunk"]
|
|
413
|
+
"""Used for discrimination."""
|
|
436
414
|
|
|
437
|
-
|
|
438
|
-
"""
|
|
415
|
+
name: NotRequired[str]
|
|
416
|
+
"""The name of the tool to be called."""
|
|
439
417
|
|
|
440
|
-
|
|
441
|
-
"""
|
|
418
|
+
args: NotRequired[str]
|
|
419
|
+
"""JSON substring of the arguments to the tool call."""
|
|
442
420
|
|
|
443
421
|
id: NotRequired[str]
|
|
444
|
-
"""
|
|
445
|
-
|
|
446
|
-
Either:
|
|
447
|
-
- Generated by the provider (e.g., OpenAI's file ID)
|
|
448
|
-
- Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
|
|
449
|
-
|
|
450
|
-
"""
|
|
451
|
-
|
|
452
|
-
language: NotRequired[str]
|
|
453
|
-
"""The name of the programming language used in the code interpreter tool call."""
|
|
454
|
-
|
|
455
|
-
code: NotRequired[str]
|
|
456
|
-
"""The code to be executed by the code interpreter."""
|
|
422
|
+
"""An identifier associated with the tool call."""
|
|
457
423
|
|
|
458
424
|
index: NotRequired[Union[int, str]]
|
|
459
425
|
"""Index of block in aggregate response. Used during streaming."""
|
|
@@ -462,60 +428,23 @@ class CodeInterpreterCall(TypedDict):
|
|
|
462
428
|
"""Provider-specific metadata."""
|
|
463
429
|
|
|
464
430
|
|
|
465
|
-
class
|
|
466
|
-
"""
|
|
467
|
-
|
|
468
|
-
Full output of a code interpreter tool call is represented by
|
|
469
|
-
``CodeInterpreterResult`` which is a list of these blocks.
|
|
470
|
-
|
|
471
|
-
"""
|
|
472
|
-
|
|
473
|
-
type: Literal["code_interpreter_output"]
|
|
474
|
-
"""Type of the content block. Used for discrimination."""
|
|
475
|
-
|
|
476
|
-
id: NotRequired[str]
|
|
477
|
-
"""Content block identifier.
|
|
478
|
-
|
|
479
|
-
Either:
|
|
480
|
-
- Generated by the provider (e.g., OpenAI's file ID)
|
|
481
|
-
- Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
|
|
482
|
-
|
|
483
|
-
"""
|
|
484
|
-
|
|
485
|
-
return_code: NotRequired[int]
|
|
486
|
-
"""Return code of the executed code.
|
|
431
|
+
class ServerToolResult(TypedDict):
|
|
432
|
+
"""Result of a server-side tool call."""
|
|
487
433
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
"""
|
|
491
|
-
|
|
492
|
-
stderr: NotRequired[str]
|
|
493
|
-
"""Standard error output of the executed code."""
|
|
494
|
-
|
|
495
|
-
stdout: NotRequired[str]
|
|
496
|
-
"""Standard output of the executed code."""
|
|
497
|
-
|
|
498
|
-
file_ids: NotRequired[list[str]]
|
|
499
|
-
"""List of file IDs generated by the code interpreter."""
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
class CodeInterpreterResult(TypedDict):
|
|
503
|
-
"""Result of a code interpreter tool call."""
|
|
504
|
-
|
|
505
|
-
type: Literal["code_interpreter_result"]
|
|
506
|
-
"""Type of the content block. Used for discrimination."""
|
|
434
|
+
type: Literal["server_tool_result"]
|
|
435
|
+
"""Used for discrimination."""
|
|
507
436
|
|
|
508
437
|
id: NotRequired[str]
|
|
509
|
-
"""
|
|
438
|
+
"""An identifier associated with the server tool result."""
|
|
510
439
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
- Generated by LangChain upon creation (``UUID4`` prefixed with ``'lc_'``))
|
|
440
|
+
tool_call_id: str
|
|
441
|
+
"""ID of the corresponding server tool call."""
|
|
514
442
|
|
|
515
|
-
"""
|
|
443
|
+
status: Literal["success", "error"]
|
|
444
|
+
"""Execution status of the server-side tool."""
|
|
516
445
|
|
|
517
|
-
output:
|
|
518
|
-
"""
|
|
446
|
+
output: NotRequired[Any]
|
|
447
|
+
"""Output of the executed tool."""
|
|
519
448
|
|
|
520
449
|
index: NotRequired[Union[int, str]]
|
|
521
450
|
"""Index of block in aggregate response. Used during streaming."""
|
|
@@ -709,6 +638,12 @@ class AudioContentBlock(TypedDict):
|
|
|
709
638
|
class PlainTextContentBlock(TypedDict):
|
|
710
639
|
"""Plaintext data (e.g., from a document).
|
|
711
640
|
|
|
641
|
+
.. note::
|
|
642
|
+
A ``PlainTextContentBlock`` existed in ``langchain-core<1.0.0``. Although the
|
|
643
|
+
name has carried over, the structure has changed significantly. The only shared
|
|
644
|
+
keys between the old and new versions are ``type`` and ``text``, though the
|
|
645
|
+
``type`` value has changed from ``'text'`` to ``'text-plain'``.
|
|
646
|
+
|
|
712
647
|
.. note::
|
|
713
648
|
Title and context are optional fields that may be passed to the model. See
|
|
714
649
|
Anthropic `example <https://docs.anthropic.com/en/docs/build-with-claude/citations#citable-vs-non-citable-content>`__.
|
|
@@ -874,10 +809,9 @@ DataContentBlock = Union[
|
|
|
874
809
|
ToolContentBlock = Union[
|
|
875
810
|
ToolCall,
|
|
876
811
|
ToolCallChunk,
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
WebSearchResult,
|
|
812
|
+
ServerToolCall,
|
|
813
|
+
ServerToolCallChunk,
|
|
814
|
+
ServerToolResult,
|
|
881
815
|
]
|
|
882
816
|
|
|
883
817
|
ContentBlock = Union[
|
|
@@ -905,13 +839,17 @@ KNOWN_BLOCK_TYPES = {
|
|
|
905
839
|
"text-plain",
|
|
906
840
|
"video",
|
|
907
841
|
# Server-side tool calls
|
|
908
|
-
"
|
|
909
|
-
"
|
|
910
|
-
"
|
|
911
|
-
"web_search_result",
|
|
842
|
+
"server_tool_call",
|
|
843
|
+
"server_tool_call_chunk",
|
|
844
|
+
"server_tool_result",
|
|
912
845
|
# Catch-all
|
|
913
846
|
"non_standard",
|
|
847
|
+
# citation and non_standard_annotation intentionally omitted
|
|
914
848
|
}
|
|
849
|
+
"""These are block types known to ``langchain-core>=1.0.0``.
|
|
850
|
+
|
|
851
|
+
If a block has a type not in this set, it is considered to be provider-specific.
|
|
852
|
+
"""
|
|
915
853
|
|
|
916
854
|
|
|
917
855
|
def _get_data_content_block_types() -> tuple[str, ...]:
|
|
@@ -956,10 +894,18 @@ def is_data_content_block(block: dict) -> bool:
|
|
|
956
894
|
if any(key in block for key in ("url", "base64", "file_id", "text")):
|
|
957
895
|
# Type is valid and at least one data field is present
|
|
958
896
|
# (Accepts old-style image and audio URLContentBlock)
|
|
897
|
+
|
|
898
|
+
# 'text' is checked to support v0 PlainTextContentBlock types
|
|
899
|
+
# We must guard against new style TextContentBlock which also has 'text' `type`
|
|
900
|
+
# by ensuring the presense of `source_type`
|
|
901
|
+
if block["type"] == "text" and "source_type" not in block: # noqa: SIM103 # This is more readable
|
|
902
|
+
return False
|
|
903
|
+
|
|
959
904
|
return True
|
|
960
905
|
|
|
961
|
-
# Verify data presence based on source type
|
|
962
906
|
if "source_type" in block:
|
|
907
|
+
# Old-style content blocks had possible types of 'image', 'audio', and 'file'
|
|
908
|
+
# which is not captured in the prior check
|
|
963
909
|
source_type = block["source_type"]
|
|
964
910
|
if (source_type == "url" and "url" in block) or (
|
|
965
911
|
source_type == "base64" and "data" in block
|
|
@@ -970,8 +916,6 @@ def is_data_content_block(block: dict) -> bool:
|
|
|
970
916
|
):
|
|
971
917
|
return True
|
|
972
918
|
|
|
973
|
-
# Type may be valid, but no data fields are present
|
|
974
|
-
# (required case since each is optional and we have no validation)
|
|
975
919
|
return False
|
|
976
920
|
|
|
977
921
|
|
|
@@ -15,19 +15,20 @@ from langchain_core.utils._merge import merge_dicts
|
|
|
15
15
|
class FunctionMessage(BaseMessage):
|
|
16
16
|
"""Message for passing the result of executing a tool back to a model.
|
|
17
17
|
|
|
18
|
-
FunctionMessage are an older version of the ToolMessage schema, and
|
|
19
|
-
do not contain the tool_call_id field.
|
|
18
|
+
``FunctionMessage`` are an older version of the ``ToolMessage`` schema, and
|
|
19
|
+
do not contain the ``tool_call_id`` field.
|
|
20
20
|
|
|
21
|
-
The tool_call_id field is used to associate the tool call request with the
|
|
21
|
+
The ``tool_call_id`` field is used to associate the tool call request with the
|
|
22
22
|
tool call response. This is useful in situations where a chat model is able
|
|
23
23
|
to request multiple tool calls in parallel.
|
|
24
|
+
|
|
24
25
|
"""
|
|
25
26
|
|
|
26
27
|
name: str
|
|
27
28
|
"""The name of the function that was executed."""
|
|
28
29
|
|
|
29
30
|
type: Literal["function"] = "function"
|
|
30
|
-
"""The type of the message (used for serialization). Defaults to
|
|
31
|
+
"""The type of the message (used for serialization). Defaults to ``'function'``."""
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
class FunctionMessageChunk(FunctionMessage, BaseMessageChunk):
|
|
@@ -38,7 +39,10 @@ class FunctionMessageChunk(FunctionMessage, BaseMessageChunk):
|
|
|
38
39
|
# non-chunk variant.
|
|
39
40
|
type: Literal["FunctionMessageChunk"] = "FunctionMessageChunk" # type: ignore[assignment]
|
|
40
41
|
"""The type of the message (used for serialization).
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
Defaults to ``'FunctionMessageChunk'``.
|
|
44
|
+
|
|
45
|
+
"""
|
|
42
46
|
|
|
43
47
|
@override
|
|
44
48
|
def __add__(self, other: Any) -> BaseMessageChunk: # type: ignore[override]
|
langchain_core/messages/human.py
CHANGED
|
@@ -9,7 +9,7 @@ from langchain_core.messages.base import BaseMessage, BaseMessageChunk
|
|
|
9
9
|
class HumanMessage(BaseMessage):
|
|
10
10
|
"""Message from a human.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
``HumanMessage``s are messages that are passed in from a human to the model.
|
|
13
13
|
|
|
14
14
|
Example:
|
|
15
15
|
|
|
@@ -29,7 +29,11 @@ class HumanMessage(BaseMessage):
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
type: Literal["human"] = "human"
|
|
32
|
-
"""The type of the message (used for serialization).
|
|
32
|
+
"""The type of the message (used for serialization).
|
|
33
|
+
|
|
34
|
+
Defaults to ``'human'``.
|
|
35
|
+
|
|
36
|
+
"""
|
|
33
37
|
|
|
34
38
|
@overload
|
|
35
39
|
def __init__(
|
|
@@ -29,7 +29,11 @@ class SystemMessage(BaseMessage):
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
type: Literal["system"] = "system"
|
|
32
|
-
"""The type of the message (used for serialization).
|
|
32
|
+
"""The type of the message (used for serialization).
|
|
33
|
+
|
|
34
|
+
Defaults to ``'system'``.
|
|
35
|
+
|
|
36
|
+
"""
|
|
33
37
|
|
|
34
38
|
@overload
|
|
35
39
|
def __init__(
|
|
@@ -70,4 +74,7 @@ class SystemMessageChunk(SystemMessage, BaseMessageChunk):
|
|
|
70
74
|
# non-chunk variant.
|
|
71
75
|
type: Literal["SystemMessageChunk"] = "SystemMessageChunk" # type: ignore[assignment]
|
|
72
76
|
"""The type of the message (used for serialization).
|
|
73
|
-
|
|
77
|
+
|
|
78
|
+
Defaults to ``'SystemMessageChunk'``.
|
|
79
|
+
|
|
80
|
+
"""
|
langchain_core/messages/tool.py
CHANGED
|
@@ -16,19 +16,20 @@ from langchain_core.utils._merge import merge_dicts, merge_obj
|
|
|
16
16
|
class ToolOutputMixin:
|
|
17
17
|
"""Mixin for objects that tools can return directly.
|
|
18
18
|
|
|
19
|
-
If a custom BaseTool is invoked with a ToolCall and the output of custom code is
|
|
20
|
-
not an instance of ToolOutputMixin
|
|
21
|
-
string and wrapped in a ToolMessage
|
|
19
|
+
If a custom BaseTool is invoked with a ``ToolCall`` and the output of custom code is
|
|
20
|
+
not an instance of ``ToolOutputMixin``, the output will automatically be coerced to
|
|
21
|
+
a string and wrapped in a ``ToolMessage``.
|
|
22
|
+
|
|
22
23
|
"""
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
26
27
|
"""Message for passing the result of executing a tool back to a model.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
is encoded inside the
|
|
29
|
+
``ToolMessage``s contain the result of a tool invocation. Typically, the result
|
|
30
|
+
is encoded inside the ``content`` field.
|
|
30
31
|
|
|
31
|
-
Example: A ToolMessage representing a result of 42 from a tool call with id
|
|
32
|
+
Example: A ``ToolMessage`` representing a result of ``42`` from a tool call with id
|
|
32
33
|
|
|
33
34
|
.. code-block:: python
|
|
34
35
|
|
|
@@ -37,7 +38,7 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
37
38
|
ToolMessage(content="42", tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL")
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
Example: A ToolMessage where only part of the tool output is sent to the model
|
|
41
|
+
Example: A ``ToolMessage`` where only part of the tool output is sent to the model
|
|
41
42
|
and the full output is passed in to artifact.
|
|
42
43
|
|
|
43
44
|
.. versionadded:: 0.2.17
|
|
@@ -59,7 +60,7 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
59
60
|
tool_call_id="call_Jja7J89XsjrOLA5r!MEOW!SL",
|
|
60
61
|
)
|
|
61
62
|
|
|
62
|
-
The tool_call_id field is used to associate the tool call request with the
|
|
63
|
+
The ``tool_call_id`` field is used to associate the tool call request with the
|
|
63
64
|
tool call response. This is useful in situations where a chat model is able
|
|
64
65
|
to request multiple tool calls in parallel.
|
|
65
66
|
|
|
@@ -69,7 +70,11 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
69
70
|
"""Tool call that this message is responding to."""
|
|
70
71
|
|
|
71
72
|
type: Literal["tool"] = "tool"
|
|
72
|
-
"""The type of the message (used for serialization).
|
|
73
|
+
"""The type of the message (used for serialization).
|
|
74
|
+
|
|
75
|
+
Defaults to ``'tool'``.
|
|
76
|
+
|
|
77
|
+
"""
|
|
73
78
|
|
|
74
79
|
artifact: Any = None
|
|
75
80
|
"""Artifact of the Tool execution which is not meant to be sent to the model.
|
|
@@ -79,12 +84,14 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
79
84
|
output is needed in other parts of the code.
|
|
80
85
|
|
|
81
86
|
.. versionadded:: 0.2.17
|
|
87
|
+
|
|
82
88
|
"""
|
|
83
89
|
|
|
84
90
|
status: Literal["success", "error"] = "success"
|
|
85
91
|
"""Status of the tool invocation.
|
|
86
92
|
|
|
87
93
|
.. versionadded:: 0.2.24
|
|
94
|
+
|
|
88
95
|
"""
|
|
89
96
|
|
|
90
97
|
additional_kwargs: dict = Field(default_factory=dict, repr=False)
|
|
@@ -99,6 +106,7 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
99
106
|
|
|
100
107
|
Args:
|
|
101
108
|
values: The model arguments.
|
|
109
|
+
|
|
102
110
|
"""
|
|
103
111
|
content = values["content"]
|
|
104
112
|
if isinstance(content, tuple):
|
|
@@ -157,7 +165,15 @@ class ToolMessage(BaseMessage, ToolOutputMixin):
|
|
|
157
165
|
content_blocks: Optional[list[types.ContentBlock]] = None,
|
|
158
166
|
**kwargs: Any,
|
|
159
167
|
) -> None:
|
|
160
|
-
"""
|
|
168
|
+
"""Initialize ``ToolMessage``.
|
|
169
|
+
|
|
170
|
+
Specify ``content`` as positional arg or ``content_blocks`` for typing.
|
|
171
|
+
|
|
172
|
+
Args:
|
|
173
|
+
content: The string contents of the message.
|
|
174
|
+
content_blocks: Typed standard content.
|
|
175
|
+
**kwargs: Additional fields.
|
|
176
|
+
"""
|
|
161
177
|
if content_blocks is not None:
|
|
162
178
|
super().__init__(
|
|
163
179
|
content=cast("Union[str, list[Union[str, dict]]]", content_blocks),
|
|
@@ -208,8 +224,8 @@ class ToolCall(TypedDict):
|
|
|
208
224
|
|
|
209
225
|
{"name": "foo", "args": {"a": 1}, "id": "123"}
|
|
210
226
|
|
|
211
|
-
This represents a request to call the tool named
|
|
212
|
-
and an identifier of
|
|
227
|
+
This represents a request to call the tool named ``'foo'`` with arguments
|
|
228
|
+
``{"a": 1}`` and an identifier of ``'123'``.
|
|
213
229
|
|
|
214
230
|
"""
|
|
215
231
|
|
|
@@ -222,6 +238,7 @@ class ToolCall(TypedDict):
|
|
|
222
238
|
|
|
223
239
|
An identifier is needed to associate a tool call request with a tool
|
|
224
240
|
call result in events when multiple concurrent tool calls are made.
|
|
241
|
+
|
|
225
242
|
"""
|
|
226
243
|
type: NotRequired[Literal["tool_call"]]
|
|
227
244
|
|
|
@@ -248,9 +265,9 @@ def tool_call(
|
|
|
248
265
|
class ToolCallChunk(TypedDict):
|
|
249
266
|
"""A chunk of a tool call (e.g., as part of a stream).
|
|
250
267
|
|
|
251
|
-
When merging
|
|
268
|
+
When merging ``ToolCallChunk``s (e.g., via ``AIMessageChunk.__add__``),
|
|
252
269
|
all string attributes are concatenated. Chunks are only merged if their
|
|
253
|
-
values of
|
|
270
|
+
values of ``index`` are equal and not None.
|
|
254
271
|
|
|
255
272
|
Example:
|
|
256
273
|
|