mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 12:01:54 +00:00
fix(core): revert "fix: tool call streaming bug with inconsistent indices from Qwen3" (#32307)
Reverts langchain-ai/langchain#32160 Original issue stems from using `ChatOpenAI` to interact with a `qwen` model. Recommended to use [langchain-qwq](https://python.langchain.com/docs/integrations/chat/qwq/) which is built for Qwen
This commit is contained in:
@@ -108,39 +108,6 @@ def merge_lists(left: Optional[list], *others: Optional[list]) -> Optional[list]
|
||||
else e
|
||||
)
|
||||
merged[to_merge[0]] = merge_dicts(merged[to_merge[0]], new_e)
|
||||
# Special handling for tool call chunks: if this chunk appears to be
|
||||
# a continuation of a prior chunk (has None name/id) and no matching
|
||||
# index was found, try to merge with the most recent tool call chunk
|
||||
# that has a name/id.
|
||||
# Fixes issues with models that send inconsistent indices.
|
||||
# See #31511 for more.
|
||||
elif (
|
||||
e.get("type") == "tool_call_chunk"
|
||||
and e.get("name") is None
|
||||
and e.get("id") is None
|
||||
and merged
|
||||
):
|
||||
# Find the most recent tool call chunk with a valid name or id
|
||||
for i in reversed(range(len(merged))):
|
||||
if (
|
||||
isinstance(merged[i], dict)
|
||||
and merged[i].get("type") == "tool_call_chunk"
|
||||
and (
|
||||
merged[i].get("name") is not None
|
||||
or merged[i].get("id") is not None
|
||||
)
|
||||
):
|
||||
# Merge with this chunk
|
||||
new_e = (
|
||||
{k: v for k, v in e.items() if k != "type"}
|
||||
if "type" in e
|
||||
else e
|
||||
)
|
||||
merged[i] = merge_dicts(merged[i], new_e)
|
||||
break
|
||||
else:
|
||||
# No suitable chunk found, append as new
|
||||
merged.append(e)
|
||||
else:
|
||||
merged.append(e)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user