Use unified PromptKit sources for execution and preflight
This commit is contained in:
@@ -254,6 +254,11 @@ Prompt size: dependency/notices and one source-construction boundary.
|
|||||||
|
|
||||||
## Stage 3 — Switch Runtime And Preflight To Shared Engine Configuration
|
## Stage 3 — Switch Runtime And Preflight To Shared Engine Configuration
|
||||||
|
|
||||||
|
> Completion: complete. The native command build passes. Test compilation is
|
||||||
|
> still blocked by removed PromptKit setup APIs and legacy fixtures in
|
||||||
|
> `asset_registry_test.go`, `promptkit_client_test.go`, and
|
||||||
|
> `production_contract_test.go`; the fixture work remains in Stages 4–5.
|
||||||
|
|
||||||
Goal: restore application compilation and consistent sources.
|
Goal: restore application compilation and consistent sources.
|
||||||
|
|
||||||
Inspect `NewPromptKitClient`, `NewPromptKitProfileInspector`,
|
Inspect `NewPromptKitClient`, `NewPromptKitProfileInspector`,
|
||||||
|
|||||||
@@ -53,6 +53,18 @@ type LLMProfileRecorder struct {
|
|||||||
profiles map[string]artifacts.LLMProfileManifest
|
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.StructuredLLMClient = (*PromptKitClient)(nil)
|
||||||
var _ contracts.LLMProfileManifestProvider = (*PromptKitClient)(nil)
|
var _ contracts.LLMProfileManifestProvider = (*PromptKitClient)(nil)
|
||||||
|
|
||||||
@@ -60,29 +72,28 @@ func NewPromptKitClient(cfg PromptKitClientConfig) (*PromptKitClient, error) {
|
|||||||
if cfg.Assets == nil {
|
if cfg.Assets == nil {
|
||||||
return nil, fmt.Errorf("PromptKit client assets must not be 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,
|
ProfileDir: cfg.ProfileDir,
|
||||||
ProfileFile: cfg.ProfileFile,
|
ProfileFile: cfg.ProfileFile,
|
||||||
LocalBackend: cfg.LocalBackend,
|
LocalBackend: cfg.LocalBackend,
|
||||||
})
|
}, cfg.Assets)
|
||||||
if err != nil {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &promptKitClientConfigurationError{err: err}
|
||||||
}
|
}
|
||||||
options = append(options, profileOptions...)
|
|
||||||
options = append(options, cfg.EngineOptions...)
|
options = append(options, cfg.EngineOptions...)
|
||||||
|
|
||||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||||
ProfileDir: profileSource.ProfileDir,
|
Sources: sources,
|
||||||
Timeout: cfg.Timeout,
|
Timeout: cfg.Timeout,
|
||||||
HTTPClient: cfg.HTTPClient,
|
HTTPClient: cfg.HTTPClient,
|
||||||
TransientRetries: cfg.TransientRetries,
|
TransientRetries: cfg.TransientRetries,
|
||||||
}, options...)
|
}, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create PromptKit engine: %w", err)
|
return nil, &promptKitClientConfigurationError{err: err}
|
||||||
}
|
}
|
||||||
recorder := cfg.Recorder
|
recorder := cfg.Recorder
|
||||||
if recorder == nil {
|
if recorder == nil {
|
||||||
|
|||||||
@@ -75,22 +75,12 @@ func (e *promptKitProfileConfigurationError) Unwrap() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPromptKitProfileInspector(cfg PromptKitProfileInspectorConfig) (*PromptKitProfileInspector, error) {
|
func NewPromptKitProfileInspector(cfg PromptKitProfileInspectorConfig) (*PromptKitProfileInspector, error) {
|
||||||
source, options, err := promptKitProfileSourceEngineOptions(cfg.Source)
|
_, sources, options, err := promptKitEngineConfiguration(cfg.Source, cfg.Assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &promptKitProfileConfigurationError{err: err}
|
||||||
}
|
|
||||||
if cfg.Assets != nil {
|
|
||||||
fallbackOption, hasFallback, err := cfg.Assets.promptKitFallbackProfileOption()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if hasFallback {
|
|
||||||
options = append(options, fallbackOption)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||||
PromptDir: ".",
|
Sources: sources,
|
||||||
ProfileDir: source.ProfileDir,
|
|
||||||
}, options...)
|
}, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &promptKitProfileConfigurationError{err: err}
|
return nil, &promptKitProfileConfigurationError{err: err}
|
||||||
@@ -122,6 +112,25 @@ func (i *PromptKitProfileInspector) InspectProfile(ctx context.Context, profileI
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func promptKitEngineConfiguration(cfg PromptKitProfileSourceConfig, assets *AssetRegistry) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, []promptkit.Option, error) {
|
||||||
|
profileSource, profileSources, err := promptKitProfileConfigurationSources(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, nil, err
|
||||||
|
}
|
||||||
|
sources := promptkit.ConfigurationSources{}
|
||||||
|
var options []promptkit.Option
|
||||||
|
if assets != nil {
|
||||||
|
maintainedSources, maintainedOptions, err := assets.PromptKitConfigurationSources()
|
||||||
|
if err != nil {
|
||||||
|
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, nil, err
|
||||||
|
}
|
||||||
|
sources = maintainedSources
|
||||||
|
options = append(options, maintainedOptions...)
|
||||||
|
}
|
||||||
|
sources.Underlays = append(sources.Underlays, profileSources.Underlays...)
|
||||||
|
return profileSource, sources, options, nil
|
||||||
|
}
|
||||||
|
|
||||||
func promptKitProfileConfigurationSources(cfg PromptKitProfileSourceConfig) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, error) {
|
func promptKitProfileConfigurationSources(cfg PromptKitProfileSourceConfig) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, error) {
|
||||||
source := PromptKitProfileSourceConfig{
|
source := PromptKitProfileSourceConfig{
|
||||||
ProfileDir: strings.TrimSpace(cfg.ProfileDir),
|
ProfileDir: strings.TrimSpace(cfg.ProfileDir),
|
||||||
|
|||||||
Reference in New Issue
Block a user