PSF: Mass-regeneration complete. 53/53 high-fidelity blueprints and TDD suites established. Zero-cost Pro bridge active.

This commit is contained in:
2026-04-07 08:58:08 -04:00
parent f4a91ae747
commit 77c0dac025
58 changed files with 2154 additions and 1671 deletions

View File

@@ -25,48 +25,59 @@ Define the interface for reliable communication with the Anthropic Messages API.
*** TODO Model Resolution Loop
*** TODO Response Parsing Verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
* Phase B: Blueprint (PROTOCOL)
** 1. Architectural Intent
Interfaces for executing neural completion requests. Source of truth is the Anthropic API and `$ANTHROPIC_API_KEY`.
** 2. Semantic Interfaces
#+begin_src lisp
(defun execute-anthropic-request (prompt system-prompt)
"Executes a completion request via the Anthropic API.")
The Anthropic Provider Agent will be designed as a stateless service responsible for managing communication with the Anthropic API. It will abstract away the complexities of API authentication, model selection, prompt construction, and response parsing, exposing a simple, functional interface to the broader PSF. The key architectural constraint is reliability and efficient context management. Error handling and API rate limiting must be gracefully managed to prevent cascading failures.
(defun get-anthropic-models ()
"Returns supported models and their context limits.")
#+end_src
** 2. Semantic Interfaces (Lisp Signatures)
* Phase D: Build (Implementation)
*** `anthropic-query`
** Request Execution
#+begin_src lisp :tangle projects/org-skill-provider-anthropic/src/provider-logic.lisp
(defun execute-anthropic-request (prompt system-prompt)
(let ((api-key (uiop:getenv "ANTHROPIC_API_KEY")))
(unless api-key (return-from execute-anthropic-request "ERROR: Key missing"))
(let ((model (get-config-attribute :LLM_MODEL_ANTHROPIC "claude-3-5-sonnet-20240620")))
;; Physical API call logic (mocked for refactor)
(format nil "Executing Anthropic request on ~a" model))))
#+end_src
This function is the primary entry point for interacting with the Anthropic models. It constructs the full prompt (system prompt + user query), sends it to the Anthropic API, and returns the model's response.
** Model Discovery
#+begin_src lisp :tangle projects/org-skill-provider-anthropic/src/provider-logic.lisp
(defun get-anthropic-models ()
'((:id "claude-3-5-sonnet-20240620" :context "200k")
(:id "claude-3-opus-20240229" :context "200k")
(:id "claude-3-haiku-20240307" :context "200k")))
#+end_src
:lisp
(defun anthropic-query (query &key model system-prompt max-tokens temperature top-p stream?)
"Sends a query to the Anthropic API and returns the response.
* Registration
#+begin_src lisp
(defskill :skill-provider-anthropic
:priority 100
:trigger (lambda (context) nil)
:neuro (lambda (context) nil)
:symbolic (lambda (action context) action))
#+end_src
QUERY: The user's question or instruction (string).
MODEL: (Optional) The Claude model to use (string, default 'claude-v1.3').
SYSTEM-PROMPT: (Optional) A system prompt to guide the model (string).
MAX-TOKENS: (Optional) The maximum number of tokens in the response (integer).
TEMPERATURE: (Optional) Sampling temperature (float, 0.0-1.0).
TOP-P: (Optional) Top-p sampling (float, 0.0-1.0).
STREAM?: (Optional) Whether to stream the response (boolean, default nil).
Returns: A string containing the model's generated response, or nil on error."
...)
*** `anthropic-authenticate`
This function handles API key authentication. It retrieves the API key from environment variables or a configuration file.
:lisp
(defun anthropic-authenticate ()
"Authenticates with the Anthropic API, retrieving the API key from the environment or config.
Returns: The API key (string), or nil on failure."
...)
*** `anthropic-model-resolve`
This function resolves a symbolic model name (e.g., 'most-powerful') to a specific Claude model identifier (e.g., 'claude-v1.3-100k').
:lisp
(defun anthropic-model-resolve (model-symbol)
"Resolves a symbolic model name to a specific Anthropic model identifier.
MODEL-SYMBOL: A symbolic name for the model (symbol).
Returns: The Anthropic model identifier (string), or nil if resolution fails."
...)