Add engine-scoped backend registration

This commit is contained in:
2026-07-29 17:15:51 +00:00
parent 810f80e7c9
commit ae210b3c26
6 changed files with 318 additions and 9 deletions

View File

@@ -97,6 +97,32 @@ For programmatic profiles,
[`OpenAICompatibleProfile`](../../profiles.go) converts ordinary
OpenAI-compatible settings into a value accepted by `WithProfiles`.
### Register A Custom Backend
Register a reusable OpenAI-compatible connection once, then select it from a
profile:
```go
engine, err := promptkit.NewEngine(promptkit.Config{
PromptDir: "prompts",
},
promptkit.WithBackend(promptkit.Backend{
ID: "local",
Endpoint: "http://localhost:8000/v1",
APIKeyEnv: "LOCAL_LLM_API_KEY",
}),
promptkit.WithProfiles(promptkit.Profile{
ID: "local-summary",
BackendID: "local",
Model: "example-model",
}),
)
```
Registrations belong to one engine and custom IDs cannot replace built-ins.
The [`Backend` and `WithBackend` GoDoc](../../backends.go) defines validation,
copying, uniqueness, and request-default behavior.
## Credentials
File-backed profiles name an environment variable; in-memory profiles can

View File

@@ -369,6 +369,8 @@ Do not duplicate every profile-parser validation case at the engine boundary.
## Stage 3 — Consumer Registration
**Status:** Complete.
### Goal
Expose the engine-scoped extension point for additional unique