Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community[patch]: Fix tool_calls parsing when streaming from DeepInfra #26813

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions libs/community/langchain_community/chat_models/deepinfra.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ def _convert_delta_to_message_chunk(
) -> BaseMessageChunk:
role = _dict.get("role")
content = _dict.get("content") or ""
tool_calls = _dict.get("tool_calls") or []

if role == "user" or default_class == HumanMessageChunk:
return HumanMessageChunk(content=content)
elif role == "assistant" or default_class == AIMessageChunk:
tool_calls = [
_parse_tool_calling(tool_call) for tool_call in _dict.get("tool_calls", [])
]
tool_calls = [_parse_tool_calling(tool_call) for tool_call in tool_calls]
return AIMessageChunk(content=content, tool_calls=tool_calls)
elif role == "system" or default_class == SystemMessageChunk:
return SystemMessageChunk(content=content)
Expand Down
Loading