Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,13 +15,13 @@ max_seq_len = 25
|
|
| 15 |
def generate_text(seed_text, next_words=30, temperature=0.5):
|
| 16 |
seed_text = seed_text.strip().lower()
|
| 17 |
|
| 18 |
-
if "|" in seed_text:
|
| 19 |
gr.Warning("The prompt should not contain the '|' character. Using default prompt.")
|
| 20 |
seed_text = 'game name | '
|
| 21 |
elif detect_profanity([seed_text], language='All'):
|
| 22 |
gr.Warning("Profanity detected in the prompt, using the default prompt.")
|
| 23 |
seed_text = 'game name | '
|
| 24 |
-
elif
|
| 25 |
gr.Warning('Harmful speech detected in the prompt, using default prompt.')
|
| 26 |
seed_text = 'game name | '
|
| 27 |
else:
|
|
@@ -52,7 +52,7 @@ def generate_text(seed_text, next_words=30, temperature=0.5):
|
|
| 52 |
if '|' in decoded:
|
| 53 |
decoded = decoded.split('|', 1)[1].strip()
|
| 54 |
|
| 55 |
-
if detect_profanity([decoded], language='All') or (detect_hate_speech(decoded) and
|
| 56 |
gr.Warning("Flagged potentially harmful output.")
|
| 57 |
decoded = 'Flagged Output'
|
| 58 |
|
|
@@ -67,7 +67,7 @@ demo = gr.Interface(
|
|
| 67 |
],
|
| 68 |
outputs=gr.Textbox(label="Generated Names"),
|
| 69 |
title='Dungen Dev - Name Generator',
|
| 70 |
-
description='A prompt-based name generator for game developers.',
|
| 71 |
examples=[
|
| 72 |
["a male character name", 30, 0.5],
|
| 73 |
["a futuristic city name", 30, 0.5],
|
|
|
|
| 15 |
def generate_text(seed_text, next_words=30, temperature=0.5):
|
| 16 |
seed_text = seed_text.strip().lower()
|
| 17 |
|
| 18 |
+
if "|" in seed_text:
|
| 19 |
gr.Warning("The prompt should not contain the '|' character. Using default prompt.")
|
| 20 |
seed_text = 'game name | '
|
| 21 |
elif detect_profanity([seed_text], language='All'):
|
| 22 |
gr.Warning("Profanity detected in the prompt, using the default prompt.")
|
| 23 |
seed_text = 'game name | '
|
| 24 |
+
elif (hate_speech_result := detect_hate_speech(seed_text)) and hate_speech_result[0] in ['Hate Speech', 'Offensive Speech']:
|
| 25 |
gr.Warning('Harmful speech detected in the prompt, using default prompt.')
|
| 26 |
seed_text = 'game name | '
|
| 27 |
else:
|
|
|
|
| 52 |
if '|' in decoded:
|
| 53 |
decoded = decoded.split('|', 1)[1].strip()
|
| 54 |
|
| 55 |
+
if any(detect_profanity([decoded], language='All')) or (hate_speech_result := detect_hate_speech(decoded)) and hate_speech_result[0] in ['Hate Speech', 'Offensive Speech']:
|
| 56 |
gr.Warning("Flagged potentially harmful output.")
|
| 57 |
decoded = 'Flagged Output'
|
| 58 |
|
|
|
|
| 67 |
],
|
| 68 |
outputs=gr.Textbox(label="Generated Names"),
|
| 69 |
title='Dungen Dev - Name Generator',
|
| 70 |
+
description='A prompt-based name generator for game developers. Dungen Dev is an experimental model, and may produce outputs that are inappropriate, biased, or potentially harmful and inaccurate. Caution is advised.',
|
| 71 |
examples=[
|
| 72 |
["a male character name", 30, 0.5],
|
| 73 |
["a futuristic city name", 30, 0.5],
|