mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 16:13:25 +00:00
core[patch]: dont deep copy merge_message_runs (#28454)
afaict no need to deep copy here, if we merge messages then we convert them to chunks first anyways
This commit is contained in:
parent
afa94e5bf7
commit
979a991dc2
@ -557,15 +557,14 @@ def merge_message_runs(
|
||||
messages = convert_to_messages(messages)
|
||||
merged: list[BaseMessage] = []
|
||||
for msg in messages:
|
||||
curr = msg.model_copy(deep=True)
|
||||
last = merged.pop() if merged else None
|
||||
if not last:
|
||||
merged.append(curr)
|
||||
elif isinstance(curr, ToolMessage) or not isinstance(curr, last.__class__):
|
||||
merged.extend([last, curr])
|
||||
merged.append(msg)
|
||||
elif isinstance(msg, ToolMessage) or not isinstance(msg, last.__class__):
|
||||
merged.extend([last, msg])
|
||||
else:
|
||||
last_chunk = _msg_to_chunk(last)
|
||||
curr_chunk = _msg_to_chunk(curr)
|
||||
curr_chunk = _msg_to_chunk(msg)
|
||||
if curr_chunk.response_metadata:
|
||||
curr_chunk.response_metadata.clear()
|
||||
if (
|
||||
|
Loading…
Reference in New Issue
Block a user