From 320dd77f37620d9aa9f71453afe9bf6189f2e217 Mon Sep 17 00:00:00 2001 From: Jack Kingston Date: Sun, 12 Jan 2025 14:12:53 +0000 Subject: [PATCH] Tools from Spaces: Fix bug preventing use of long prompts. (#134) --- src/smolagents/tools.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/smolagents/tools.py b/src/smolagents/tools.py index 2638f54..fd71662 100644 --- a/src/smolagents/tools.py +++ b/src/smolagents/tools.py @@ -620,9 +620,12 @@ class Tool: arg.save(temp_file.name) arg = temp_file.name if ( - isinstance(arg, (str, Path)) - and Path(arg).exists() - and Path(arg).is_file() + isinstance(arg, str) + and os.path.isfile(arg) + ) or ( + isinstance(arg, Path) + and arg.exists() + and arg.is_file() ) or is_http_url_like(arg): arg = handle_file(arg) return arg