mirror of
https://github.com/hwchase17/langchain.git
synced 2026-03-18 02:53:16 +00:00
fix(core): treat empty tool chunk ids as missing in merge (#35414)
This commit is contained in:
@@ -121,9 +121,9 @@ def merge_lists(left: list | None, *others: list | None) -> list | None:
|
||||
"index" in e_left
|
||||
and e_left["index"] == e["index"] # index matches
|
||||
and ( # IDs not inconsistent
|
||||
e_left.get("id") is None
|
||||
or e.get("id") is None
|
||||
or e_left["id"] == e["id"]
|
||||
e_left.get("id") in (None, "")
|
||||
or e.get("id") in (None, "")
|
||||
or e_left.get("id") == e.get("id")
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
@@ -122,6 +122,34 @@ def test_message_chunks() -> None:
|
||||
],
|
||||
)
|
||||
|
||||
assert (
|
||||
AIMessageChunk(
|
||||
content="",
|
||||
tool_call_chunks=[
|
||||
create_tool_call_chunk(name="tool1", args="", id="1", index=0)
|
||||
],
|
||||
)
|
||||
+ AIMessageChunk(
|
||||
content="",
|
||||
tool_call_chunks=[
|
||||
create_tool_call_chunk(name=None, args='{"arg1": "val', id="", index=0)
|
||||
],
|
||||
)
|
||||
+ AIMessageChunk(
|
||||
content="",
|
||||
tool_call_chunks=[
|
||||
create_tool_call_chunk(name=None, args='ue"}', id="", index=0)
|
||||
],
|
||||
)
|
||||
) == AIMessageChunk(
|
||||
content="",
|
||||
tool_call_chunks=[
|
||||
create_tool_call_chunk(
|
||||
name="tool1", args='{"arg1": "value"}', id="1", index=0
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
assert (
|
||||
AIMessageChunk(
|
||||
content="",
|
||||
|
||||
Reference in New Issue
Block a user