You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/server/README-dev.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -180,6 +180,24 @@ That requires `JSON.stringify` when formatted to message content:
180
180
}
181
181
```
182
182
183
+
### Model management API (router mode)
184
+
185
+
Model management API was added via PR [#23976](https://github.com/ggml-org/llama.cpp/pull/23976)
186
+
187
+
The main goal of this API is to allow downloading models and/or removing models from the web UI. It relies on the model cache infrastructure under the hood to manage the list of models dynamically.
188
+
189
+
Instead of building everything from the ground up (like what most AI agents will do when you ask them to implement a similar feature), we built on top of existing, already well-engineered components inside the codebase:
190
+
- Model cache infrastructure as mentioned above (`common/download.h`)
191
+
- Server response queue (`server-queue.h`). We use this feature to broadcast events to SSE clients.
192
+
- Server router thread management (`server-models.h`). We re-use the same thread model that is used for managing subprocess life cycle, except that we don't create a new subprocess, but launch the download right inside the thread.
193
+
194
+
The flow for downloading a new model:
195
+
- POST request comes in --> `post_router_models` --> validation
196
+
-`server_models::download()` is called
197
+
- Sets up a new thread `inst.th` and runs the download inside
198
+
- If a stop request comes in, set `stop_download` to `true`
199
+
- Otherwise, upon completion, we call `load_models()` to refresh the list of models
200
+
183
201
### Notable Related PRs
184
202
185
203
- Initial server implementation: https://github.com/ggml-org/llama.cpp/pull/1443
0 commit comments