@@ -9,6 +9,7 @@ from backend import settings from ml_model.exceptions import ( FileExtensionNotSupported, GenerationException, + NSFWDetectedException, RealPersonDetectedError, RequestBlocked, ) @@ -284,6 +285,10 @@ class BytedanceModelArkAdapter: resp.text, ) raise GenerationException from exc + if error_code := data.get('error', {}).get('code', ''): + if error_code == 'OutputImageSensitiveContentDetected': + raise NSFWDetectedException + if image_data := data.get('data'): urls = [item.get('url') for item in image_data if isinstance(item, dict) and item.get('url')] if urls: