Fix Scheme implementation: Add GnuTLS support and fix model discovery
- Add guile-gnutls package to Dockerfile for HTTPS support - Fix unbound variables by ensuring proper module imports (rnrs bytevectors, srfi srfi-43) - Fix vector/list handling in model discovery with vector->list conversion - All tests now pass: model discovery, non-streaming chat, and streaming chat work correctly
This commit is contained in:
parent
157078415c
commit
71101019ab
2 changed files with 24 additions and 15 deletions
|
|
@ -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/*
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue