Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
EXECUTE-LLM-REQUEST → GATEWAY-LLM-REQUEST (the actual defined function)
44 lines
1.9 KiB
Common Lisp
44 lines
1.9 KiB
Common Lisp
(defun gateway-llm-request (&key prompt system-prompt (provider :ollama) model)
|
|
"Central dispatcher for LLM requests."
|
|
(let ((backend (gethash provider *probabilistic-backends*)))
|
|
(if backend
|
|
(handler-case
|
|
(funcall backend prompt system-prompt :model model)
|
|
(error (c)
|
|
(list :status :error :message (format nil "~a Failure: ~a" provider c))))
|
|
(list :status :error :message (format nil "Provider ~a not registered" provider)))))
|
|
|
|
(defskill :passepartout-gateway-llm
|
|
:priority 100
|
|
:trigger (lambda (ctx) (getf ctx :user-input))
|
|
:deterministic (lambda (action ctx) (declare (ignore ctx)) action))
|
|
|
|
(eval-when (:compile-toplevel :load-toplevel :execute)
|
|
(ql:quickload :fiveam :silent t))
|
|
|
|
(defpackage :passepartout-llm-gateway-tests
|
|
(:use :cl :passepartout)
|
|
(:export #:llm-gateway-suite))
|
|
|
|
(in-package :passepartout-llm-gateway-tests)
|
|
|
|
(fiveam:def-suite llm-gateway-suite :description "Tests for the LLM Gateway skill")
|
|
(fiveam:in-suite llm-gateway-suite)
|
|
|
|
(fiveam:test test-llm-gateway-timeout
|
|
"Tier 2 Chaos: Verify that LLM Gateway handles connection failures gracefully."
|
|
(let ((old-host (uiop:getenv "OLLAMA_HOST")))
|
|
(unwind-protect
|
|
(progn
|
|
(setf (uiop:getenv "OLLAMA_HOST") "localhost:1")
|
|
(let ((fn (or (find-symbol "GATEWAY-LLM-REQUEST" :passepartout.gateway-llm)
|
|
(find-symbol "GATEWAY-LLM-REQUEST" :passepartout))))
|
|
(if fn
|
|
(let ((result (funcall fn :prompt "hello" :provider :ollama)))
|
|
(fiveam:is (eq (getf result :status) :error))
|
|
(fiveam:is (uiop:string-prefix-p "Ollama Failure" (getf result :message))))
|
|
(fiveam:fail "Could not find EXECUTE-LLM-REQUEST symbol"))))
|
|
(if old-host
|
|
(setf (uiop:getenv "OLLAMA_HOST") old-host)
|
|
(sb-posix:unsetenv "OLLAMA_HOST")))))
|