Luigi commited on
Commit
cc91a1a
·
1 Parent(s): 0813164

add storage indicator

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -4,6 +4,7 @@ from huggingface_hub import hf_hub_download
4
  import os
5
  import gc
6
  import shutil
 
7
 
8
  # Available models
9
  MODELS = {
@@ -34,6 +35,24 @@ with st.sidebar:
34
  top_p = st.slider("Top-P", 0.1, 1.0, 0.95)
35
  repeat_penalty = st.slider("Repetition Penalty", 1.0, 2.0, 1.1)
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # Model info
38
  selected_model = MODELS[selected_model_name]
39
  model_path = os.path.join("models", selected_model["filename"])
 
4
  import os
5
  import gc
6
  import shutil
7
+ import subprocess
8
 
9
  # Available models
10
  MODELS = {
 
35
  top_p = st.slider("Top-P", 0.1, 1.0, 0.95)
36
  repeat_penalty = st.slider("Repetition Penalty", 1.0, 2.0, 1.1)
37
 
38
+ if st.button("🧹 Clear All Cached Models"):
39
+ try:
40
+ for f in os.listdir("models"):
41
+ if f.endswith(".gguf"):
42
+ os.remove(os.path.join("models", f))
43
+ st.success("Model cache cleared.")
44
+ except Exception as e:
45
+ st.error(f"Failed to clear models: {e}")
46
+
47
+ if st.button("📦 Show Disk Usage"):
48
+ try:
49
+ usage = shutil.disk_usage(".")
50
+ used = usage.used / (1024**3)
51
+ free = usage.free / (1024**3)
52
+ st.info(f"Disk Used: {used:.2f} GB | Free: {free:.2f} GB")
53
+ except Exception as e:
54
+ st.error(f"Disk usage error: {e}")
55
+
56
  # Model info
57
  selected_model = MODELS[selected_model_name]
58
  model_path = os.path.join("models", selected_model["filename"])