The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix AddableDict raising exception when used with non-addable values (#12785)
Nuno Camposc4fdf78d0375
diff --git a/libs/langchain/langchain/schema/runnable/utils.py b/libs/langchain/langchain/schema/runnable/utils.pyindex 05ea6832df..781f529722 100644--- a/libs/langchain/langchain/schema/runnable/utils.py+++ b/libs/langchain/langchain/schema/runnable/utils.py@@ -192,7 +192,11 @@ class AddableDict(Dict[str, Any]):if key not in chunk or chunk[key] is None:chunk[key] = other[key]elif other[key] is not None:- chunk[key] = chunk[key] + other[key]+ try:+ added = chunk[key] + other[key]+ except TypeError:+ added = other[key]+ chunk[key] = addedreturn chunkdef __radd__(self, other: AddableDict) -> AddableDict:@@ -201,7 +205,11 @@ class AddableDict(Dict[str, Any]):if key not in chunk or chunk[key] is None:chunk[key] = self[key]elif self[key] is not None:- chunk[key] = chunk[key] + self[key]+ try:+ added = chunk[key] + self[key]+ except TypeError:+ added = self[key]+ chunk[key] = addedreturn chunk