Hug0endob commited on
Commit
7b1705a
·
verified ·
1 Parent(s): fc82f2f

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +12 -5
streamlit_app.py CHANGED
@@ -31,14 +31,16 @@ except ImportError: # pragma: no cover
31
  DATA_DIR = Path("./data")
32
  DATA_DIR.mkdir(exist_ok=True)
33
 
 
34
  MODEL_OPTIONS = [
 
35
  "gemini-2.5-flash",
36
- "gemini-2.5-flash-lite",
37
- "gemini-2.0-flash",
38
  "gemini-2.0-flash-lite",
 
39
  "custom",
40
  ]
41
- DEFAULT_MODEL = "gemini-2.0-flash-lite"
 
42
  DEFAULT_PROMPT = (
43
  "Watch the video and provide a detailed behavioral report focusing on human actions, "
44
  "interactions, posture, movement, and apparent intent. Keep language professional. "
@@ -235,6 +237,7 @@ def download_video(url: str, dst_dir: str, password: str = "") -> str:
235
  if not any(dst_dir.iterdir()):
236
  raise RuntimeError("yt‑dlp did not download any files.")
237
  newest = max(dst_dir.iterdir(), key=lambda p: p.stat().st_mtime)
 
238
  return convert_to_mp4(str(newest))
239
 
240
 
@@ -258,10 +261,14 @@ def main() -> None:
258
  )
259
  st.session_state["model_input"] = model
260
 
261
- # API key prefer Streamlit secrets, fall back to env / session state
262
- secret_key = st.secrets.get("google_api_key")
 
 
263
  if secret_key:
264
  st.session_state["api_key"] = secret_key
 
 
265
  st.text_input("Google API Key", key="api_key", type="password")
266
 
267
  st.text_area(
 
31
  DATA_DIR = Path("./data")
32
  DATA_DIR.mkdir(exist_ok=True)
33
 
34
+ # Use the newest Gemini model that consumes the fewest tokens
35
  MODEL_OPTIONS = [
36
+ "gemini-2.5-flash-lite", # default, cheapest‑token version
37
  "gemini-2.5-flash",
 
 
38
  "gemini-2.0-flash-lite",
39
+ "gemini-2.0-flash",
40
  "custom",
41
  ]
42
+ DEFAULT_MODEL = "gemini-2.5-flash-lite"
43
+
44
  DEFAULT_PROMPT = (
45
  "Watch the video and provide a detailed behavioral report focusing on human actions, "
46
  "interactions, posture, movement, and apparent intent. Keep language professional. "
 
237
  if not any(dst_dir.iterdir()):
238
  raise RuntimeError("yt‑dlp did not download any files.")
239
  newest = max(dst_dir.iterdir(), key=lambda p: p.stat().st_mtime)
240
+ # Return the newest file converted to MP4
241
  return convert_to_mp4(str(newest))
242
 
243
 
 
261
  )
262
  st.session_state["model_input"] = model
263
 
264
+ # ----- Secret handling (no secrets.toml) -----
265
+ # If a secret file existed it would be read here, but we fall back
266
+ # to the environment variable or manual entry.
267
+ secret_key = os.getenv("GOOGLE_API_KEY", "")
268
  if secret_key:
269
  st.session_state["api_key"] = secret_key
270
+
271
+ # Allow manual entry (overwrites any env value)
272
  st.text_input("Google API Key", key="api_key", type="password")
273
 
274
  st.text_area(