Spaces:
Runtime error
Runtime error
add input check
Browse files12311 unmodified lines15161718192011 unmodified lines323334353637def is_unsafe_prompt(model, tokenizer, user_prompt):prompt = f"""You are a content safety filter. Your task is to analyze the following user input and determine if it contains unsafe content.11 unmodified linesmessages = [{"role": "user", "content": prompt}]text = tokenizer.apply_chat_template(messages,tokenize=False,11 unmodified linescontent = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n")print(content)return "yes" in content.lower()123456711 unmodified lines192021222324252611 unmodified lines383940414243from diffusers.utils.logging import get_loggerlogger = get_logger(__name__)def is_unsafe_prompt(model, tokenizer, user_prompt):prompt = f"""You are a content safety filter. Your task is to analyze the following user input and determine if it contains unsafe content.11 unmodified linesmessages = [{"role": "user", "content": prompt}]logger.warning(str(messages))text = tokenizer.apply_chat_template(messages,tokenize=False,11 unmodified linescontent = tokenizer.decode(output_ids, skip_special_tokens=True).strip("\n")logger.warning(content)return "yes" in content.lower()
prompt_check.py+7-1