diff --git a/libs/core/langchain_core/runnables/utils.py b/libs/core/langchain_core/runnables/utils.py index a81ca7615a66f..89e3651dcce4c 100644 --- a/libs/core/langchain_core/runnables/utils.py +++ b/libs/core/langchain_core/runnables/utils.py @@ -271,6 +271,20 @@ def visit_Attribute(self, node: ast.Attribute) -> Any: if isinstance(parent, ast.Name): self.loads.add(parent.id + "." + attr_expr) self.loads.discard(parent.id) + elif isinstance(parent, ast.Call): + if isinstance(parent.func, ast.Name): + self.loads.add(parent.func.id) + else: + parent = parent.func + attr_expr = "" + while isinstance(parent, ast.Attribute): + if attr_expr: + attr_expr = parent.attr + "." + attr_expr + else: + attr_expr = parent.attr + parent = parent.value + if isinstance(parent, ast.Name): + self.loads.add(parent.id + "." + attr_expr) class FunctionNonLocals(ast.NodeVisitor):