Implement a library profile API and built-in profile docs
This commit is contained in:
19
engine.go
19
engine.go
@@ -58,9 +58,11 @@ type engineOptions struct {
|
||||
llmClient llm.Client
|
||||
promptDefs promptdef.Repository
|
||||
profiles profile.Repository
|
||||
memoryProfiles profile.Repository
|
||||
validator validate.Validator
|
||||
promptSource bool
|
||||
profileSource bool
|
||||
memorySource bool
|
||||
validatorSource bool
|
||||
}
|
||||
|
||||
@@ -127,6 +129,20 @@ func WithProfileFile(path string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithProfiles configures in-memory profiles that take precedence over
|
||||
// configured profile files and built-in profiles.
|
||||
func WithProfiles(profiles ...Profile) Option {
|
||||
return func(options *engineOptions) error {
|
||||
repo, err := newMemoryProfileRepository(profiles)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
options.memoryProfiles = repo
|
||||
options.memorySource = true
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func WithSchemaFS(fsys fs.FS, root string) Option {
|
||||
return func(options *engineOptions) error {
|
||||
if fsys == nil {
|
||||
@@ -178,6 +194,9 @@ func NewEngine(cfg Config, opts ...Option) (*Engine, error) {
|
||||
if options.profileSource {
|
||||
profiles = builtin.NewRepositoryWithPrimary(options.profiles)
|
||||
}
|
||||
if options.memorySource {
|
||||
profiles = profile.NewOverlayRepository(options.memoryProfiles, profiles)
|
||||
}
|
||||
|
||||
validator := options.validator
|
||||
if !options.validatorSource {
|
||||
|
||||
Reference in New Issue
Block a user