Documentation
¶
Overview ¶
Package structjudge adapts an injected structured-output completion client to Reliquary's judgment contracts.
Structured-output providers force a JSON Schema on their responses, which is exactly what the strict judgment primitives need: a Choice distribution that sums to one, a Score in [0, 100], a Noul verdict from a two-value enum. This adapter owns the per-primitive response schemas, renders each judgment request into one instruction, forwards it to the injected Client, maps the JSON response back, and validates the pair with the judgment package. Transport, credentials, endpoints, retries, and model choice belong entirely to the injected Client; the adapter performs no network, file, or environment I/O and retains no state beyond the client reference.
The motivating client is a multi-provider LLM gateway (for example Wormhole's structured builder), wired with a few lines of caller glue:
type wormholeJudge struct{ w *wormhole.Wormhole }
func (g wormholeJudge) Generate(ctx context.Context, r structjudge.Request) ([]byte, error) {
resp, err := g.w.Structured().Model("…").Prompt(r.Instruction).Schema(r.Schema).Do(ctx)
// … extract the JSON payload from resp …
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrGenerate = errors.New("structjudge adapter: generate")
ErrGenerate reports a client-side generation failure.
var ErrInvalidResponse = errors.New("structjudge adapter: invalid response")
ErrInvalidResponse reports a response that is not valid JSON for the primitive's schema or fails the judgment contract.
var ErrNilClient = errors.New("structjudge adapter: client must not be nil")
ErrNilClient reports construction with a missing client.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter maps judgment primitives onto an injected Client.
func New ¶
New constructs an Adapter over client.
Example ¶
package main
import (
"context"
"fmt"
"github.com/dotcommander/reliquary/adapter/structjudge"
)
type staticStructClient struct{}
func (staticStructClient) Generate(_ context.Context, _ structjudge.Request) ([]byte, error) {
return []byte(`{"selected":"a","distribution":{"a":1.0},"confidence":1.0}`), nil
}
func main() {
judge, err := structjudge.New(staticStructClient{})
fmt.Println(judge != nil, err == nil)
}
Output: true true
func (*Adapter) Ask ¶
Ask renders the noul request into one instruction, generates a schema-forced response, and validates the mapped verdict.