Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e05e531

Browse files
committed
Added test coverage to ensure that the initialPrompt is also fed into the {{input}} template when processing prompt.yaml files.
1 parent c916262 commit e05e531

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/run/run_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ messages:
149149
require.Contains(t, out.String(), reply) // response streamed to output
150150
})
151151

152-
t.Run("--file with {{input}} placeholder is substituted with stdin", func(t *testing.T) {
152+
t.Run("--file with {{input}} placeholder is substituted with initial prompt and stdin", func(t *testing.T) {
153153
const yamlBody = `
154154
name: Summarizer
155155
description: Summarizes input text
@@ -208,18 +208,21 @@ messages:
208208

209209
out := new(bytes.Buffer)
210210
cfg := command.NewConfig(out, out, client, true, 100)
211+
212+
initialPrompt := "Please summarize the provided text."
211213
runCmd := NewRunCommand(cfg)
212214
runCmd.SetArgs([]string{
213215
"--file", tmp.Name(),
214216
azuremodels.FormatIdentifier("openai", "test-model"),
217+
initialPrompt,
215218
})
216219

217220
_, err = runCmd.ExecuteC()
218221
require.NoError(t, err)
219222

220223
require.Len(t, capturedReq.Messages, 3)
221224
require.Equal(t, "You are a text summarizer.", *capturedReq.Messages[0].Content)
222-
require.Equal(t, piped, *capturedReq.Messages[1].Content) // {{input}} -> "Hello there!"
225+
require.Equal(t, initialPrompt+"\n"+piped, *capturedReq.Messages[1].Content) // {{input}} -> "Hello there!"
223226

224227
require.Contains(t, out.String(), reply)
225228
})

0 commit comments

Comments
 (0)