Architectural Upgrade 2026-03-30: Modular Emacs, org-gtd v4.0, and PSF Phase 1

This commit is contained in:
2026-03-30 21:16:05 -04:00
parent 4652163b7b
commit 5a9129132e
321 changed files with 151080 additions and 112599 deletions

View File

@@ -0,0 +1,72 @@
#+TITLE: SKILL: OpenAI Provider Agent (GPT Backend)
#+ID: skill-provider-openai-agent
#+STARTUP: content
* Overview
The **OpenAI Provider Agent** integrates OpenAI's GPT family of models as a pluggable System 1 (neural) backend for the Neurosymbolic Kernel. It provides the system with industry-standard language processing capabilities, enabling high-fidelity reasoning and content generation.
* The Provider Mandate
1. **Compatibility:** Implement the OpenAI Chat Completions API protocol.
2. **Reliability:** Ensure robust credential management via the system environment.
3. **Optimized Inference:** Support configurable temperature and model selection (e.g., GPT-4o, GPT-4 Turbo) to balance cost and intelligence.
4. **Resilience:** Gracefully handle API timeouts and errors, providing clear diagnostics to the kernel.
* Symbolic Implementation (The Logic)
The implementation focuses on the secure transmission of prompts to OpenAI's infrastructure.
** Architectural Intent: OpenAI Request Execution
This function handles the authenticated POST request to OpenAI. It dynamically resolves the preferred model from the environment configuration and ensures that the system prompt and user prompt are correctly framed for the chat completion interface.
#+begin_src lisp
(defun execute-openai-request (prompt system-prompt)
"Executes a completion request via the OpenAI API."
(let ((api-key (org-agent::get-env "OPENAI_API_KEY"))
(config-pkg (find-package :org-agent.skills.skill-environment-config)))
(unless api-key
(return-from execute-openai-request "(:type :LOG :payload (:text \"OpenAI key missing\"))"))
(let* ((get-config-fn (when config-pkg (find-symbol "GET-CONFIG-ATTRIBUTE" config-pkg)))
(model (if (and get-config-fn (fboundp get-config-fn))
(funcall get-config-fn :LLM_MODEL_OPENAI "gpt-4-turbo-preview")
"gpt-4-turbo-preview"))
(url "https://api.openai.com/v1/chat/completions")
(body (cl-json:encode-json-to-string
`((model . ,model)
(messages . (((role . "system") (content . ,system-prompt))
((role . "user") (content . ,prompt))))
(temperature . 0.2)))))
(handler-case
(let* ((response (dex:post url
:headers `(("Content-Type" . "application/json")
("Authorization" . ,(format nil "Bearer ~a" api-key)))
:content body))
(json (cl-json:decode-json-from-string response)))
;; Extract content from OpenAI response structure
(cdr (assoc :content (cdr (assoc :message (car (cdr (assoc :choices json))))))))
(error (c)
(format nil "(:type :LOG :payload (:text \"OpenAI Failure (~a) - ~a\"))" model c))))))
;; Register the backend upon skill load
(org-agent:register-neuro-backend :openai #'execute-openai-request)
#+end_src
** Architectural Intent: Model Discovery
Exposes a curated list of supported OpenAI models and their context window specifications for system-wide introspection.
#+begin_src lisp
(defun get-available-models ()
"Returns the list of LLM models supported by this provider."
'((:id "gpt-4-turbo-preview" :context "128k")
(:id "gpt-4o" :context "128k")
(:id "gpt-4" :context "8k")
(:id "gpt-3.5-turbo" :context "16k")))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-provider-openai
:priority 100 ; Providers are foundational
:trigger (lambda (context) nil) ; No cognitive trigger
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))
#+end_src