Correct artifact file and empty input handling
This commit is contained in:
@@ -1049,6 +1049,59 @@ func TestArtifactReaderReceivesPublicReferenceAndPreparesArtifact(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrepareAcceptsExplicitEmptyInlineInputs(t *testing.T) {
|
||||
promptSource := fstest.MapFS{
|
||||
"prompt.yaml": &fstest.MapFile{Data: []byte(`id: empty-inline
|
||||
version: "1"
|
||||
default_profile: profile
|
||||
inputs:
|
||||
- name: transcript
|
||||
required: true
|
||||
session_id: 'session-{{input "transcript"}}'
|
||||
messages:
|
||||
- role: user
|
||||
content: 'before{{input "transcript"}}after'
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
`)},
|
||||
}
|
||||
engine, err := promptkit.NewEngine(
|
||||
promptkit.Config{},
|
||||
promptkit.WithPromptFS(promptSource, "."),
|
||||
promptkit.WithProfiles(promptkit.Profile{
|
||||
ID: "profile", Endpoint: "http://example.test/v1", Model: "model",
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("construct engine: %v", err)
|
||||
}
|
||||
|
||||
for name, ref := range map[string]promptkit.ArtifactRef{
|
||||
"without URI": promptkit.Inline(""),
|
||||
"with URI": promptkit.InlineWithURI("memory://empty", ""),
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{
|
||||
PromptID: "empty-inline",
|
||||
Inputs: map[string]promptkit.ArtifactRef{"transcript": ref},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("prepare empty input: %v", err)
|
||||
}
|
||||
if prepared.SessionID != "session-" {
|
||||
t.Fatalf("session ID = %q, want session-", prepared.SessionID)
|
||||
}
|
||||
if len(prepared.Messages) != 1 || prepared.Messages[0].Content != "beforeafter" {
|
||||
t.Fatalf("messages = %#v, want empty input rendered between markers", prepared.Messages)
|
||||
}
|
||||
if prepared.InputHashes["transcript"] == "" {
|
||||
t.Fatalf("empty input did not retain an equality value: %#v", prepared.InputHashes)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestArtifactReaderFailuresPreserveArtifactLoadErrors(t *testing.T) {
|
||||
readerErr := errors.New("artifact reader failed")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user