From 01c510658d5a5116af70037c2b096c5e051f1251 Mon Sep 17 00:00:00 2001 From: CalOmnie Date: Sun, 9 Feb 2025 17:40:16 +0100 Subject: [PATCH] Add authorized_imports in importFrom errors (#506) --- src/smolagents/local_python_executor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/smolagents/local_python_executor.py b/src/smolagents/local_python_executor.py index 346f0fe..85b5317 100644 --- a/src/smolagents/local_python_executor.py +++ b/src/smolagents/local_python_executor.py @@ -1067,7 +1067,9 @@ def import_modules(expression, state, authorized_imports): else: raise InterpreterError(f"Module {expression.module} has no attribute {alias.name}") else: - raise InterpreterError(f"Import from {expression.module} is not allowed.") + raise InterpreterError( + f"Import from {expression.module} is not allowed. Authorized imports are: {str(authorized_imports)}" + ) return None