provider: revert to simple dex:post (API key confirmed valid)
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s

This commit is contained in:
2026-05-04 20:41:46 -04:00
parent d8929aeb24
commit d782f58291
2 changed files with 22 additions and 52 deletions

View File

@@ -52,32 +52,17 @@
(messages . (( (role . "system") (content . ,system-prompt) ) (messages . (( (role . "system") (content . ,system-prompt) )
( (role . "user") (content . ,prompt) ))))))) ( (role . "user") (content . ,prompt) )))))))
(handler-case (handler-case
(let* ((result nil) (let* ((response (dex:post url :headers headers :content body
(lock (bt:make-lock "llm-lock")) :connect-timeout (min 10 timeout)
(cvar (bt:make-condition-variable)) :read-timeout (max 10 (- timeout 5))))
(thread (bt:make-thread (json (cl-json:decode-json-from-string response))
(lambda () (choices (cdr (assoc :choices json)))
(unwind-protect (first-choice (car choices))
(handler-case (message (cdr (assoc :message first-choice)))
(let* ((response (dex:post url :headers headers :content body (content (cdr (assoc :content message))))
:connect-timeout (min 10 timeout) (if content
:read-timeout (max 10 (- timeout 5)))) (list :status :success :content content)
(json (cl-json:decode-json-from-string response)) (list :status :error :message (format nil "~a: No content" provider))))
(choices (cdr (assoc :choices json)))
(first-choice (car choices))
(message (cdr (assoc :message first-choice)))
(content (cdr (assoc :content message))))
(setf result (list :status :success :content content)))
(error (c)
(setf result (list :status :error :message (format nil "~a Error: ~a" provider c)))))
(bt:with-lock-held (lock)
(bt:condition-notify cvar))))
:name (format nil "llm-~a" provider))))
(bt:with-lock-held (lock)
(unless result
(bt:condition-wait cvar lock :timeout timeout)))
(or result
(list :status :error :message (format nil "~a: Request timed out after ~d seconds" provider timeout))))
(error (c) (error (c)
(list :status :error :message (format nil "~a Failure: ~a" provider c)))))) (list :status :error :message (format nil "~a Failure: ~a" provider c))))))

View File

@@ -80,32 +80,17 @@ Providers register themselves at boot. No API key? That provider doesn't registe
(messages . (( (role . "system") (content . ,system-prompt) ) (messages . (( (role . "system") (content . ,system-prompt) )
( (role . "user") (content . ,prompt) ))))))) ( (role . "user") (content . ,prompt) )))))))
(handler-case (handler-case
(let* ((result nil) (let* ((response (dex:post url :headers headers :content body
(lock (bt:make-lock "llm-lock")) :connect-timeout (min 10 timeout)
(cvar (bt:make-condition-variable)) :read-timeout (max 10 (- timeout 5))))
(thread (bt:make-thread (json (cl-json:decode-json-from-string response))
(lambda () (choices (cdr (assoc :choices json)))
(unwind-protect (first-choice (car choices))
(handler-case (message (cdr (assoc :message first-choice)))
(let* ((response (dex:post url :headers headers :content body (content (cdr (assoc :content message))))
:connect-timeout (min 10 timeout) (if content
:read-timeout (max 10 (- timeout 5)))) (list :status :success :content content)
(json (cl-json:decode-json-from-string response)) (list :status :error :message (format nil "~a: No content" provider))))
(choices (cdr (assoc :choices json)))
(first-choice (car choices))
(message (cdr (assoc :message first-choice)))
(content (cdr (assoc :content message))))
(setf result (list :status :success :content content)))
(error (c)
(setf result (list :status :error :message (format nil "~a Error: ~a" provider c)))))
(bt:with-lock-held (lock)
(bt:condition-notify cvar))))
:name (format nil "llm-~a" provider))))
(bt:with-lock-held (lock)
(unless result
(bt:condition-wait cvar lock :timeout timeout)))
(or result
(list :status :error :message (format nil "~a: Request timed out after ~d seconds" provider timeout))))
(error (c) (error (c)
(list :status :error :message (format nil "~a Failure: ~a" provider c)))))) (list :status :error :message (format nil "~a Failure: ~a" provider c))))))
#+end_src #+end_src