39 lines
1.6 KiB
Org Mode
39 lines
1.6 KiB
Org Mode
#+TITLE - Gemini Provider Skill
|
|
#+AUTHOR - org-agent
|
|
#+SKILL_NAME - skill-provider-gemini
|
|
|
|
This skill registers Google's Gemini as a pluggable System 1 backend, moving the logic from the core to an Org-Native skill.
|
|
|
|
* Backend Implementation
|
|
#+begin_src lisp
|
|
(defun execute-gemini-v1-request (prompt system-prompt)
|
|
"Executes a completion request via the Google Gemini v1beta API."
|
|
(let ((api-key (org-agent::get-env "LLM_API_KEY"))
|
|
(endpoint (org-agent::get-env "LLM_ENDPOINT")))
|
|
(unless api-key
|
|
(return-from execute-gemini-v1-request "(:type :LOG :payload (:text \"Gemini key missing\"))"))
|
|
|
|
(let* ((url (format nil "~a?key=~a" endpoint api-key))
|
|
(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 '(("Content-Type" . "application/json"))
|
|
: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 \"Gemini Failure - ~a\"))" c))))))
|
|
|
|
;; Register the official backend
|
|
(org-agent:register-neuro-backend :gemini-official #'execute-gemini-v1-request)
|
|
#+end_src
|
|
|
|
* Registration
|
|
#+begin_src lisp
|
|
(defskill :skill-provider-gemini
|
|
:priority 100
|
|
:trigger (lambda (context) nil)
|
|
:neuro (lambda (context) nil)
|
|
:symbolic (lambda (action context) action))
|
|
#+end_src |