fix(llm): gptel-magit: non-string responses

Resolves an upstream issue (ragnard/gptel-magit#9) where gptel-magit
requests may return a non-string response, causing a type error. The
solution was adapted from an upstream PR (ragnard/gptel-magit#4).

Ref: ragnard/gptel-magit#9
Ref: ragnard/gptel-magit#4
This commit is contained in:
Henrik Lissner 2026-03-11 22:06:46 -04:00
parent 0ec6255f23
commit b30f5ca6df
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -39,7 +39,20 @@
(if (eq gptel-magit-backend gptel--openrouter)
'(:reasoning (:exclude t :effort "minimal"))
nil)))
(apply fn args))))
(apply fn args)))
;; HACK: Responses from the system/API calls might not be a string, causing
;; type errors.
;; REVIEW: Remove these when ragnard/gptel-magit#9 is resolved OR
;; ragnard/gptel-magit#4 is merged.
(defadvice! +llm--fix-gptel-magit--non-string-responses-a (plist)
:filter-args #'gptel-magit--request
(when-let* ((callback (plist-get plist :callback)))
(cl-callf plist-put plist :callback
(lambda (response info)
(when (stringp response)
(funcall callback response info)))))
plist))
(use-package! ob-gptel