lg3394 commited on
Commit
0174bb9
·
verified ·
1 Parent(s): 716822e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
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