diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-04-25 21:53:18 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-04-25 21:53:18 -0400 |
| commit | 24e471ddc7b5367e7cdcd1bcbd70c45a812a3131 (patch) | |
| tree | 5c247637ed8e4dc42725a80343694d4fa457581a /epistemia/services | |
| parent | 50ad0e8c36e59d6e9572f73551d5cb44ab4cd834 (diff) | |
services/machine-learning: add service for llama-swap
Diffstat (limited to 'epistemia/services')
| -rw-r--r-- | epistemia/services/machine-learning.scm | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/epistemia/services/machine-learning.scm b/epistemia/services/machine-learning.scm new file mode 100644 index 0000000..0226300 --- /dev/null +++ b/epistemia/services/machine-learning.scm | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | (define-module (epistemia services machine-learning) | ||
| 2 | #:use-module (gnu services) | ||
| 3 | #:use-module (gnu services shepherd) | ||
| 4 | #:use-module (guix gexp) | ||
| 5 | #:use-module (guix records) | ||
| 6 | #:export (llama-swap-configuration | ||
| 7 | llama-swap-configuration? | ||
| 8 | llama-swap-service-type)) | ||
| 9 | |||
| 10 | (define-record-type* <llama-swap-configuration> | ||
| 11 | llama-swap-configuration make-llama-swap-configuration | ||
| 12 | llama-swap-configuration? | ||
| 13 | (package llama-swap-configuration-package | ||
| 14 | (default llama-swap)) | ||
| 15 | (llama-cpp llama-swap-configuration-llama-cpp | ||
| 16 | (default llama-cpp)) | ||
| 17 | (config llama-swap-configuration-config) | ||
| 18 | (listen llama-swap-configuration-listen | ||
| 19 | (default ":8080")) | ||
| 20 | (watch-config? llama-swap-configuration-watch-config? | ||
| 21 | (default #f))) | ||
| 22 | |||
| 23 | (define (llama-swap-shepherd-service config) | ||
| 24 | (let ((pkg (llama-swap-configuration-package config)) | ||
| 25 | (lcpp (llama-swap-configuration-llama-cpp config)) | ||
| 26 | (cfg (llama-swap-configuration-config config)) | ||
| 27 | (listen (llama-swap-configuration-listen config)) | ||
| 28 | (watch? (llama-swap-configuration-watch-config? config))) | ||
| 29 | (list | ||
| 30 | (shepherd-service | ||
| 31 | (documentation "llama-swap OpenAI-compatible model proxy") | ||
| 32 | (provision '(llama-swap)) | ||
| 33 | (requirement '(networking)) | ||
| 34 | (start #~(make-forkexec-constructor | ||
| 35 | (append | ||
| 36 | (list #$(file-append pkg "/bin/llama-swap") | ||
| 37 | "-config" #$cfg | ||
| 38 | "-listen" #$listen) | ||
| 39 | (if #$watch? '("-watch-config") '())) | ||
| 40 | #:environment-variables | ||
| 41 | (cons (string-append "PATH=" #$(file-append lcpp "/bin")) | ||
| 42 | (default-environment-variables)))) | ||
| 43 | (stop #~(make-kill-destructor)))))) | ||
| 44 | |||
| 45 | (define llama-swap-service-type | ||
| 46 | (service-type | ||
| 47 | (name 'llama-swap) | ||
| 48 | (extensions | ||
| 49 | (list (service-extension shepherd-root-service-type | ||
| 50 | llama-swap-shepherd-service))) | ||
| 51 | (description | ||
| 52 | "llama-swap is an @code{OpenAI} API compatible server that gives you complete | ||
| 53 | control over how you use your hardware. It automatically swaps to the | ||
| 54 | configuration of your choice for serving a model."))) | ||
