feat: stabilized org-agent two-way communication and UX
- Fixed kernel-to-Emacs communication bridge. - Resolved boot-time crashes in multiple skeletal skills. - Refined Chat skill prompt to eliminate conversational filler. - Updated Emacs UI to automatically clean up status markers. - Synchronized all fixes via Literate Org-mode documents. - Verified physical two-way interaction via simulation.
This commit is contained in:
@@ -4,56 +4,53 @@
|
||||
#+FILETAGS: :llm:provider:gemini:google:psf:
|
||||
|
||||
* Overview
|
||||
The *Gemini Provider Agent* integrates Google's Gemini API as a pluggable System 1 (neural) backend. This skill enables modular updates to the Google backend while maintaining strict architectural alignment with the PSF.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Define the interface for reliable communication with the Google Gemini v1beta API.
|
||||
|
||||
** 2. User Needs
|
||||
- *API Integration:* Implementation of the Gemini `contents.parts` protocol.
|
||||
- *Reliability:* Secure retrieval of endpoints and API keys from the environment.
|
||||
- *Modularity:* Registration under `:gemini-official` for multi-provider support.
|
||||
|
||||
** 3. Success Criteria
|
||||
*** TODO API Authentication via URL Key
|
||||
*** TODO Payload Construction
|
||||
*** TODO Response Parsing Verification
|
||||
The *Gemini Provider Agent* integrates Google's Gemini API as a pluggable System 1 (neural) backend.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Interfaces for executing neural completion requests via Google's generative AI endpoints.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun execute-gemini-v1-request (prompt system-prompt)
|
||||
"Executes a completion request via the Gemini API.")
|
||||
(defun execute-gemini-request (prompt system-prompt)
|
||||
"Executes a completion request via the Google Gemini API.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Request Execution
|
||||
#+begin_src lisp :tangle projects/org-skill-provider-gemini/src/provider-logic.lisp
|
||||
(defun execute-gemini-v1-request (prompt system-prompt)
|
||||
(let ((api-key (uiop:getenv "LLM_API_KEY"))
|
||||
(endpoint (uiop:getenv "LLM_ENDPOINT")))
|
||||
(unless api-key (return-from execute-gemini-v1-request "ERROR: Key missing"))
|
||||
;; Physical API call logic (mocked for refactor)
|
||||
(format nil "Executing Gemini request via ~a" endpoint)))
|
||||
#+begin_src lisp
|
||||
(defun execute-gemini-request (prompt system-prompt)
|
||||
(let* ((auth (org-agent:get-provider-auth :gemini))
|
||||
(api-key (getf auth :api-key))
|
||||
(bearer-token (getf auth :bearer-token))
|
||||
(endpoint (or (getf auth :endpoint)
|
||||
"https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent")))
|
||||
|
||||
(unless (or api-key bearer-token)
|
||||
(return-from execute-gemini-request "(:type :LOG :payload (:text \"Authentication missing for Gemini\"))"))
|
||||
|
||||
(let* ((url (if api-key (format nil "~a?key=~a" endpoint api-key) endpoint))
|
||||
(headers `(("Content-Type" . "application/json")
|
||||
,@(when bearer-token `(("Authorization" . ,(format nil "Bearer ~a" bearer-token))))))
|
||||
(body (cl-json:encode-json-to-string
|
||||
`((contents . ((parts . ((text . ,(format nil "~a~%~%Prompt: ~a" system-prompt prompt))))))))))
|
||||
(handler-case
|
||||
(let* ((response (dex:post url :headers headers :content body))
|
||||
(json (cl-json:decode-json-from-string response)))
|
||||
(cdr (assoc :text (cdr (assoc :parts (car (cdr (assoc :parts (car (cdr (assoc :candidates json)))))))))))
|
||||
(error (c)
|
||||
(format nil "(:type :LOG :payload (:text \"Neural Engine Failure: ~a\"))" c))))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
;; Register with the kernel
|
||||
(org-agent:register-neuro-backend :gemini #'execute-gemini-request)
|
||||
|
||||
(defskill :skill-provider-gemini
|
||||
:priority 100
|
||||
:priority 90
|
||||
:trigger (lambda (context) nil)
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) action))
|
||||
|
||||
Reference in New Issue
Block a user