Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,7 +67,26 @@ def getblog(text_inp1,text_inp2):
|
|
| 67 |
temp=titleslist[i]+'\n'+bloglist[i]+'\n\n'
|
| 68 |
blog+=temp
|
| 69 |
print(blog)
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
else:
|
| 72 |
return "Enter OpenAPI key"
|
| 73 |
|
|
|
|
| 67 |
temp=titleslist[i]+'\n'+bloglist[i]+'\n\n'
|
| 68 |
blog+=temp
|
| 69 |
print(blog)
|
| 70 |
+
|
| 71 |
+
response_nsfw = requests.get('https://github.com/coffee-and-fun/google-profanity-words/raw/main/data/list.txt')
|
| 72 |
+
data_nsfw = response_nsfw.text
|
| 73 |
+
nsfwlist=data_nsfw.split('\n')
|
| 74 |
+
nsfwlowerlist=[]
|
| 75 |
+
for each in nsfwlist:
|
| 76 |
+
if each!='':
|
| 77 |
+
nsfwlowerlist.append(each.lower())
|
| 78 |
+
nsfwlowerlist.extend(['bra','gay','lesbian',])
|
| 79 |
+
|
| 80 |
+
foundnsfw=0
|
| 81 |
+
for each_word in nsfwlowerlist:
|
| 82 |
+
if each_word in blog.lower() or each_word in text_inp1:
|
| 83 |
+
foundnsfw=1
|
| 84 |
+
if foundnsfw==1:
|
| 85 |
+
error_msg="Unsafe content found. Please try again with different prompts."
|
| 86 |
+
print(error_msg)
|
| 87 |
+
return(error_msg)
|
| 88 |
+
else:
|
| 89 |
+
return(blog)
|
| 90 |
else:
|
| 91 |
return "Enter OpenAPI key"
|
| 92 |
|