NavyDevilDoc commited on
Commit
4f42001
·
verified ·
1 Parent(s): 939e39c

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +25 -16
src/app.py CHANGED
@@ -69,7 +69,6 @@ with st.sidebar:
69
  st.header("🛡️ Admin Tools")
70
  admin_metric_placeholder = st.empty()
71
 
72
- # FIX: Point to the correct persistence path
73
  log_path = tracker.get_log_path()
74
  if log_path.exists():
75
  with open(log_path, "r") as f:
@@ -101,30 +100,40 @@ with st.sidebar:
101
  model_options = list(model_map.keys())
102
  model_captions = ["Slower for now, but free and private" for _ in model_options]
103
 
104
- if "admin" in st.session_state.roles:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  model_options.append("GPT-4o (Omni)")
106
  model_captions.append("Fast, smart, sends data to OpenAI")
107
 
 
108
  model_choice = st.radio(
109
  "Choose your Intelligence:",
110
  model_options,
111
  captions=model_captions,
112
- key="model_selector_radio" # Unique Key Added for Safety
113
  )
114
  st.info(f"Connected to: **{model_choice}**")
115
-
116
- # --- REGULAR USER OPENAI API KEY ---
117
- user_api_key = st.text_input(
118
- "OpenAI API Key (Optional)",
119
- type="password",
120
- help="Enter your own key to bypass limits. Press Enter to apply."
121
- )
122
-
123
- if user_api_key:
124
- st.session_state.user_openai_key = user_api_key
125
- st.caption("✅ Key Active") # Visual confirmation
126
- else:
127
- st.session_state.user_openai_key = None
128
 
129
  st.divider()
130
  st.header("⚙️ Controls")
 
69
  st.header("🛡️ Admin Tools")
70
  admin_metric_placeholder = st.empty()
71
 
 
72
  log_path = tracker.get_log_path()
73
  if log_path.exists():
74
  with open(log_path, "r") as f:
 
100
  model_options = list(model_map.keys())
101
  model_captions = ["Slower for now, but free and private" for _ in model_options]
102
 
103
+ # 2. CHECK FOR GPT-4o ACCESS (Admin OR User Key)
104
+ # We moved the input UP so the user can unlock the option immediately
105
+
106
+ # Check if user is admin
107
+ is_admin = "admin" in st.session_state.roles
108
+
109
+ # Input for Non-Admins
110
+ user_api_key = None
111
+ if not is_admin:
112
+ user_api_key = st.text_input(
113
+ "🔓 Unlock GPT-4o (Enter API Key)",
114
+ type="password",
115
+ help="Enter your OpenAI API key to access GPT-4o. Press Enter to apply."
116
+ )
117
+ if user_api_key:
118
+ st.session_state.user_openai_key = user_api_key
119
+ st.caption("✅ Key Active")
120
+ else:
121
+ st.session_state.user_openai_key = None
122
+
123
+ # 3. DYNAMICALLY ADD GPT-4o TO THE LIST
124
+ # If Admin OR if they just entered a key, show the option
125
+ if is_admin or st.session_state.get("user_openai_key"):
126
  model_options.append("GPT-4o (Omni)")
127
  model_captions.append("Fast, smart, sends data to OpenAI")
128
 
129
+ # 4. RENDER THE SELECTOR
130
  model_choice = st.radio(
131
  "Choose your Intelligence:",
132
  model_options,
133
  captions=model_captions,
134
+ key="model_selector_radio"
135
  )
136
  st.info(f"Connected to: **{model_choice}**")
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  st.divider()
139
  st.header("⚙️ Controls")