2.2 KiB
2.2 KiB
SKILL: Ollama Provider Agent (Local Backend)
Overview
The Ollama Provider Agent enables the use of local, privacy-preserving LLM models by integrating with a local Ollama instance. This allows the system to remain functional and sovereign even without external internet connectivity, utilizing models like `llama3` for neural reasoning.
The Local Mandate
- Sovereignty: Provide a fallback neural backend that does not rely on third-party cloud providers.
- Performance: Interface with Ollama via its local API (typically over the Docker bridge).
- Simplicity: Focus on standard text generation without complex streaming requirements for the initial implementation.
Symbolic Implementation (The Logic)
The implementation focuses on the local network interaction with the Ollama daemon.
Architectural Intent: Local Request Execution
This function communicates with the Ollama `/api/generate` endpoint. It specifies the model (defaulting to `llama3`) and ensures that the response is captured in a non-streaming format for easier symbolic processing.
(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))