Identify built-in generation preparation failures
This commit is contained in:
29
preparation_error_contract_test.go
Normal file
29
preparation_error_contract_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package promptkit_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestBuiltInPreparationFailureIsInvalidRequestWithoutDispatch(t *testing.T) {
|
||||
calls := 0
|
||||
cfg := simpleConfig("hello")
|
||||
cfg.HTTPClient = &http.Client{Transport: roundTripFunc(func(*http.Request) (*http.Response, error) { calls++; return nil, errors.New("unexpected dispatch") })}
|
||||
engine, err := promptkit.NewEngine(cfg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
override := &promptkit.ExecutionTargetOverride{ExtraParams: map[string]any{"model": "reserved"}}
|
||||
_, err = engine.Run(context.Background(), promptkit.RunRequest{PromptID: "prompt", Execution: override})
|
||||
if !errors.Is(err, promptkit.ErrInvalidRequest) || calls != 0 {
|
||||
t.Fatalf("run error = %v, calls = %d", err, calls)
|
||||
}
|
||||
report, err := engine.SmokeTest(context.Background(), promptkit.SmokeTestRequest{Kind: promptkit.SmokeTestTextInference, ProfileID: "profile", Execution: override})
|
||||
if !errors.Is(err, promptkit.ErrInvalidRequest) || report != nil || calls != 0 {
|
||||
t.Fatalf("smoke = %+v, %v, calls = %d", report, err, calls)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user