Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,7 +56,14 @@ def sanitize_input(text):
|
|
| 56 |
# Allow alphanumerics and some punctuation, then truncate to 500 characters.
|
| 57 |
clean_text = re.sub(r"[^a-zA-Z0-9\s.,!?@:\-]", "", text)
|
| 58 |
return clean_text.strip()[:500]
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
def validate_email(email):
|
| 61 |
"""
|
| 62 |
Validates that the provided email is in a valid format.
|
|
@@ -86,7 +93,7 @@ def submit_prompt(email, name, system_prompt):
|
|
| 86 |
email = sanitize_input(email)
|
| 87 |
name = sanitize_input(name)
|
| 88 |
print("UNSAINITIZED SYSTEM PROMPT", system_prompt)
|
| 89 |
-
system_prompt =
|
| 90 |
print("CLEANED SYSTEM PROMPT", system_prompt)
|
| 91 |
|
| 92 |
score = 0
|
|
|
|
| 56 |
# Allow alphanumerics and some punctuation, then truncate to 500 characters.
|
| 57 |
clean_text = re.sub(r"[^a-zA-Z0-9\s.,!?@:\-]", "", text)
|
| 58 |
return clean_text.strip()[:500]
|
| 59 |
+
|
| 60 |
+
def sanitize_prompt(text):
|
| 61 |
+
"""
|
| 62 |
+
Sanitizes input to prevent harmful content and limits its length.
|
| 63 |
+
"""
|
| 64 |
+
# Allow alphanumerics and some punctuation, then truncate to 500 characters.
|
| 65 |
+
clean_text = re.sub(r"[^a-zA-Z0-9\s.,!?@:\-]", "", text)
|
| 66 |
+
return clean_text.strip()[:8000]
|
| 67 |
def validate_email(email):
|
| 68 |
"""
|
| 69 |
Validates that the provided email is in a valid format.
|
|
|
|
| 93 |
email = sanitize_input(email)
|
| 94 |
name = sanitize_input(name)
|
| 95 |
print("UNSAINITIZED SYSTEM PROMPT", system_prompt)
|
| 96 |
+
system_prompt = sanitize_prompt(system_prompt)
|
| 97 |
print("CLEANED SYSTEM PROMPT", system_prompt)
|
| 98 |
|
| 99 |
score = 0
|