Remove native field from conversation chatlog delta listeners (#150389)

This commit is contained in:
Denis Shulyaka
2025-08-10 23:41:37 +03:00
committed by GitHub
parent 9561c84920
commit 84de6aacfc
2 changed files with 8 additions and 2 deletions

View File

@@ -342,7 +342,12 @@ class ChatLog:
name=f"llm_tool_{tool_call.id}",
)
if self.delta_listener:
self.delta_listener(self, delta) # type: ignore[arg-type]
if filtered_delta := {
k: v for k, v in delta.items() if k != "native"
}:
# We do not want to send the native content to the listener
# as it is not JSON serializable
self.delta_listener(self, filtered_delta)
continue
# Starting a new message

View File

@@ -568,7 +568,8 @@ async def test_add_delta_content_stream(
"""Yield deltas."""
for d in deltas:
yield d
expected_delta.append(d)
if filtered_delta := {k: v for k, v in d.items() if k != "native"}:
expected_delta.append(filtered_delta)
captured_deltas = []