mrmadblack commited on
Commit
8bdd554
·
verified ·
1 Parent(s): 3b266a7

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +19 -9
server.py CHANGED
@@ -179,21 +179,31 @@ def chat(req: ChatRequest):
179
 
180
  os.makedirs("models", exist_ok=True)
181
 
182
- MODEL_URLS = {
183
- "tinyllama": "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat.Q4_K_M.gguf",
184
- "qwen": "https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF/resolve/main/qwen1_5-1_8b-chat-q4_k_m.gguf"
 
 
 
 
 
 
185
  }
186
 
187
- for name, url in MODEL_URLS.items():
188
-
189
  path = f"models/{name}.gguf"
190
 
191
- if not os.path.exists(path) or os.path.getsize(path) < 100000000:
192
- print(f"Downloading model: {name}")
 
 
 
 
 
193
 
194
- os.system(f"curl -L {url} -o {path}")
195
 
196
- print(f"Downloaded {name}")
197
 
198
  # ---------------------------
199
  # Start server
 
179
 
180
  os.makedirs("models", exist_ok=True)
181
 
182
+ MODEL_FILES = {
183
+ "tinyllama": (
184
+ "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF",
185
+ "tinyllama-1.1b-chat.Q4_K_M.gguf"
186
+ ),
187
+ "qwen": (
188
+ "Qwen/Qwen1.5-1.8B-Chat-GGUF",
189
+ "qwen1_5-1_8b-chat-q4_k_m.gguf"
190
+ )
191
  }
192
 
193
+ for name, (repo, file) in MODEL_FILES.items():
 
194
  path = f"models/{name}.gguf"
195
 
196
+ if not os.path.exists(path):
197
+ print(f"Downloading model {name} from {repo}")
198
+
199
+ downloaded = hf_hub_download(
200
+ repo_id=repo,
201
+ filename=file
202
+ )
203
 
204
+ os.system(f"cp {downloaded} {path}")
205
 
206
+ print(f"Model ready: {path}")
207
 
208
  # ---------------------------
209
  # Start server