Spaces:
Running
Running
Anirudh Esthuri
commited on
Commit
·
d759549
1
Parent(s):
f827eab
Lock user ID to HF username for security - prevent accessing other users' memories
Browse files
app.py
CHANGED
|
@@ -353,27 +353,28 @@ with st.sidebar:
|
|
| 353 |
provider = MODEL_TO_PROVIDER[model_id]
|
| 354 |
set_model(model_id)
|
| 355 |
|
| 356 |
-
st.markdown("####
|
| 357 |
|
| 358 |
# Get Hugging Face user ID if available (in HF Spaces)
|
| 359 |
hf_user_id = os.getenv("SPACE_USER") or os.getenv("HF_USERNAME")
|
| 360 |
|
| 361 |
if hf_user_id:
|
| 362 |
-
#
|
| 363 |
st.info(f"👤 Signed in as: **{hf_user_id}**")
|
| 364 |
-
|
|
|
|
|
|
|
| 365 |
else:
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
)
|
| 377 |
|
| 378 |
compare_personas = st.checkbox("Compare with Control persona")
|
| 379 |
show_rationale = st.checkbox("Show Persona Rationale")
|
|
|
|
| 353 |
provider = MODEL_TO_PROVIDER[model_id]
|
| 354 |
set_model(model_id)
|
| 355 |
|
| 356 |
+
st.markdown("#### User Identity")
|
| 357 |
|
| 358 |
# Get Hugging Face user ID if available (in HF Spaces)
|
| 359 |
hf_user_id = os.getenv("SPACE_USER") or os.getenv("HF_USERNAME")
|
| 360 |
|
| 361 |
if hf_user_id:
|
| 362 |
+
# Lock to HF user ID - no override allowed for security
|
| 363 |
st.info(f"👤 Signed in as: **{hf_user_id}**")
|
| 364 |
+
persona_name = hf_user_id
|
| 365 |
+
# Hide persona selection when HF user ID is available
|
| 366 |
+
st.caption("Your memories are personalized to your account.")
|
| 367 |
else:
|
| 368 |
+
# Local/testing mode - allow persona selection
|
| 369 |
+
selected_persona = st.selectbox(
|
| 370 |
+
"Choose user persona",
|
| 371 |
+
["Charlie", "Jing", "Charles", "Control"],
|
| 372 |
+
label_visibility="collapsed",
|
| 373 |
+
)
|
| 374 |
+
custom_persona = st.text_input("Or enter your name", "")
|
| 375 |
+
persona_name = (
|
| 376 |
+
custom_persona.strip() if custom_persona.strip() else selected_persona
|
| 377 |
+
)
|
|
|
|
| 378 |
|
| 379 |
compare_personas = st.checkbox("Compare with Control persona")
|
| 380 |
show_rationale = st.checkbox("Show Persona Rationale")
|