mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 19:47:13 +00:00
core[patch]: merge_content fix (#24526)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
from typing import List, Type
|
||||
from typing import List, Type, Union
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -18,6 +18,7 @@ from langchain_core.messages import (
|
||||
ToolMessage,
|
||||
convert_to_messages,
|
||||
get_buffer_string,
|
||||
merge_content,
|
||||
message_chunk_to_message,
|
||||
message_to_dict,
|
||||
messages_from_dict,
|
||||
@@ -950,3 +951,27 @@ def test_tool_message_str() -> None:
|
||||
expected = "content='foo' tool_call_id='1' artifact={'bar': {'baz': 123}}"
|
||||
actual = str(message)
|
||||
assert expected == actual
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
["first", "others", "expected"],
|
||||
[
|
||||
("", [""], ""),
|
||||
("", [[]], [""]),
|
||||
([], [""], []),
|
||||
([], [[]], []),
|
||||
("foo", [""], "foo"),
|
||||
("foo", [[]], ["foo"]),
|
||||
(["foo"], [""], ["foo"]),
|
||||
(["foo"], [[]], ["foo"]),
|
||||
("foo", ["bar"], "foobar"),
|
||||
("foo", [["bar"]], ["foo", "bar"]),
|
||||
(["foo"], ["bar"], ["foobar"]),
|
||||
(["foo"], [["bar"]], ["foo", "bar"]),
|
||||
],
|
||||
)
|
||||
def test_merge_content(
|
||||
first: Union[list, str], others: list, expected: Union[list, str]
|
||||
) -> None:
|
||||
actual = merge_content(first, *others)
|
||||
assert actual == expected
|
||||
|
Reference in New Issue
Block a user