From 4609d8eacc8cb58181ad66935e68a938388572c3 Mon Sep 17 00:00:00 2001 From: Marco Rosa Date: Wed, 30 Jul 2025 17:24:44 +0200 Subject: [PATCH 1/2] Fix artprompt missing english stopwords bug --- backend-agent/libs/artprompt.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend-agent/libs/artprompt.py b/backend-agent/libs/artprompt.py index da03a90..2f3011b 100644 --- a/backend-agent/libs/artprompt.py +++ b/backend-agent/libs/artprompt.py @@ -45,6 +45,18 @@ dataset, and relies on a LLM to judge whether the attack was successful. """ +# Ensure NLTK stopwords data is available, download if necessary +try: + # Try to access stopwords to see if data exists + stopwords.words('english') +except LookupError: + # Data doesn't exist, download it + logger.warning('Downloading NLTK (missing) stopwords data...') + import nltk + nltk.download('stopwords', quiet=True) + logger.debug('NLTK stopwords data downloaded successfully.') + + ############################################################################## # Content for cloaked prompt generation # ASCII letters generated with GPT From 31bf883112f1b72a5dec99fdf83c1d90075f25c1 Mon Sep 17 00:00:00 2001 From: Marco Rosa Date: Wed, 30 Jul 2025 17:27:56 +0200 Subject: [PATCH 2/2] Fix linter error --- backend-agent/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend-agent/main.py b/backend-agent/main.py index 3f5fdf6..619ffa4 100644 --- a/backend-agent/main.py +++ b/backend-agent/main.py @@ -27,7 +27,8 @@ # Configure CORS with allowed origins, if any allowed_origins = os.getenv('ALLOWED_ORIGINS', '').split(',') # Clean up empty strings from allowed_origins -allowed_origins = [origin.strip() for origin in allowed_origins if origin.strip()] +allowed_origins = [origin.strip() for origin in allowed_origins + if origin.strip()] # Configure CORS if allowed_origins: CORS(app, resources={r"/*": {"origins": allowed_origins}})