From: Behnam M Date: Thu, 11 Jan 2024 07:12:05 +0000 (-0500) Subject: server : update readme to document the new `/health` endpoint (#4866) X-Git-Tag: upstream/0.0.4488~2676 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=7a9f75c38b5e62fe27b8a5a3ed823b4a3714024b;p=pkg%2Fggml%2Fsources%2Fllama.cpp server : update readme to document the new `/health` endpoint (#4866) * added /health endpoint to the server * added comments on the additional /health endpoint * Better handling of server state When the model is being loaded, the server state is `LOADING_MODEL`. If model-loading fails, the server state becomes `ERROR`, otherwise it becomes `READY`. The `/health` endpoint provides more granular messages now according to the server_state value. * initialized server_state * fixed a typo * starting http server before initializing the model * Update server.cpp * Update server.cpp * fixes * fixes * fixes * made ServerState atomic and turned two-line spaces into one-line * updated `server` readme to document the `/health` endpoint too --- diff --git a/examples/server/README.md b/examples/server/README.md index d85a14f8..dc27e72b 100644 --- a/examples/server/README.md +++ b/examples/server/README.md @@ -110,6 +110,10 @@ node index.js ``` ## API Endpoints +- **GET** `/health`: Returns the current state of the server: + - `{"status": "loading model"}` if the model is still being loaded. + - `{"status": "error"}` if the model failed to load. + - `{"status": "ok"}` if the model is successfully loaded and the server is ready for further requests mentioned below. - **POST** `/completion`: Given a `prompt`, it returns the predicted completion.