Complete pipeline preflight verification
This commit is contained in:
@@ -35,6 +35,15 @@ type Targets struct {
|
||||
Access []AccessTarget
|
||||
}
|
||||
|
||||
// TargetError identifies the binding whose initial target could not be selected.
|
||||
type TargetError struct {
|
||||
Scope BindingScope
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (err *TargetError) Error() string { return err.Cause.Error() }
|
||||
func (err *TargetError) Unwrap() error { return err.Cause }
|
||||
|
||||
// DiscoverTargets identifies initial request targets without invoking providers.
|
||||
func DiscoverTargets(ctx context.Context, resolved pipeline.ResolvedPipeline, catalog pipeline.ModuleCatalog, engine *promptkit.Engine) (Targets, error) {
|
||||
var targets Targets
|
||||
@@ -46,7 +55,12 @@ func DiscoverTargets(ctx context.Context, resolved pipeline.ResolvedPipeline, ca
|
||||
}
|
||||
profiles := make(map[string]int)
|
||||
access := make(map[string]int)
|
||||
add := func(scope BindingScope, class contracts.ExecutionClass, profile string, prompts []string) error {
|
||||
add := func(scope BindingScope, class contracts.ExecutionClass, profile string, prompts []string) (failure error) {
|
||||
defer func() {
|
||||
if failure != nil {
|
||||
failure = &TargetError{Scope: scope, Cause: failure}
|
||||
}
|
||||
}()
|
||||
if class != contracts.ExecutionClassLLMBacked {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -69,6 +69,11 @@ prompts:
|
||||
resolved.Chunk.LLMProfile = "missing"
|
||||
if _, err := DiscoverTargets(context.Background(), resolved, catalog, engine); !errors.Is(err, promptkit.ErrProfileNotFound) {
|
||||
t.Fatalf("missing profile cause = %v", err)
|
||||
} else {
|
||||
var targetErr *TargetError
|
||||
if !errors.As(err, &targetErr) || targetErr.Scope.Module != "chunk" {
|
||||
t.Fatalf("missing profile binding scope = %v", err)
|
||||
}
|
||||
}
|
||||
resolved.Chunk.LLMProfile = ""
|
||||
resolved.Chunk.Module = "dynamic"
|
||||
|
||||
Reference in New Issue
Block a user