File tree 1 file changed +7
-2
lines changed
libs/core/langchain_core/language_models
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,19 @@ def _format_for_tracing(messages: list[BaseMessage]) -> list[BaseMessage]:
124
124
for idx , block in enumerate (message .content ):
125
125
if (
126
126
isinstance (block , dict )
127
- and is_data_content_block (block )
128
127
and block .get ("type" ) == "image"
128
+ and is_data_content_block (block )
129
129
):
130
- message_to_trace = message .model_copy (deep = True )
130
+ if message_to_trace is message :
131
+ message_to_trace = message .model_copy ()
132
+ # Also shallow-copy content
133
+ message_to_trace .content = list (message_to_trace .content )
134
+
131
135
message_to_trace .content [idx ] = ( # type: ignore[index] # mypy confused by .model_copy
132
136
convert_to_openai_image_block (block )
133
137
)
134
138
messages_to_trace .append (message_to_trace )
139
+
135
140
return messages_to_trace
136
141
137
142
You can’t perform that action at this time.
0 commit comments