Document prompt-owned schemas and finalize migration
This commit is contained in:
@@ -83,20 +83,25 @@ promptInputs, err := promptkit.DirectoryInputs("prompts")
|
||||
if err != nil { return err }
|
||||
profileInputs, err := promptkit.DirectoryInputs("profiles")
|
||||
if err != nil { return err }
|
||||
filesystem := configkit.NewFilesystem("application schemas", os.DirFS("."))
|
||||
schemaInput := configkit.Input{
|
||||
Source: promptkit.SchemaRootSource("application schemas", "schemas"),
|
||||
Filesystem: &configkit.FilesystemContext{FS: &filesystem, Root: ".", BaseDir: "."},
|
||||
}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
Sources: promptkit.ConfigurationSources{Underlays: []configkit.Underlay{
|
||||
{Inputs: promptInputs},
|
||||
{Inputs: profileInputs},
|
||||
{Inputs: []configkit.Input{schemaInput}},
|
||||
}},
|
||||
SchemaDir: "schemas",
|
||||
})
|
||||
```
|
||||
|
||||
For a single highest-priority document, set `Sources.Main` to a
|
||||
`*configkit.Input`; omit it for ordinary layered construction. A single file
|
||||
can use `configkit.File` directly. `PromptSource`, `ProfileSource`, `BackendSource`, and raw
|
||||
`configkit.Mapping` supply programmatic definitions. Schema and runtime
|
||||
collaborator options remain available. Construction validates the final
|
||||
`configkit.Mapping` supply programmatic definitions. Runtime collaborator
|
||||
options remain available. Construction validates the final
|
||||
effective configuration and captures referenced prompt content; construct a
|
||||
new engine to observe configuration edits. See the [constructor GoDoc](../../engine.go)
|
||||
for the exact public contract and the [framework format reference](../formats.md)
|
||||
@@ -705,7 +710,7 @@ corrected automatically:
|
||||
request.Validation = &promptkit.OutputContract{
|
||||
Format: promptkit.FormatJSON,
|
||||
ValidationMode: promptkit.ValidationJSONSchema,
|
||||
SchemaPath: "events.schema.json",
|
||||
Schema: map[string]any{"type": "object"},
|
||||
RepairAttempts: 1,
|
||||
}
|
||||
```
|
||||
@@ -1119,10 +1124,20 @@ secret-handling policies.
|
||||
## Extension Interfaces
|
||||
|
||||
JSON Schema validation and native structured output use a self-contained root
|
||||
document. Internal references are supported; references to other files or
|
||||
network resources fail during preparation. `WithSchemaFile` selects one root
|
||||
file, while `WithSchemaFS` and `SchemaDir` select a root source. Prepared
|
||||
executions retain their captured schema even if the source later changes.
|
||||
document. See [schema selection and resource context](../formats.md#schemas).
|
||||
Prepared executions retain their captured schema even if the source later changes.
|
||||
|
||||
### Migrating Schema Sources
|
||||
|
||||
`Config.SchemaDir`, `WithSchemaFS`, and `WithSchemaFile` have been removed.
|
||||
Supply a context-backed `SchemaRootSource` at the desired ConfigKit layer, as
|
||||
shown above, or declare `schema_root` in application or collection mappings.
|
||||
For a former single-file source, configure `schema_file` relative to its
|
||||
contributing source, or supply its directory as a root and use its basename in
|
||||
`schema_path`. To substitute an unrelated file per request, read and decode it
|
||||
in the caller and supply its value as `OutputContract.Schema`. There is no
|
||||
implicit working-directory root. Public structs gained fields; change any
|
||||
positional struct literals to keyed literals when migrating.
|
||||
|
||||
Inject an [`LLMClient` or `ArtifactReader`](../../types.go) when the built-in
|
||||
behavior does not fit the application. Their GoDoc defines concurrent use,
|
||||
|
||||
Reference in New Issue
Block a user