Use unified PromptKit sources for execution and preflight
This commit is contained in:
@@ -53,6 +53,18 @@ type LLMProfileRecorder struct {
|
||||
profiles map[string]artifacts.LLMProfileManifest
|
||||
}
|
||||
|
||||
type promptKitClientConfigurationError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (e *promptKitClientConfigurationError) Error() string {
|
||||
return "PromptKit client configuration is invalid or unreadable"
|
||||
}
|
||||
|
||||
func (e *promptKitClientConfigurationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
var _ contracts.StructuredLLMClient = (*PromptKitClient)(nil)
|
||||
var _ contracts.LLMProfileManifestProvider = (*PromptKitClient)(nil)
|
||||
|
||||
@@ -60,29 +72,28 @@ func NewPromptKitClient(cfg PromptKitClientConfig) (*PromptKitClient, error) {
|
||||
if cfg.Assets == nil {
|
||||
return nil, fmt.Errorf("PromptKit client assets must not be nil")
|
||||
}
|
||||
profileSource, profileOptions, err := promptKitProfileSourceEngineOptions(PromptKitProfileSourceConfig{
|
||||
profileSource, sources, options, err := promptKitEngineConfiguration(PromptKitProfileSourceConfig{
|
||||
ProfileDir: cfg.ProfileDir,
|
||||
ProfileFile: cfg.ProfileFile,
|
||||
LocalBackend: cfg.LocalBackend,
|
||||
})
|
||||
}, cfg.Assets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, &promptKitClientConfigurationError{err: err}
|
||||
}
|
||||
options, fallbackProfileDigest, err := cfg.Assets.promptKitOptions()
|
||||
fallbackProfileDigest, err := cfg.Assets.FallbackProfileDigest()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, &promptKitClientConfigurationError{err: err}
|
||||
}
|
||||
options = append(options, profileOptions...)
|
||||
options = append(options, cfg.EngineOptions...)
|
||||
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
ProfileDir: profileSource.ProfileDir,
|
||||
Sources: sources,
|
||||
Timeout: cfg.Timeout,
|
||||
HTTPClient: cfg.HTTPClient,
|
||||
TransientRetries: cfg.TransientRetries,
|
||||
}, options...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create PromptKit engine: %w", err)
|
||||
return nil, &promptKitClientConfigurationError{err: err}
|
||||
}
|
||||
recorder := cfg.Recorder
|
||||
if recorder == nil {
|
||||
|
||||
Reference in New Issue
Block a user