From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.dismail.de ( [192.168.2.1]) by mugam.systemreboot.net (OpenSMTPD) with ESMTPS id a738e64e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 20 Jul 2026 14:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=20190914; bh=/yp56PV+1C/ GYbAzBu2XizN1+HA4IJ0kPxZkiD9wx7s=; h=references:in-reply-to:date: subject:cc:to:from; d=dismail.de; b=YbrXNVvrRAoVtE8mdJYTYYPdY7Hcp1kG8S aTxgRsw1WSVbNmaKghXTSOGvOb7rfU9yTRueV8+lJoydweGJkPAsa4f42wUadwmOhGYwm2 g52Gd0ncy8Z5LMjuEDKLcygdjAmp1Gizp+w29NhErO+S7MOrQEP9YytqMUirP8BpfH2hNg 9+Xb57Z1gZ3t14RVZ/elWi0+JAHZKIN2dNUPdXjUPfBV4TTHSgO4JHktWPy3ki4Fowbkeq 8kIjEyaSpBQ4+M1ojVqk34VjskvYILlRAl+AUYKHD9pfU/jWd1Q6zMVYo2N3ougcd2g7ko z6KHLLKn3W8Pk2Gs/T8ciKYv88nw== Received: from smtp1.dismail.de ( [10.240.26.11]) by mx1.dismail.de (OpenSMTPD) with ESMTP id 6c97fa5b for ; Mon, 20 Jul 2026 16:26:30 +0200 (CEST) Received: from smtp1.dismail.de (localhost [127.0.0.1]) by smtp1.dismail.de (OpenSMTPD) with ESMTP id 72a911ff for ; Mon, 20 Jul 2026 16:26:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=20190914; bh=/yp56PV+1C/ GYbAzBu2XizN1+HA4IJ0kPxZkiD9wx7s=; h=references:in-reply-to:date: subject:cc:to:from; d=dismail.de; b=YbrXNVvrRAoVtE8mdJYTYYPdY7Hcp1kG8S aTxgRsw1WSVbNmaKghXTSOGvOb7rfU9yTRueV8+lJoydweGJkPAsa4f42wUadwmOhGYwm2 g52Gd0ncy8Z5LMjuEDKLcygdjAmp1Gizp+w29NhErO+S7MOrQEP9YytqMUirP8BpfH2hNg 9+Xb57Z1gZ3t14RVZ/elWi0+JAHZKIN2dNUPdXjUPfBV4TTHSgO4JHktWPy3ki4Fowbkeq 8kIjEyaSpBQ4+M1ojVqk34VjskvYILlRAl+AUYKHD9pfU/jWd1Q6zMVYo2N3ougcd2g7ko z6KHLLKn3W8Pk2Gs/T8ciKYv88nw== Received: by dismail.de (OpenSMTPD) with ESMTPSA id 51420914 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 20 Jul 2026 16:26:28 +0200 (CEST) From: jgart To: kaagum@systemreboot.net Cc: jgart Subject: [PATCH] Remove #:streaming? #t from HTTP requests. Date: Mon, 20 Jul 2026 15:21:50 +0100 Message-ID: <20260720142610.1193079-2-jgart@dismail.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720142610.1193079-1-jgart@dismail.de> References: <20260720142610.1193079-1-jgart@dismail.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The #:streaming? #t option bypasses Guile's automatic content-encoding decompression and chunked transfer decoding. This caused json->scm to receive raw gzip-compressed bytes or trailing chunk framing data, resulting in a json-invalid exception. Without #:streaming? #t, http-request returns a clean bytevector that we decode to a UTF-8 string and parse with json-string->scm. The accept-encoding: identity workaround in openai-models is no longer needed since Guile now handles gzip decompression automatically. --- kaagum/openai.scm | 5 +++-- kaagum/web.scm | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kaagum/openai.scm b/kaagum/openai.scm index 436a755..3334f3e 100644 --- a/kaagum/openai.scm +++ b/kaagum/openai.scm @@ -65,5 +65,6 @@ in @code{openai-query}." (focus (key-ref "context_length") tree)))) (vector->list (focus (key-ref "data") (json-get (uri-join base-uri "/v1/models") - #:headers `((authorization - . ,(string-append "Bearer " api-key)))))))) + #:headers + `((authorization + . ,(string-append "Bearer " api-key)))))))) diff --git a/kaagum/web.scm b/kaagum/web.scm index ce29bdd..3454b4b 100644 --- a/kaagum/web.scm +++ b/kaagum/web.scm @@ -23,6 +23,7 @@ #:use-module (web http) #:use-module (web response) #:use-module (json) + #:use-module (rnrs bytevectors) #:export (uri-join json-request json-get @@ -44,14 +45,10 @@ additional @var{headers}. Return JSON response." (http-request url #:method method #:headers headers - #:body body - #:streaming? #t))) - ;; Guile does not consider application/json responses as textual, and does - ;; not automatically set the port encoding to UTF-8. - (set-port-encoding! body "UTF-8") + #:body body))) (case (quotient (response-code response) 100) - ((2) (json->scm body)) + ((2) (json-string->scm (utf8->string body))) ((4) (raise-exception (condition (make-violation) -- 2.55.0