The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community: handle chatdeepinfra jsondecode error (#27603)
Shawn Lee6f368e9eab0a
diff --git a/libs/community/langchain_community/chat_models/deepinfra.py b/libs/community/langchain_community/chat_models/deepinfra.pyindex 71389cc2c9..bb5309a6c4 100644--- a/libs/community/langchain_community/chat_models/deepinfra.py+++ b/libs/community/langchain_community/chat_models/deepinfra.py@@ -4,6 +4,7 @@ from __future__ import annotationsimport jsonimport logging+from json import JSONDecodeErrorfrom typing import (Any,AsyncIterator,@@ -96,7 +97,10 @@ def _parse_tool_calling(tool_call: dict) -> ToolCall:"""name = tool_call["function"].get("name", "")- args = json.loads(tool_call["function"]["arguments"])+ try:+ args = json.loads(tool_call["function"]["arguments"])+ except (JSONDecodeError, TypeError):+ args = {}id = tool_call.get("id")return create_tool_call(name=name, args=args, id=id)