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
Files changed (1) hide show
  1. app.py +15 -14
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("#### Choose user persona")
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
- # Use HF user ID as default, but allow override
363
  st.info(f"👤 Signed in as: **{hf_user_id}**")
364
- default_persona = hf_user_id
 
 
365
  else:
366
- default_persona = "Charlie"
367
-
368
- selected_persona = st.selectbox(
369
- "Choose user persona",
370
- ["Charlie", "Jing", "Charles", "Control"],
371
- label_visibility="collapsed",
372
- )
373
- custom_persona = st.text_input("Or enter your name", default_persona if hf_user_id else "")
374
- persona_name = (
375
- custom_persona.strip() if custom_persona.strip() else (hf_user_id if hf_user_id else selected_persona)
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")