Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,18 +10,37 @@ from datetime import datetime
|
|
10 |
from reportlab.lib.pagesizes import letter
|
11 |
from reportlab.pdfgen import canvas
|
12 |
import io
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
-
# Initialize components
|
16 |
-
groq_client = Groq(api_key=st.secrets["GROQ_API_KEY"])
|
17 |
-
personality_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
|
18 |
|
19 |
-
# Verified working Big Five model (no auth required)
|
20 |
-
big5_model = pipeline(
|
21 |
-
"text-classification",
|
22 |
-
model="bardsai/bigfive-base", # Publicly available model
|
23 |
-
top_k=5
|
24 |
-
)
|
25 |
|
26 |
# Configure Streamlit
|
27 |
st.set_page_config(page_title="🧠 Personality Prodigy", layout="wide", page_icon="🤖")
|
|
|
10 |
from reportlab.lib.pagesizes import letter
|
11 |
from reportlab.pdfgen import canvas
|
12 |
import io
|
13 |
+
from transformers import AutoModel, AutoTokenizer
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
# Initialize Groq client (Ensure API key is available in Streamlit secrets)
|
18 |
+
if "GROQ_API_KEY" in st.secrets:
|
19 |
+
groq_client = Groq(api_key=st.secrets["GROQ_API_KEY"])
|
20 |
+
else:
|
21 |
+
st.error("GROQ_API_KEY is missing in Streamlit secrets.")
|
22 |
+
|
23 |
+
# Emotion Classification Model
|
24 |
+
try:
|
25 |
+
personality_classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
|
26 |
+
except Exception as e:
|
27 |
+
st.error(f"Error loading emotion classifier: {e}")
|
28 |
+
|
29 |
+
# Big Five Personality Model
|
30 |
+
try:
|
31 |
+
big5_model = pipeline(
|
32 |
+
"text-classification",
|
33 |
+
model="bardsai/bigfive-base", # Ensure this model exists
|
34 |
+
top_k=5
|
35 |
+
)
|
36 |
+
except Exception as e:
|
37 |
+
st.error(f"Error loading Big Five personality model: {e}")
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
|
42 |
|
|
|
|
|
|
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Configure Streamlit
|
46 |
st.set_page_config(page_title="🧠 Personality Prodigy", layout="wide", page_icon="🤖")
|