diff --git a/public/languages/scheme/Dockerfile b/public/languages/scheme/Dockerfile index 1727a3a..bef4d59 100644 --- a/public/languages/scheme/Dockerfile +++ b/public/languages/scheme/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get update && \ guile-3.0 \ guile-3.0-dev \ guile-json \ + guile-gnutls \ curl \ ca-certificates && \ rm -rf /var/lib/apt/lists/* diff --git a/public/languages/scheme/uncloseai.scm b/public/languages/scheme/uncloseai.scm index 8aa0c12..c9551ab 100644 --- a/public/languages/scheme/uncloseai.scm +++ b/public/languages/scheme/uncloseai.scm @@ -16,8 +16,10 @@ (ice-9 textual-ports) (ice-9 rdelim) (ice-9 binary-ports) + (rnrs bytevectors) (json) - (srfi srfi-1)) + (srfi srfi-1) + (srfi srfi-43)) ;;; Global client state (define *model-ids* '()) @@ -46,22 +48,28 @@ (http-get (string-append endpoint "/models"))) (lambda (response body) (when (= (response-code response) 200) - (let* ((json-response (json-string->scm (utf8->string body))) + (let* ((body-string (if (bytevector? body) + (utf8->string body) + body)) + (json-response (json-string->scm body-string)) (models-data (assoc-ref json-response "data"))) (when models-data - ;; Process each model in the response - (vector-for-each - (lambda (model) - (let ((model-id (assoc-ref model "id"))) - ;; Skip modelperm entries - (when (and model-id - (not (string-prefix? "modelperm-" model-id))) - ;; Extract max_model_len if available (vLLM) - (let ((max-tokens (or (assoc-ref model "max_model_len") 8192))) - (set! *model-ids* (append *model-ids* (list model-id))) - (set! *model-endpoints* (append *model-endpoints* (list endpoint))) - (set! *model-max-tokens* (append *model-max-tokens* (list max-tokens))))))) - models-data))))))) + ;; Process each model in the response (handle both vector and list) + (let ((models-list (if (vector? models-data) + (vector->list models-data) + models-data))) + (for-each + (lambda (model) + (let ((model-id (assoc-ref model "id"))) + ;; Skip modelperm entries + (when (and model-id + (not (string-prefix? "modelperm-" model-id))) + ;; Extract max_model_len if available (vLLM) + (let ((max-tokens (or (assoc-ref model "max_model_len") 8192))) + (set! *model-ids* (append *model-ids* (list model-id))) + (set! *model-endpoints* (append *model-endpoints* (list endpoint))) + (set! *model-max-tokens* (append *model-max-tokens* (list max-tokens))))))) + models-list)))))))) (lambda (key . args) ;; Silently skip endpoints that fail #f))