Cut modules over to Scriptorium prompts

This commit is contained in:
2026-07-05 18:27:07 +00:00
parent f6224dcbee
commit c9fbb331e2
29 changed files with 210 additions and 2597 deletions

View File

@@ -2,9 +2,8 @@
The implemented LLM runtime lives in `internal/framework/llm`. It provides
transport-neutral structured completion contracts, a Scriptorium-backed
production client, an OpenAI-compatible HTTP adapter retained for legacy tests
and helpers, concurrency scheduling, prompt/schema asset registration, schema
registry helpers, and secret redaction.
production client, concurrency scheduling, prompt/schema asset registration,
schema registry helpers, and secret redaction.
## Contract
@@ -15,9 +14,8 @@ CompleteStructured(ctx, request, out) (response, error)
```
The request contains prompt ID/version, profile ID, session ID, prompt input
materials, variables, and legacy rendered-message/schema fields used by modules
that have not yet moved to prompt-asset execution. The caller supplies a pointer
target for decoded structured output.
materials, and variables. The caller supplies a pointer target for decoded
structured output.
Modules that call the LLM own their prompts, schemas, prompt IDs, validators,
and domain-specific interpretation. Provider adapters should not contain
@@ -57,48 +55,6 @@ Generated-output validation failures are returned as Notarius errors. Provider
and runtime errors are wrapped with prompt context and bearer tokens are
redacted from error strings.
## OpenAI-Compatible Adapter
`OpenAICompatibleClient` posts JSON to:
```text
<base_url>/chat/completions
```
It sends:
- `model`
- `messages`
- `response_format.type = "json_schema"`
- `response_format.json_schema.name`
- `response_format.json_schema.strict = true`
- `response_format.json_schema.schema`
If an API key is configured, the adapter sends an `Authorization: Bearer ...`
header.
The adapter accepts assistant content either as a JSON string containing JSON or
as raw JSON content. It then unmarshals that content into the caller-provided
target.
External wire-contract details belong in the
[OpenAI-compatible integration doc](../integrations/openai-compatible.md).
## Retries And Timeouts
The adapter retries:
- provider request failures;
- response read failures;
- HTTP `429`;
- HTTP `5xx`;
- malformed provider envelopes;
- malformed assistant JSON;
- structured-output decode failures.
Non-retryable `4xx` responses are returned without retry. Context cancellation
is respected.
## Scheduler
`Scheduler` bounds concurrent provider calls. It tracks in-flight calls and a