Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def _merge_items_lists(self, other_items: list[Any]) -> list[Any]:
new_item = item + other_item # type: ignore
new_items_list[id] = new_item
added = True
break
except (ValueError, ContentAdditionException) as ex:
logger.debug(f"Could not add item {other_item} to {item}.", exc_info=ex)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,22 @@ def test_scmc_add_three():
assert len(combined.inner_content) == 3


def test_scmc_add_merges_item_into_one_matching_item_only():
message1 = StreamingChatMessageContent(
choice_index=0,
role=AuthorRole.ASSISTANT,
items=[
StreamingTextContent(choice_index=0, text="Part one. "),
StreamingTextContent(choice_index=0, text="Part two. "),
],
)
message2 = StreamingChatMessageContent(
choice_index=0, role=AuthorRole.ASSISTANT, items=[StreamingTextContent(choice_index=0, text="tail")]
)
combined = message1 + message2
assert [item.text for item in combined.items] == ["Part one. tail", "Part two. "]


@pytest.mark.parametrize(
"message1, message2",
[
Expand Down
Loading