mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-16 08:06:14 +00:00
fix(core): fix index checking when merging lists (#32431)
**Description:** fix an issue I discovered when attempting to merge messages in which one message has an `index` key in its content dictionary and another does not.
This commit is contained in:
parent
2543007436
commit
bc4251b9e0
@ -97,7 +97,7 @@ def merge_lists(left: Optional[list], *others: Optional[list]) -> Optional[list]
|
|||||||
to_merge = [
|
to_merge = [
|
||||||
i
|
i
|
||||||
for i, e_left in enumerate(merged)
|
for i, e_left in enumerate(merged)
|
||||||
if e_left["index"] == e["index"]
|
if "index" in e_left and e_left["index"] == e["index"]
|
||||||
]
|
]
|
||||||
if to_merge:
|
if to_merge:
|
||||||
# TODO: Remove this once merge_dict is updated with special
|
# TODO: Remove this once merge_dict is updated with special
|
||||||
|
@ -1019,6 +1019,11 @@ def test_tool_message_str() -> None:
|
|||||||
("foo", [["bar"]], ["foo", "bar"]),
|
("foo", [["bar"]], ["foo", "bar"]),
|
||||||
(["foo"], ["bar"], ["foobar"]),
|
(["foo"], ["bar"], ["foobar"]),
|
||||||
(["foo"], [["bar"]], ["foo", "bar"]),
|
(["foo"], [["bar"]], ["foo", "bar"]),
|
||||||
|
(
|
||||||
|
[{"text": "foo"}],
|
||||||
|
[[{"index": 0, "text": "bar"}]],
|
||||||
|
[{"text": "foo"}, {"index": 0, "text": "bar"}],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_merge_content(
|
def test_merge_content(
|
||||||
|
Loading…
Reference in New Issue
Block a user