hra commited on
Commit
811f257
1 Parent(s): 72d179e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -41,8 +41,25 @@ titleslist=prompt.split('SEPERATOR')[2].split(',')
41
  def getblog(text_inp1,text_inp2):
42
  print(text_inp1,text_inp2)
43
  print(datetime.today().strftime("%d-%m-%Y"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  if text_inp2!='':
45
- #openai.api_key = text_inp2
46
  template_tmp=template
47
  template_tmp=template_tmp.replace("{topic}",text_inp1).strip()
48
  llm = OpenAI(temperature=0,openai_api_key=text_inp2)
@@ -75,7 +92,6 @@ def getblog(text_inp1,text_inp2):
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:
 
41
  def getblog(text_inp1,text_inp2):
42
  print(text_inp1,text_inp2)
43
  print(datetime.today().strftime("%d-%m-%Y"))
44
+
45
+ response_nsfw = requests.get('https://github.com/coffee-and-fun/google-profanity-words/raw/main/data/list.txt')
46
+ data_nsfw = response_nsfw.text
47
+ nsfwlist=data_nsfw.split('\n')
48
+ nsfwlowerlist=[]
49
+ for each in nsfwlist:
50
+ if each!='':
51
+ nsfwlowerlist.append(each.lower())
52
+
53
+ foundnsfw=0
54
+ for each_word in nsfwlowerlist:
55
+ if each_word in text_inp1:
56
+ foundnsfw=1
57
+ if foundnsfw==1:
58
+ error_msg="Unsafe content found. Please try again with different prompts."
59
+ print(error_msg)
60
+ return(error_msg)
61
+
62
  if text_inp2!='':
 
63
  template_tmp=template
64
  template_tmp=template_tmp.replace("{topic}",text_inp1).strip()
65
  llm = OpenAI(temperature=0,openai_api_key=text_inp2)
 
92
  for each in nsfwlist:
93
  if each!='':
94
  nsfwlowerlist.append(each.lower())
 
95
 
96
  foundnsfw=0
97
  for each_word in nsfwlowerlist: