-
Notifications
You must be signed in to change notification settings - Fork 8
Support loading prompt from yml file #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds the ability to load a prompt definition from a YAML file via the --file
flag, preload its messages and parameters, and include a test verifying basic YAML loading.
- Introduce
s.prompt.yml
as an example prompt definition. - Parse
.prompt.yml
into apromptFile
struct inrun.go
and inject its data before executing the command. - Add a test in
run_test.go
to confirm that YAML-loaded messages and temperature are applied.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
s.prompt.yml | New example YAML file defining prompt metadata. |
cmd/run/run.go | Parse --file flag, unmarshal YAML, preload messages and parameters. |
cmd/run/run_test.go | Test that --file loads YAML and applies its settings. |
Comments suppressed due to low confidence (1)
cmd/run/run_test.go:85
- There is no test verifying that a CLI flag overrides a value from the YAML file. Add a case where you pass
--temperature
alongside--file
and assert that the flag value takes effect.
t.Run("--file pre-loads YAML and CLI overrides take precedence", func(t *testing.T) {
b5d7883
to
f74c60a
Compare
@@ -208,6 +225,24 @@ func NewRunCommand(cfg *command.Config) *cobra.Command { | |||
Example: "gh models run openai/gpt-4o-mini \"how many types of hyena are there?\"", | |||
Args: cobra.ArbitraryArgs, | |||
RunE: func(cmd *cobra.Command, args []string) error { | |||
filePath, _ := cmd.Flags().GetString("file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That _
, is that an error? Should you maybe check it and return early if it's non-nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's probably wise to do that, but I think it's safe to follow up in a later change. The possible errors here are things like "you defined the file
flag as an integer but are trying to GetString
it", not really things that users could trigger.
Supports loading prompt from a yml file via the
--file
parameter.