Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import os
|
|
7 |
import datetime
|
8 |
from datetime import datetime
|
9 |
import openai
|
|
|
10 |
|
11 |
#print('for update')
|
12 |
|
@@ -50,12 +51,21 @@ def getblog(text_inp1,text_inp2):
|
|
50 |
if each!='':
|
51 |
nsfwlowerlist.append(each.lower())
|
52 |
|
|
|
53 |
foundnsfw=0
|
54 |
for each_word in nsfwlowerlist:
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
56 |
foundnsfw=1
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
print(error_msg)
|
60 |
return(error_msg)
|
61 |
|
@@ -85,20 +95,21 @@ def getblog(text_inp1,text_inp2):
|
|
85 |
blog+=temp
|
86 |
print(blog)
|
87 |
|
88 |
-
|
89 |
-
data_nsfw = response_nsfw.text
|
90 |
-
nsfwlist=data_nsfw.split('\n')
|
91 |
-
nsfwlowerlist=[]
|
92 |
-
for each in nsfwlist:
|
93 |
-
if each!='':
|
94 |
-
nsfwlowerlist.append(each.lower())
|
95 |
-
|
96 |
foundnsfw=0
|
97 |
for each_word in nsfwlowerlist:
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
99 |
foundnsfw=1
|
|
|
|
|
|
|
100 |
if foundnsfw==1:
|
101 |
-
error_msg="Unsafe content found. Please try again with different
|
102 |
print(error_msg)
|
103 |
return(error_msg)
|
104 |
else:
|
|
|
7 |
import datetime
|
8 |
from datetime import datetime
|
9 |
import openai
|
10 |
+
import re
|
11 |
|
12 |
#print('for update')
|
13 |
|
|
|
51 |
if each!='':
|
52 |
nsfwlowerlist.append(each.lower())
|
53 |
|
54 |
+
mainstring=text_inp1
|
55 |
foundnsfw=0
|
56 |
for each_word in nsfwlowerlist:
|
57 |
+
raw_search_string = r"\b" + each_word + r"\b"
|
58 |
+
match_output = re.search(raw_search_string, mainstring)
|
59 |
+
no_match_was_found = ( match_output is None )
|
60 |
+
if no_match_was_found:
|
61 |
+
foundnsfw=0
|
62 |
+
else:
|
63 |
foundnsfw=1
|
64 |
+
print(each_word)
|
65 |
+
break
|
66 |
+
|
67 |
+
if foundnsfw==1:
|
68 |
+
error_msg="Unsafe content found. Please try again with different keywords."
|
69 |
print(error_msg)
|
70 |
return(error_msg)
|
71 |
|
|
|
95 |
blog+=temp
|
96 |
print(blog)
|
97 |
|
98 |
+
mainstring=blog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
foundnsfw=0
|
100 |
for each_word in nsfwlowerlist:
|
101 |
+
raw_search_string = r"\b" + each_word + r"\b"
|
102 |
+
match_output = re.search(raw_search_string, mainstring)
|
103 |
+
no_match_was_found = ( match_output is None )
|
104 |
+
if no_match_was_found:
|
105 |
+
foundnsfw=0
|
106 |
+
else:
|
107 |
foundnsfw=1
|
108 |
+
print(each_word)
|
109 |
+
break
|
110 |
+
|
111 |
if foundnsfw==1:
|
112 |
+
error_msg="Unsafe content found. Please try again with different keywords."
|
113 |
print(error_msg)
|
114 |
return(error_msg)
|
115 |
else:
|