Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
import openai
|
|
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
|
|
|
|
6 |
|
7 |
def moderate_text(text):
|
8 |
text = str(text).strip() if text else ""
|
@@ -35,4 +40,4 @@ iface = gr.Interface(
|
|
35 |
)
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
import os
|
5 |
|
6 |
+
# Load environment variables from .env file
|
7 |
+
load_dotenv()
|
8 |
|
9 |
+
# Set OpenAI API key from environment variable
|
10 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
11 |
|
12 |
def moderate_text(text):
|
13 |
text = str(text).strip() if text else ""
|
|
|
40 |
)
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
+
iface.launch()
|