diff --git a/libs/core/langchain_core/messages/utils.py b/libs/core/langchain_core/messages/utils.py
index eb0b7df86a2..8f5fffdf606 100644
--- a/libs/core/langchain_core/messages/utils.py
+++ b/libs/core/langchain_core/messages/utils.py
@@ -52,6 +52,12 @@ AnyMessage = Union[
SystemMessage,
FunctionMessage,
ToolMessage,
+ AIMessageChunk,
+ HumanMessageChunk,
+ ChatMessageChunk,
+ SystemMessageChunk,
+ FunctionMessageChunk,
+ ToolMessageChunk,
]
diff --git a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr
index 147181335b2..83ac40f37a8 100644
--- a/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr
+++ b/libs/core/tests/unit_tests/prompts/__snapshots__/test_chat.ambr
@@ -117,6 +117,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -195,6 +311,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -270,6 +464,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -371,6 +631,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -537,6 +875,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -591,6 +1002,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -720,6 +1214,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -781,6 +1365,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'History',
@@ -916,6 +1518,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -994,6 +1712,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -1069,6 +1865,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -1170,6 +2032,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -1336,6 +2276,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -1390,6 +2403,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -1519,6 +2615,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -1580,6 +2766,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'History',
diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
index 8bac9b66dd4..2a6ff6ad79c 100644
--- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
+++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
@@ -1,4 +1,31 @@
# serializer version: 1
+# name: test_double_nested_subgraph_mermaid[mermaid]
+ '''
+ %%{init: {'flowchart': {'curve': 'linear'}}}%%
+ graph TD;
+ __start__([__start__]):::first
+ parent_1(parent_1)
+ child_child_1_grandchild_1(grandchild_1)
+ child_child_1_grandchild_2(grandchild_2
__interrupt = before)
+ child_child_2(child_2)
+ parent_2(parent_2)
+ __end__([__end__]):::last
+ __start__ --> parent_1;
+ child_child_2 --> parent_2;
+ parent_1 --> child_child_1_grandchild_1;
+ parent_2 --> __end__;
+ subgraph child
+ child_child_1_grandchild_2 --> child_child_2;
+ subgraph child_1
+ child_child_1_grandchild_1 --> child_child_1_grandchild_2;
+ end
+ end
+ classDef default fill:#f2f0ff,line-height:1.2
+ classDef first fill-opacity:0
+ classDef last fill:#bfb6fc
+
+ '''
+# ---
# name: test_graph_sequence[ascii]
'''
+-------------+
@@ -450,6 +477,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/$defs/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/$defs/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/$defs/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/$defs/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -528,6 +671,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -603,6 +824,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -704,6 +991,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -870,6 +1235,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -924,6 +1362,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -1054,6 +1575,97 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'default': None,
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -1115,6 +1727,24 @@
dict({
'$ref': '#/$defs/ToolMessage',
}),
+ dict({
+ '$ref': '#/$defs/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/$defs/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/$defs/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/$defs/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/$defs/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/$defs/ToolMessageChunk',
+ }),
]),
'title': 'RunnableParallelInput',
}),
@@ -1250,63 +1880,6 @@
'''
# ---
-# name: test_parallel_subgraph_mermaid[mermaid]
- '''
- %%{init: {'flowchart': {'curve': 'linear'}}}%%
- graph TD;
- __start__([__start__]):::first
- outer_1(outer_1)
- inner_1_inner_1(inner_1)
- inner_1_inner_2(inner_2
__interrupt = before)
- inner_2_inner_1(inner_1)
- inner_2_inner_2(inner_2)
- outer_2(outer_2)
- __end__([__end__]):::last
- __start__ --> outer_1;
- inner_1_inner_2 --> outer_2;
- inner_2_inner_2 --> outer_2;
- outer_1 --> inner_1_inner_1;
- outer_1 --> inner_2_inner_1;
- outer_2 --> __end__;
- subgraph inner_1
- inner_1_inner_1 --> inner_1_inner_2;
- end
- subgraph inner_2
- inner_2_inner_1 --> inner_2_inner_2;
- end
- classDef default fill:#f2f0ff,line-height:1.2
- classDef first fill-opacity:0
- classDef last fill:#bfb6fc
-
- '''
-# ---
-# name: test_double_nested_subgraph_mermaid[mermaid]
- '''
- %%{init: {'flowchart': {'curve': 'linear'}}}%%
- graph TD;
- __start__([__start__]):::first
- parent_1(parent_1)
- child_child_1_grandchild_1(grandchild_1)
- child_child_1_grandchild_2(grandchild_2
__interrupt = before)
- child_child_2(child_2)
- parent_2(parent_2)
- __end__([__end__]):::last
- __start__ --> parent_1;
- child_child_2 --> parent_2;
- parent_1 --> child_child_1_grandchild_1;
- parent_2 --> __end__;
- subgraph child
- child_child_1_grandchild_2 --> child_child_2;
- subgraph child_1
- child_child_1_grandchild_1 --> child_child_1_grandchild_2;
- end
- end
- classDef default fill:#f2f0ff,line-height:1.2
- classDef first fill-opacity:0
- classDef last fill:#bfb6fc
-
- '''
-# ---
# name: test_graph_single_runnable[ascii]
'''
+----------------------+
@@ -1341,6 +1914,36 @@
'''
# ---
+# name: test_parallel_subgraph_mermaid[mermaid]
+ '''
+ %%{init: {'flowchart': {'curve': 'linear'}}}%%
+ graph TD;
+ __start__([__start__]):::first
+ outer_1(outer_1)
+ inner_1_inner_1(inner_1)
+ inner_1_inner_2(inner_2
__interrupt = before)
+ inner_2_inner_1(inner_1)
+ inner_2_inner_2(inner_2)
+ outer_2(outer_2)
+ __end__([__end__]):::last
+ __start__ --> outer_1;
+ inner_1_inner_2 --> outer_2;
+ inner_2_inner_2 --> outer_2;
+ outer_1 --> inner_1_inner_1;
+ outer_1 --> inner_2_inner_1;
+ outer_2 --> __end__;
+ subgraph inner_1
+ inner_1_inner_1 --> inner_1_inner_2;
+ end
+ subgraph inner_2
+ inner_2_inner_1 --> inner_2_inner_2;
+ end
+ classDef default fill:#f2f0ff,line-height:1.2
+ classDef first fill-opacity:0
+ classDef last fill:#bfb6fc
+
+ '''
+# ---
# name: test_trim
dict({
'edges': list([
diff --git a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr
index 3f81124da20..164e3f8366f 100644
--- a/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr
+++ b/libs/core/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr
@@ -5294,6 +5294,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -5372,6 +5488,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -5447,6 +5641,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -5548,6 +5808,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -5714,6 +6052,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -5768,6 +6179,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -5897,6 +6391,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -5958,6 +6542,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'History',
@@ -6097,6 +6699,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -6175,6 +6893,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'ChatPromptValueConcrete': dict({
'description': '''
Chat prompt value which explicitly lists out the message types it accepts.
@@ -6202,6 +6998,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'Messages',
@@ -6298,6 +7112,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -6399,6 +7279,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -6588,6 +7546,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -6642,6 +7673,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -6771,6 +7885,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -6846,6 +8050,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'type': 'array',
@@ -6967,6 +8189,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -7045,6 +8383,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'ChatPromptValueConcrete': dict({
'description': '''
Chat prompt value which explicitly lists out the message types it accepts.
@@ -7072,6 +8488,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'Messages',
@@ -7168,6 +8602,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -7269,6 +8769,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -7458,6 +9036,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -7512,6 +9163,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -7641,6 +9375,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -7704,6 +9528,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
'definitions': dict({
'AIMessage': dict({
@@ -7821,6 +9663,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -7899,6 +9857,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -7974,6 +10010,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -8075,6 +10177,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -8241,6 +10421,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -8295,6 +10548,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -8424,6 +10760,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -8499,6 +10925,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'type': 'array',
@@ -8620,6 +11064,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -8698,6 +11258,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'ChatPromptValueConcrete': dict({
'description': '''
Chat prompt value which explicitly lists out the message types it accepts.
@@ -8725,6 +11363,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'Messages',
@@ -8821,6 +11477,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -8922,6 +11644,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -9111,6 +11911,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -9165,6 +12038,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -9294,6 +12250,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -9360,6 +12406,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
'definitions': dict({
'AIMessage': dict({
@@ -9477,6 +12541,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -9555,6 +12735,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'FunctionMessage': dict({
'additionalProperties': True,
'description': '''
@@ -9630,6 +12888,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -9731,6 +13055,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -9897,6 +13299,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -9951,6 +13426,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -10080,6 +13638,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -10240,6 +13888,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -10318,6 +14082,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'ChatPromptValueConcrete': dict({
'description': '''
Chat prompt value which explicitly lists out the message types it accepts.
@@ -10345,6 +14187,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'Messages',
@@ -10441,6 +14301,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -10542,6 +14468,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -10742,6 +14746,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -10796,6 +14873,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -10925,6 +15085,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.
@@ -11097,6 +15347,122 @@
'title': 'AIMessage',
'type': 'object',
}),
+ 'AIMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Message chunk from an AI.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'invalid_tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/InvalidToolCall',
+ }),
+ 'title': 'Invalid Tool Calls',
+ 'type': 'array',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'tool_call_chunks': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCallChunk',
+ }),
+ 'title': 'Tool Call Chunks',
+ 'type': 'array',
+ }),
+ 'tool_calls': dict({
+ 'default': list([
+ ]),
+ 'items': dict({
+ '$ref': '#/definitions/ToolCall',
+ }),
+ 'title': 'Tool Calls',
+ 'type': 'array',
+ }),
+ 'type': dict({
+ 'const': 'AIMessageChunk',
+ 'default': 'AIMessageChunk',
+ 'enum': list([
+ 'AIMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ 'usage_metadata': dict({
+ 'anyOf': list([
+ dict({
+ '$ref': '#/definitions/UsageMetadata',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'AIMessageChunk',
+ 'type': 'object',
+ }),
'ChatMessage': dict({
'additionalProperties': True,
'description': 'Message that can be assigned an arbitrary speaker (i.e. role).',
@@ -11175,6 +15541,84 @@
'title': 'ChatMessage',
'type': 'object',
}),
+ 'ChatMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Chat Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'role': dict({
+ 'title': 'Role',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ChatMessageChunk',
+ 'default': 'ChatMessageChunk',
+ 'enum': list([
+ 'ChatMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'role',
+ ]),
+ 'title': 'ChatMessageChunk',
+ 'type': 'object',
+ }),
'ChatPromptValueConcrete': dict({
'description': '''
Chat prompt value which explicitly lists out the message types it accepts.
@@ -11202,6 +15646,24 @@
dict({
'$ref': '#/definitions/ToolMessage',
}),
+ dict({
+ '$ref': '#/definitions/AIMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/HumanMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ChatMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/SystemMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/FunctionMessageChunk',
+ }),
+ dict({
+ '$ref': '#/definitions/ToolMessageChunk',
+ }),
]),
}),
'title': 'Messages',
@@ -11298,6 +15760,72 @@
'title': 'FunctionMessage',
'type': 'object',
}),
+ 'FunctionMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Function Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'title': 'Name',
+ 'type': 'string',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'FunctionMessageChunk',
+ 'default': 'FunctionMessageChunk',
+ 'enum': list([
+ 'FunctionMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'name',
+ ]),
+ 'title': 'FunctionMessageChunk',
+ 'type': 'object',
+ }),
'HumanMessage': dict({
'additionalProperties': True,
'description': '''
@@ -11399,6 +15927,84 @@
'title': 'HumanMessage',
'type': 'object',
}),
+ 'HumanMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Human Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'example': dict({
+ 'default': False,
+ 'title': 'Example',
+ 'type': 'boolean',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'HumanMessageChunk',
+ 'default': 'HumanMessageChunk',
+ 'enum': list([
+ 'HumanMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'HumanMessageChunk',
+ 'type': 'object',
+ }),
'InvalidToolCall': dict({
'description': '''
Allowance for errors made by LLM.
@@ -11588,6 +16194,79 @@
'title': 'SystemMessage',
'type': 'object',
}),
+ 'SystemMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'System Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'type': dict({
+ 'const': 'SystemMessageChunk',
+ 'default': 'SystemMessageChunk',
+ 'enum': list([
+ 'SystemMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ ]),
+ 'title': 'SystemMessageChunk',
+ 'type': 'object',
+ }),
'ToolCall': dict({
'description': '''
Represents a request to call a tool.
@@ -11642,6 +16321,89 @@
'title': 'ToolCall',
'type': 'object',
}),
+ 'ToolCallChunk': dict({
+ 'description': '''
+ A chunk of a tool call (e.g., as part of a stream).
+
+ When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
+ all string attributes are concatenated. Chunks are only merged if their
+ values of `index` are equal and not None.
+
+ Example:
+
+ .. code-block:: python
+
+ left_chunks = [ToolCallChunk(name="foo", args='{"a":', index=0)]
+ right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]
+
+ (
+ AIMessageChunk(content="", tool_call_chunks=left_chunks)
+ + AIMessageChunk(content="", tool_call_chunks=right_chunks)
+ ).tool_call_chunks == [ToolCallChunk(name='foo', args='{"a":1}', index=0)]
+ ''',
+ 'properties': dict({
+ 'args': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Args',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Id',
+ }),
+ 'index': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'integer',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Index',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'title': 'Name',
+ }),
+ 'type': dict({
+ 'const': 'tool_call_chunk',
+ 'enum': list([
+ 'tool_call_chunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'name',
+ 'args',
+ 'id',
+ 'index',
+ ]),
+ 'title': 'ToolCallChunk',
+ 'type': 'object',
+ }),
'ToolMessage': dict({
'additionalProperties': True,
'description': '''
@@ -11771,6 +16533,96 @@
'title': 'ToolMessage',
'type': 'object',
}),
+ 'ToolMessageChunk': dict({
+ 'additionalProperties': True,
+ 'description': 'Tool Message chunk.',
+ 'properties': dict({
+ 'additional_kwargs': dict({
+ 'title': 'Additional Kwargs',
+ 'type': 'object',
+ }),
+ 'artifact': dict({
+ 'title': 'Artifact',
+ }),
+ 'content': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'items': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'object',
+ }),
+ ]),
+ }),
+ 'type': 'array',
+ }),
+ ]),
+ 'title': 'Content',
+ }),
+ 'id': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Id',
+ }),
+ 'name': dict({
+ 'anyOf': list([
+ dict({
+ 'type': 'string',
+ }),
+ dict({
+ 'type': 'null',
+ }),
+ ]),
+ 'default': None,
+ 'title': 'Name',
+ }),
+ 'response_metadata': dict({
+ 'title': 'Response Metadata',
+ 'type': 'object',
+ }),
+ 'status': dict({
+ 'default': 'success',
+ 'enum': list([
+ 'success',
+ 'error',
+ ]),
+ 'title': 'Status',
+ 'type': 'string',
+ }),
+ 'tool_call_id': dict({
+ 'title': 'Tool Call Id',
+ 'type': 'string',
+ }),
+ 'type': dict({
+ 'const': 'ToolMessageChunk',
+ 'default': 'ToolMessageChunk',
+ 'enum': list([
+ 'ToolMessageChunk',
+ ]),
+ 'title': 'Type',
+ 'type': 'string',
+ }),
+ }),
+ 'required': list([
+ 'content',
+ 'tool_call_id',
+ ]),
+ 'title': 'ToolMessageChunk',
+ 'type': 'object',
+ }),
'UsageMetadata': dict({
'description': '''
Usage metadata for a message, such as token counts.