Skip to content

Commit 79f5bc2

Browse files
committed
Also use copy() in example 5
1 parent 13237a6 commit 79f5bc2

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎python/samples/02-agents/response_stream.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ def add_metadata_transform(response: ChatResponse) -> ChatResponse:
293293
def wrap_in_quotes_transform(response: ChatResponse) -> ChatResponse:
294294
"""Result transform that wraps the response text in quotes."""
295295
if response.text:
296-
return ChatResponse(
297-
messages=[Message(contents=[f'"{response.text}"'], role="assistant")],
298-
additional_properties=response.additional_properties,
299-
)
296+
transformed = copy(response)
297+
transformed.messages = [Message(contents=[f'"{response.text}"'], role="assistant")]
298+
return transformed
300299
return response
301300

302301
# The finalizer creates a response, then result transforms run in order.

0 commit comments

Comments
 (0)