Construct prompt engines from shared configuration
This commit is contained in:
@@ -13,6 +13,17 @@ import (
|
||||
pk "go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
// AssetError reports a failure to access an embedded application resource.
|
||||
type AssetError struct{ Err error }
|
||||
|
||||
func (e *AssetError) Error() string { return e.Err.Error() }
|
||||
func (e *AssetError) Unwrap() error { return e.Err }
|
||||
|
||||
func IsAssetError(err error) bool {
|
||||
var target *AssetError
|
||||
return errors.As(err, &target)
|
||||
}
|
||||
|
||||
// Config combines Audita's root settings with native PromptKit settings.
|
||||
type Config struct {
|
||||
Application config.Config `yaml:",inline"`
|
||||
@@ -74,7 +85,7 @@ func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.O
|
||||
input.Source = prepared
|
||||
embedded, err := pk.FilesystemInputs("Audita embedded prompts", prompts.Filesystem(), prompts.AssetRoot)
|
||||
if err != nil {
|
||||
return nil, report, fmt.Errorf("discover embedded prompts: %w", err)
|
||||
return nil, report, &AssetError{Err: fmt.Errorf("discover embedded prompts: %w", err)}
|
||||
}
|
||||
for i := range embedded {
|
||||
embedded[i].Destination = ck.Keys("promptkit")
|
||||
|
||||
Reference in New Issue
Block a user