Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +20 -8
src/streamlit_app.py
CHANGED
|
@@ -34,7 +34,7 @@ st.set_page_config(
|
|
| 34 |
# ==========================================
|
| 35 |
|
| 36 |
# 1. Bot Detector: The gold standard for catching GPT-written text
|
| 37 |
-
MODEL_FAKE = "
|
| 38 |
|
| 39 |
# 2. Mood Scanner: Checks detailed sentiment
|
| 40 |
MODEL_MOOD = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
@@ -43,21 +43,33 @@ MODEL_MOOD = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
| 43 |
MODEL_GRAMMAR = "textattack/roberta-base-CoLA"
|
| 44 |
|
| 45 |
# 4. Image Checker A: High Precision (Strict)
|
| 46 |
-
MODEL_IMG_A = "dima806/
|
| 47 |
|
| 48 |
# 5. Image Checker B: High Reliability (Broad)
|
| 49 |
MODEL_IMG_B = "umm-maybe/AI-image-detector"
|
| 50 |
|
| 51 |
# ==========================================
|
| 52 |
|
| 53 |
-
# --- Secrets Management ---
|
| 54 |
-
def
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
return None
|
| 58 |
|
| 59 |
-
HF_TOKEN =
|
| 60 |
-
OPENAI_API_KEY =
|
| 61 |
|
| 62 |
# --- Custom CSS ---
|
| 63 |
def inject_custom_css():
|
|
|
|
| 34 |
# ==========================================
|
| 35 |
|
| 36 |
# 1. Bot Detector: The gold standard for catching GPT-written text
|
| 37 |
+
MODEL_FAKE = "openai-community/roberta-base-openai-detector"
|
| 38 |
|
| 39 |
# 2. Mood Scanner: Checks detailed sentiment
|
| 40 |
MODEL_MOOD = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
|
|
| 43 |
MODEL_GRAMMAR = "textattack/roberta-base-CoLA"
|
| 44 |
|
| 45 |
# 4. Image Checker A: High Precision (Strict)
|
| 46 |
+
MODEL_IMG_A = "dima806/ai_generated_image_detection"
|
| 47 |
|
| 48 |
# 5. Image Checker B: High Reliability (Broad)
|
| 49 |
MODEL_IMG_B = "umm-maybe/AI-image-detector"
|
| 50 |
|
| 51 |
# ==========================================
|
| 52 |
|
| 53 |
+
# --- Robust Secrets Management ---
|
| 54 |
+
def get_secret(key):
|
| 55 |
+
"""Safe retrieval of secrets from Env Vars OR Streamlit Secrets"""
|
| 56 |
+
# 1. Check Environment Variables (Preferred for HF Spaces)
|
| 57 |
+
if key in os.environ:
|
| 58 |
+
return os.environ[key]
|
| 59 |
+
|
| 60 |
+
# 2. Check Streamlit Secrets (Preferred for Local Dev)
|
| 61 |
+
# We wrap this in try/except because accessing st.secrets throws an error
|
| 62 |
+
# if the secrets.toml file does not exist.
|
| 63 |
+
try:
|
| 64 |
+
if key in st.secrets:
|
| 65 |
+
return st.secrets[key]
|
| 66 |
+
except Exception:
|
| 67 |
+
pass
|
| 68 |
+
|
| 69 |
return None
|
| 70 |
|
| 71 |
+
HF_TOKEN = get_secret("HF_TOKEN")
|
| 72 |
+
OPENAI_API_KEY = get_secret("OPENAI_API_KEY")
|
| 73 |
|
| 74 |
# --- Custom CSS ---
|
| 75 |
def inject_custom_css():
|