Spaces:
Running
Running
nicholasKluge
commited on
Commit
•
3701393
1
Parent(s):
56d4b07
Update app.py
Browse files
app.py
CHANGED
@@ -112,8 +112,6 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
|
|
112 |
likeable=False,
|
113 |
layout='panel')
|
114 |
|
115 |
-
#chatbot = gr.Chatbot(label="Aira").style(height=500)
|
116 |
-
|
117 |
msg = gr.Textbox(label="Write a question or instruction to Aira ...", placeholder="What is the capital of Brazil?")
|
118 |
|
119 |
# Parameters to control the generation
|
@@ -211,11 +209,13 @@ with gr.Blocks(theme='freddyaboulton/dracula_revamped') as demo:
|
|
211 |
|
212 |
toxicity_threshold = 5
|
213 |
|
214 |
-
ordered_generations = sorted(zip(decoded_text, rewards, toxicities), key=lambda x: x[1], reverse=True)
|
215 |
-
|
216 |
if safety == "On":
|
|
|
217 |
ordered_generations = [(x, y, z) for (x, y, z) in ordered_generations if z >= toxicity_threshold]
|
218 |
|
|
|
|
|
|
|
219 |
if len(ordered_generations) == 0:
|
220 |
bot_message = """I apologize for the inconvenience, but it appears that no suitable responses meeting our safety standards could be identified. Unfortunately, this indicates that the generated content may contain elements of toxicity or may not help address your message. Your input is valuable to us, and we strive to ensure a safe and constructive conversation. Please feel free to provide further details or ask any other questions, and I will do my best to assist you."""
|
221 |
|
|
|
112 |
likeable=False,
|
113 |
layout='panel')
|
114 |
|
|
|
|
|
115 |
msg = gr.Textbox(label="Write a question or instruction to Aira ...", placeholder="What is the capital of Brazil?")
|
116 |
|
117 |
# Parameters to control the generation
|
|
|
209 |
|
210 |
toxicity_threshold = 5
|
211 |
|
|
|
|
|
212 |
if safety == "On":
|
213 |
+
ordered_generations = sorted(zip(decoded_text, rewards, toxicities), key=lambda x: x[1], reverse=True)
|
214 |
ordered_generations = [(x, y, z) for (x, y, z) in ordered_generations if z >= toxicity_threshold]
|
215 |
|
216 |
+
else:
|
217 |
+
ordered_generations = sorted(zip(decoded_text, rewards), key=lambda x: x[1], reverse=True)
|
218 |
+
|
219 |
if len(ordered_generations) == 0:
|
220 |
bot_message = """I apologize for the inconvenience, but it appears that no suitable responses meeting our safety standards could be identified. Unfortunately, this indicates that the generated content may contain elements of toxicity or may not help address your message. Your input is valuable to us, and we strive to ensure a safe and constructive conversation. Please feel free to provide further details or ask any other questions, and I will do my best to assist you."""
|
221 |
|