Compare commits

...

5 Commits

Author SHA1 Message Date
Bagatur
dffa08ffcb Merge branch 'master' into wfh/is_error 2024-07-03 12:00:46 -04:00
Bagatur
3284108e5d fmt 2024-07-03 11:58:39 -04:00
Bagatur
433a6d7613 Merge branch 'master' into wfh/is_error 2024-07-03 11:32:50 -04:00
William FH
a211a811f3 Merge branch 'master' into wfh/is_error 2024-06-20 15:56:12 -07:00
William Fu-Hinthorn
fc713df9ba flip is_error 2024-05-15 19:41:02 -07:00
5 changed files with 60 additions and 15 deletions

View File

@@ -32,9 +32,8 @@ class ToolMessage(BaseMessage):
tool_call_id: str
"""Tool call that this message is responding to."""
# TODO: Add is_error param?
# is_error: bool = False
# """Whether the tool errored."""
is_error: bool = False
"""Whether the tool errored."""
type: Literal["tool"] = "tool"
"""The type of the message (used for serialization). Defaults to "tool"."""

View File

@@ -5759,6 +5759,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -6397,6 +6402,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -6950,6 +6960,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -7560,6 +7575,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -8170,6 +8190,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -8783,6 +8808,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',
@@ -9343,6 +9373,11 @@
'title': 'Id',
'type': 'string',
}),
'is_error': dict({
'default': False,
'title': 'Is Error',
'type': 'boolean',
}),
'name': dict({
'title': 'Name',
'type': 'string',

View File

@@ -256,7 +256,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"AIMessage": {
"title": "AIMessage",
"description": AnyStr(),
"description": "Message from an AI.\n\nAIMessage is returned from a chat model as a response to a prompt.\n\nThis message represents the output of the model and consists of both\nthe raw output as returned by the model together standardized fields\n(e.g., tool calls, usage metadata) added by the LangChain framework.",
"type": "object",
"properties": {
"content": {
@@ -315,7 +315,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"HumanMessage": {
"title": "HumanMessage",
"description": AnyStr(),
"description": 'Message from a human.\n\nHumanMessages are messages that are passed in from a human to the model.\n\nExample:\n\n .. code-block:: python\n\n from langchain_core.messages import HumanMessage, SystemMessage\n\n messages = [\n SystemMessage(\n content="You are a helpful assistant! Your name is Bob."\n ),\n HumanMessage(\n content="What is your name?"\n )\n ]\n\n # Instantiate a chat model and invoke it with the messages\n model = ...\n print(model.invoke(messages))',
"type": "object",
"properties": {
"content": {
@@ -359,7 +359,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"ChatMessage": {
"title": "ChatMessage",
"description": AnyStr(),
"description": "Message that can be assigned an arbitrary speaker (i.e. role).",
"type": "object",
"properties": {
"content": {
@@ -399,7 +399,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"SystemMessage": {
"title": "SystemMessage",
"description": AnyStr(),
"description": 'Message for priming AI behavior.\n\nThe system message is usually passed in as the first of a sequence\nof input messages.\n\nExample:\n\n .. code-block:: python\n\n from langchain_core.messages import HumanMessage, SystemMessage\n\n messages = [\n SystemMessage(\n content="You are a helpful assistant! Your name is Bob."\n ),\n HumanMessage(\n content="What is your name?"\n )\n ]\n\n # Define a chat model and invoke it with the messages\n print(model.invoke(messages))',
"type": "object",
"properties": {
"content": {
@@ -438,7 +438,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"FunctionMessage": {
"title": "FunctionMessage",
"description": AnyStr(),
"description": "Message for passing the result of executing a tool back to a model.\n\nFunctionMessage are an older version of the ToolMessage schema, and\ndo not contain the tool_call_id field.\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel.",
"type": "object",
"properties": {
"content": {
@@ -477,7 +477,7 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
},
"ToolMessage": {
"title": "ToolMessage",
"description": AnyStr(),
"description": "Message for passing the result of executing a tool back to a model.\n\nToolMessages contain the result of a tool invocation. Typically, the result\nis encoded inside the `content` field.\n\nExample: A TooMessage representing a result of 42 from a tool call with id\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n ToolMessage(content='42', tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL')\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel.",
"type": "object",
"properties": {
"content": {
@@ -515,6 +515,11 @@ def test_graph_sequence_map(snapshot: SnapshotAssertion) -> None:
"title": "Tool Call Id",
"type": "string",
},
"is_error": {
"title": "Is Error",
"default": False,
"type": "boolean",
},
},
"required": ["content", "tool_call_id"],
},

View File

@@ -400,7 +400,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"AIMessage": {
"title": "AIMessage",
"description": AnyStr(),
"description": "Message from an AI.\n\nAIMessage is returned from a chat model as a response to a prompt.\n\nThis message represents the output of the model and consists of both\nthe raw output as returned by the model together standardized fields\n(e.g., tool calls, usage metadata) added by the LangChain framework.",
"type": "object",
"properties": {
"content": {
@@ -454,7 +454,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"HumanMessage": {
"title": "HumanMessage",
"description": AnyStr(),
"description": 'Message from a human.\n\nHumanMessages are messages that are passed in from a human to the model.\n\nExample:\n\n .. code-block:: python\n\n from langchain_core.messages import HumanMessage, SystemMessage\n\n messages = [\n SystemMessage(\n content="You are a helpful assistant! Your name is Bob."\n ),\n HumanMessage(\n content="What is your name?"\n )\n ]\n\n # Instantiate a chat model and invoke it with the messages\n model = ...\n print(model.invoke(messages))',
"type": "object",
"properties": {
"content": {
@@ -495,7 +495,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"ChatMessage": {
"title": "ChatMessage",
"description": AnyStr(),
"description": "Message that can be assigned an arbitrary speaker (i.e. role).",
"type": "object",
"properties": {
"content": {
@@ -532,7 +532,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"SystemMessage": {
"title": "SystemMessage",
"description": AnyStr(),
"description": 'Message for priming AI behavior.\n\nThe system message is usually passed in as the first of a sequence\nof input messages.\n\nExample:\n\n .. code-block:: python\n\n from langchain_core.messages import HumanMessage, SystemMessage\n\n messages = [\n SystemMessage(\n content="You are a helpful assistant! Your name is Bob."\n ),\n HumanMessage(\n content="What is your name?"\n )\n ]\n\n # Define a chat model and invoke it with the messages\n print(model.invoke(messages))',
"type": "object",
"properties": {
"content": {
@@ -568,7 +568,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"FunctionMessage": {
"title": "FunctionMessage",
"description": AnyStr(),
"description": "Message for passing the result of executing a tool back to a model.\n\nFunctionMessage are an older version of the ToolMessage schema, and\ndo not contain the tool_call_id field.\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel.",
"type": "object",
"properties": {
"content": {
@@ -604,7 +604,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
},
"ToolMessage": {
"title": "ToolMessage",
"description": AnyStr(),
"description": "Message for passing the result of executing a tool back to a model.\n\nToolMessages contain the result of a tool invocation. Typically, the result\nis encoded inside the `content` field.\n\nExample: A TooMessage representing a result of 42 from a tool call with id\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n ToolMessage(content='42', tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL')\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel.",
"type": "object",
"properties": {
"content": {
@@ -636,6 +636,11 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
"name": {"title": "Name", "type": "string"},
"id": {"title": "Id", "type": "string"},
"tool_call_id": {"title": "Tool Call Id", "type": "string"},
"is_error": {
"title": "Is Error",
"default": False,
"type": "boolean",
},
},
"required": ["content", "tool_call_id"],
},

View File

@@ -120,6 +120,7 @@ def _merge_messages(
"type": "tool_result",
"content": curr.content,
"tool_use_id": curr.tool_call_id,
"is_error": getattr(curr, "is_error", False),
}
]
)