Add schema selection values and ownership
This commit is contained in:
17
prompts.go
17
prompts.go
@@ -1,6 +1,10 @@
|
||||
package promptkit
|
||||
|
||||
import "go.maximumdirect.net/configkit"
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
// PromptConfig is a presence-aware source input for one prompt. Extends names
|
||||
// a sibling prompt. Nil optional pointers and slices are omitted; non-nil
|
||||
@@ -35,8 +39,9 @@ type PromptCacheControlConfig struct{ Type, TTL *string }
|
||||
|
||||
// PromptOutputConfig supplies optional output contract source fields.
|
||||
type PromptOutputConfig struct {
|
||||
Format, ValidationMode, SchemaPath *string
|
||||
RepairAttempts *int
|
||||
Format, ValidationMode, SchemaPath, SchemaFile *string
|
||||
Schema any
|
||||
RepairAttempts *int
|
||||
}
|
||||
|
||||
// PromptSource creates a labeled ConfigKit mapping in caller order. Nil
|
||||
@@ -118,6 +123,12 @@ func PromptSource(label string, prompts []PromptConfig) configkit.Source {
|
||||
if config.Output.SchemaPath != nil {
|
||||
output["schema_path"] = *config.Output.SchemaPath
|
||||
}
|
||||
if value := reflect.ValueOf(config.Output.Schema); value.IsValid() && !((value.Kind() == reflect.Pointer || value.Kind() == reflect.Map || value.Kind() == reflect.Slice || value.Kind() == reflect.Interface) && value.IsNil()) {
|
||||
output["schema"] = config.Output.Schema
|
||||
}
|
||||
if config.Output.SchemaFile != nil {
|
||||
output["schema_file"] = *config.Output.SchemaFile
|
||||
}
|
||||
if config.Output.RepairAttempts != nil {
|
||||
output["repair_attempts"] = *config.Output.RepairAttempts
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user