Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,9 +8,7 @@ import traceback
|
|
8 |
|
9 |
from base64 import b64decode,b64encode
|
10 |
from io import BytesIO
|
11 |
-
import
|
12 |
-
from profanity_filter import ProfanityFilter
|
13 |
-
|
14 |
|
15 |
|
16 |
|
@@ -20,24 +18,14 @@ with gr.Blocks(theme="darkdefault") as demo:
|
|
20 |
return f"Welcome to AIXRPL.com Minter, {name}!"
|
21 |
|
22 |
|
|
|
|
|
23 |
def profanityCheck(prompt):
|
24 |
prompt = prompt.replace('+',' ').replace('|',' ')
|
25 |
-
|
26 |
-
profanity_filter = ProfanityFilter(nlps={'en_core_web_sm': nlp}) # reuse spacy Language (optional)
|
27 |
-
nlp.add_pipe(profanity_filter.spacy_component, last=True)
|
28 |
-
pf = ProfanityFilter()
|
29 |
-
pf.censor_whole_words = False
|
30 |
-
|
31 |
-
doc = nlp(prompt)
|
32 |
-
if doc._.is_profane:
|
33 |
-
print(doc)
|
34 |
return True
|
35 |
-
|
36 |
-
|
37 |
-
if token._.is_profane:
|
38 |
-
return True
|
39 |
-
|
40 |
-
return False
|
41 |
|
42 |
|
43 |
def inference(_prompt,_token):
|
|
|
8 |
|
9 |
from base64 import b64decode,b64encode
|
10 |
from io import BytesIO
|
11 |
+
from better_profanity import profanity
|
|
|
|
|
12 |
|
13 |
|
14 |
|
|
|
18 |
return f"Welcome to AIXRPL.com Minter, {name}!"
|
19 |
|
20 |
|
21 |
+
|
22 |
+
|
23 |
def profanityCheck(prompt):
|
24 |
prompt = prompt.replace('+',' ').replace('|',' ')
|
25 |
+
if profanity.contains_profanity(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return True
|
27 |
+
else:
|
28 |
+
return False
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
def inference(_prompt,_token):
|