Files
memex/notes/skill-provider-ollama.org

1.3 KiB

#+TITLE - Ollama Provider Skill (Local) #+AUTHOR - org-agent #+SKILL_NAME - skill-provider-ollama

This skill registers a local Ollama instance as a pluggable System 1 backend.

Backend Implementation

(defun execute-ollama-request (prompt system-prompt)
  "Executes a completion request via local Ollama."
  (let* ((url "http://host.docker.internal:11434/api/generate")
         (body (cl-json:encode-json-to-string
                `((model . "llama3")
                  (system . ,system-prompt)
                  (prompt . ,prompt)
                  (stream . nil)))))
    (handler-case
        (let* ((response (dex:post url
                                   :headers '(("Content-Type" . "application/json"))
                                   :content body))
               (json (cl-json:decode-json-from-string response)))
          (cdr (assoc :response json)))
      (error (c)
        (format nil "(:type :LOG :payload (:text \"Ollama Failure - ~a\"))" c)))))

;; Register the backend
(org-agent:register-neuro-backend :ollama #'execute-ollama-request)

Registration

(defskill :skill-provider-ollama
  :priority 100
  :trigger (lambda (context) nil)
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))