Files
memex/system/skills/org-skill-provider-ollama.org

49 lines
2.2 KiB
Org Mode

#+TITLE: SKILL: Ollama Provider Agent (Local Backend)
#+ID: skill-provider-ollama-agent
#+STARTUP: content
* 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
1. **Sovereignty:** Provide a fallback neural backend that does not rely on third-party cloud providers.
2. **Performance:** Interface with Ollama via its local API (typically over the Docker bridge).
3. **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.
#+begin_src lisp
(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)
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-provider-ollama
:priority 100
:trigger (lambda (context) nil)
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))
#+end_src