23v commited on
Commit
0a93646
·
verified ·
1 Parent(s): 3a411da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -13
app.py CHANGED
@@ -100,21 +100,37 @@ def start_llama_server():
100
 
101
  binary_path = build_latest_llama_server()
102
 
103
- from huggingface_hub import hf_hub_download
104
 
105
- model_path = None
106
- for i in range(1, 34):
107
- mp = hf_hub_download(
108
- repo_id="unsloth/GLM-5.3-Flash-GGUF",
109
- filename="UD-IQ2_XXS".format(str(i).zfill(5))
110
- )
111
- if not model_path:
112
- model_path = mp
113
 
114
- mmproj_path = hf_hub_download(
115
- repo_id="unsloth/GLM-5.3-Flash-GGUF",
116
- filename="mmproj-BF16.gguf",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  )
 
118
 
119
  binary_dir = os.path.dirname(os.path.abspath(binary_path))
120
  env = os.environ.copy()
@@ -123,7 +139,7 @@ def start_llama_server():
123
  cmd = [
124
  binary_path,
125
  "-m", model_path,
126
- "-mm", mmproj_path,
127
  "--port", "8000",
128
  "--host", "127.0.0.1",
129
  "-t", "16",
 
100
 
101
  binary_path = build_latest_llama_server()
102
 
103
+ from huggingface_hub import hf_hub_download, list_repo_files
104
 
105
+ repo_id = "unsloth/GLM-5.3-Flash-GGUF"
106
+ quant = "UD-IQ2_XXS"
107
+
108
+ # Discover the real filenames instead of guessing them.
109
+ all_files = list_repo_files(repo_id)
 
 
 
110
 
111
+ model_files = sorted(
112
+ f for f in all_files
113
+ if f.endswith(".gguf") and quant in f and "mmproj" not in f.lower()
114
+ )
115
+ if not model_files:
116
+ raise RuntimeError(
117
+ f"No .gguf files matching '{quant}' found in {repo_id}. "
118
+ f"Available files: {all_files}"
119
+ )
120
+ print(f"Downloading {len(model_files)} model file(s): {model_files}")
121
+
122
+ # Download every shard; llama.cpp loads the rest automatically when
123
+ # pointed at the first one (…-00001-of-0000N.gguf).
124
+ local_paths = [hf_hub_download(repo_id=repo_id, filename=f) for f in model_files]
125
+ model_path = local_paths[0]
126
+
127
+ # Vision projector (optional): prefer BF16, then F16, then anything.
128
+ mmproj_files = [f for f in all_files if "mmproj" in f.lower() and f.endswith(".gguf")]
129
+ mmproj_file = next(
130
+ (f for tag in ("BF16", "F16") for f in mmproj_files if tag in f.upper()),
131
+ mmproj_files[0] if mmproj_files else None,
132
  )
133
+ mmproj_path = hf_hub_download(repo_id=repo_id, filename=mmproj_file) if mmproj_file else None
134
 
135
  binary_dir = os.path.dirname(os.path.abspath(binary_path))
136
  env = os.environ.copy()
 
139
  cmd = [
140
  binary_path,
141
  "-m", model_path,
142
+ *(["-mm", mmproj_path] if mmproj_path else []),
143
  "--port", "8000",
144
  "--host", "127.0.0.1",
145
  "-t", "16",