Spaces:
Running
Running
Update server.py
Browse files
server.py
CHANGED
|
@@ -179,21 +179,31 @@ def chat(req: ChatRequest):
|
|
| 179 |
|
| 180 |
os.makedirs("models", exist_ok=True)
|
| 181 |
|
| 182 |
-
|
| 183 |
-
"tinyllama":
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
-
for name,
|
| 188 |
-
|
| 189 |
path = f"models/{name}.gguf"
|
| 190 |
|
| 191 |
-
if not os.path.exists(path)
|
| 192 |
-
print(f"Downloading model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
os.system(f"
|
| 195 |
|
| 196 |
-
print(f"
|
| 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
|