mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 09:25:14 +03: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:
1 parent
2543007436
commit
bc4251b9e0
2 files changed
+6
-1
No files matched your search
@@ -97,7 +97,7 @@ def merge_lists(left: Optional[list], *others: Optional[list]) -> Optional[list]
|
||||
to_merge = [
|
||||
i
|
||||
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:
|
||||
# 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"], ["foobar"]),
|
||||
(["foo"], [["bar"]], ["foo", "bar"]),
|
||||
(
|
||||
[{"text": "foo"}],
|
||||
[[{"index": 0, "text": "bar"}]],
|
||||
[{"text": "foo"}, {"index": 0, "text": "bar"}],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_merge_content(
|
||||
|
||||
Reference in new issue
Block a user