From 7e265592569291ec7b88741b47f5cdb46cf6a393 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Tue, 26 Dec 2023 12:42:24 -0800 Subject: [PATCH] Fix runnable vistitor for funcs without pos args (#15182) --- libs/core/langchain_core/runnables/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/core/langchain_core/runnables/utils.py b/libs/core/langchain_core/runnables/utils.py index 7b523e4e0f..0da6b97b26 100644 --- a/libs/core/langchain_core/runnables/utils.py +++ b/libs/core/langchain_core/runnables/utils.py @@ -107,14 +107,20 @@ class IsFunctionArgDict(ast.NodeVisitor): self.keys: Set[str] = set() def visit_Lambda(self, node: ast.Lambda) -> Any: + if not node.args.args: + return input_arg_name = node.args.args[0].arg IsLocalDict(input_arg_name, self.keys).visit(node.body) def visit_FunctionDef(self, node: ast.FunctionDef) -> Any: + if not node.args.args: + return input_arg_name = node.args.args[0].arg IsLocalDict(input_arg_name, self.keys).visit(node) def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> Any: + if not node.args.args: + return input_arg_name = node.args.args[0].arg IsLocalDict(input_arg_name, self.keys).visit(node)