Migrate prompt fixtures to direct definitions
This commit is contained in:
@@ -19,31 +19,32 @@ import (
|
||||
|
||||
const adapterPrompt = `prompts:
|
||||
briefing:
|
||||
"1":
|
||||
default_profile: default
|
||||
inputs:
|
||||
- name: topic
|
||||
required: true
|
||||
content_type: text/plain
|
||||
description: "Topic"
|
||||
- name: audience
|
||||
required: false
|
||||
content_type: text/plain
|
||||
description: ""
|
||||
messages:
|
||||
- role: user
|
||||
content: "Hello"
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
version: "1"
|
||||
default_profile: default
|
||||
inputs:
|
||||
- name: topic
|
||||
required: true
|
||||
content_type: text/plain
|
||||
description: "Topic"
|
||||
- name: audience
|
||||
required: false
|
||||
content_type: text/plain
|
||||
description: ""
|
||||
messages:
|
||||
- role: user
|
||||
content: "Hello"
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
empty:
|
||||
"1":
|
||||
messages:
|
||||
- role: user
|
||||
content: "Empty inputs"
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
version: "1"
|
||||
default_profile: default
|
||||
messages:
|
||||
- role: user
|
||||
content: "Empty inputs"
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
backends:
|
||||
local:
|
||||
endpoint: "https://example.invalid/v1"
|
||||
@@ -68,15 +69,15 @@ profiles:
|
||||
|
||||
const adapterRequirementsPrompt = `prompts:
|
||||
briefing:
|
||||
"1":
|
||||
default_profile: default
|
||||
session_id: '{{input "session-only"}} {{.session_variable}}'
|
||||
messages:
|
||||
- role: user
|
||||
content: '{{if eq .audience "internal"}}{{input "internal-notes"}}{{else}}{{input "public-notes"}}{{end}} {{.audience}}'
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
version: "1"
|
||||
default_profile: default
|
||||
session_id: '{{input "session-only"}} {{.session_variable}}'
|
||||
messages:
|
||||
- role: user
|
||||
content: '{{if eq .audience "internal"}}{{input "internal-notes"}}{{else}}{{input "public-notes"}}{{end}} {{.audience}}'
|
||||
output:
|
||||
format: text
|
||||
validation_mode: none
|
||||
backends:
|
||||
local:
|
||||
endpoint: "https://example.invalid/v1"
|
||||
@@ -319,22 +320,18 @@ func TestFromEnginePassesRequestsAndRetainsNilLoaderIssue(t *testing.T) {
|
||||
return engine, nil
|
||||
})
|
||||
selection := ckconfig.Selection{Overlay: commandkit.Supplied[string]{Value: "overlay.yml", Set: true}}
|
||||
version := commandkit.Supplied[string]{Value: "1", Set: true}
|
||||
prompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing", Version: version}, wantInput, wantState)
|
||||
if err != nil || prompt.Value == nil || prompt.Value.PromptID != "briefing" || prompt.Value.PromptVersion != "1" || loaderCalls != 1 {
|
||||
prompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
||||
if err != nil || prompt.Value == nil || prompt.Value.PromptID != "briefing" || prompt.Value.PromptVersion == nil || *prompt.Value.PromptVersion != "1" || loaderCalls != 1 {
|
||||
t.Fatalf("prompt inspection = (%#v, %v), calls=%d", prompt, err, loaderCalls)
|
||||
}
|
||||
defaultPrompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
||||
if err != nil || defaultPrompt.Value == nil || defaultPrompt.Value.PromptVersion != "1" || loaderCalls != 2 {
|
||||
t.Fatalf("empty version default = (%#v, %v), calls=%d", defaultPrompt, err, loaderCalls)
|
||||
secondPrompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
||||
if err != nil || secondPrompt.Value == nil || secondPrompt.Value.PromptID != "briefing" || loaderCalls != 2 {
|
||||
t.Fatalf("ID-only prompt inspection = (%#v, %v), calls=%d", secondPrompt, err, loaderCalls)
|
||||
}
|
||||
profile, err := suite.InspectProfile(wantContext, ProfileRequest{Selection: selection, ID: "default"}, wantInput, wantState)
|
||||
if err != nil || profile.Value == nil || profile.Value.ProfileID != "default" || loaderCalls != 3 {
|
||||
t.Fatalf("profile inspection = (%#v, %v), calls=%d", profile, err, loaderCalls)
|
||||
}
|
||||
if version.Set != true || version.Value != "1" {
|
||||
t.Fatalf("custom callback request lost version presence: %#v", version)
|
||||
}
|
||||
|
||||
empty := FromEngine[int, int](nil)
|
||||
empty.ListPrompts = nil
|
||||
@@ -363,11 +360,10 @@ func TestFromEngineInspectsRequirementsWithNativeRequest(t *testing.T) {
|
||||
request := RequirementsRequest{
|
||||
Selection: selection,
|
||||
Inspection: promptkit.RequirementInspectionRequest{
|
||||
PromptID: "briefing",
|
||||
PromptVersion: "1",
|
||||
ProfileID: "default",
|
||||
Vars: map[string]string{"audience": "internal"},
|
||||
SessionID: "session-42",
|
||||
PromptID: "briefing",
|
||||
ProfileID: "default",
|
||||
Vars: map[string]string{"audience": "internal"},
|
||||
SessionID: "session-42",
|
||||
},
|
||||
}
|
||||
want, err := engine.InspectRequirements(wantContext, request.Inspection)
|
||||
@@ -387,26 +383,9 @@ func TestFromEngineInspectsRequirementsWithNativeRequest(t *testing.T) {
|
||||
if err != nil || acquired.Value == nil || !reflect.DeepEqual(acquired.Value, want) || loaderCalls != 1 {
|
||||
t.Fatalf("requirements inspection = (%#v, %v), calls=%d; want native result %#v", acquired, err, loaderCalls, want)
|
||||
}
|
||||
if acquired.Value.PromptID != "briefing" || acquired.Value.PromptVersion != "1" || acquired.Value.ProfileID != "default" {
|
||||
if acquired.Value.PromptID != "briefing" || acquired.Value.PromptVersion == nil || *acquired.Value.PromptVersion != "1" || acquired.Value.ProfileID != "default" {
|
||||
t.Fatalf("requirements selection = %#v", acquired.Value)
|
||||
}
|
||||
inputs := make(map[string]promptkit.InputRequirement, len(acquired.Value.Inputs))
|
||||
for _, input := range acquired.Value.Inputs {
|
||||
inputs[input.Name] = input
|
||||
}
|
||||
if inputs["internal-notes"].Kind != promptkit.RequirementRequired || inputs["public-notes"].Kind != promptkit.RequirementOptional {
|
||||
t.Fatalf("caller variable did not reach native discovery: %#v", acquired.Value.Inputs)
|
||||
}
|
||||
if _, found := inputs["session-only"]; found {
|
||||
t.Fatalf("session template was not bypassed by the supplied session ID: %#v", acquired.Value.Inputs)
|
||||
}
|
||||
variables := make(map[string]promptkit.VariableRequirement, len(acquired.Value.Variables))
|
||||
for _, variable := range acquired.Value.Variables {
|
||||
variables[variable.Name] = variable
|
||||
}
|
||||
if !variables["audience"].Supplied {
|
||||
t.Fatalf("caller variable presence was not forwarded: %#v", acquired.Value.Variables)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromEngineRequirementsRetainLoadDiagnosticsAndSelectionErrors(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user