Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,13 @@ from openai import OpenAI
|
|
| 5 |
client = OpenAI(api_key="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")
|
| 6 |
|
| 7 |
def moderate_text(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
response = client.moderations.create(
|
| 9 |
model="omni-moderation-latest",
|
| 10 |
input=text
|
|
|
|
| 5 |
client = OpenAI(api_key="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")
|
| 6 |
|
| 7 |
def moderate_text(text):
|
| 8 |
+
response = client.moderations.create(
|
| 9 |
+
model="omni-moderation-latest",
|
| 10 |
+
text = str(text).strip() if text else ""
|
| 11 |
+
|
| 12 |
+
if not text:
|
| 13 |
+
return "Input text is empty. Please enter valid text."
|
| 14 |
+
|
| 15 |
response = client.moderations.create(
|
| 16 |
model="omni-moderation-latest",
|
| 17 |
input=text
|