Skip to content

Commit 025e32e

Browse files
committed
Refactor PromptPex model handling by changing pointer fields to values; update related tests and documentation for consistency
1 parent 9eb7803 commit 025e32e

6 files changed

Lines changed: 23 additions & 24 deletions

File tree

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository implements the GitHub Models CLI extension (`gh models`), enabli
88
### Building and Testing
99

1010
- `make build`: Compiles the CLI binary
11-
- `make check`: Runs format, vet, tidy, and tests. Always run when you are done with changes.
11+
- `make check`: Runs format, vet, tidy, tests, golang-ci. Always run when you are done with changes. Use this command to validate that the build and the tests are still ok.
1212
- `make test`: Runs the tests.
1313

1414
### Command Structure
@@ -33,7 +33,7 @@ This repository implements the GitHub Models CLI extension (`gh models`), enabli
3333
- **Local build**: `make build` or `script/build` (creates `gh-models` binary)
3434
- **Cross-platform**: `script/build all|windows|linux|darwin` for release builds
3535
- **Testing**: `make check` runs format, vet, tidy, and tests. Use `go test ./...` directly for faster iteration
36-
- **Quality gates**: `make fmt vet tidy test` - required before commits
36+
- **Quality gates**: `make check` - required before commits
3737

3838
### Authentication & Setup
3939
- Extension requires `gh auth login` before use - unauthenticated clients show helpful error messages

cmd/generate/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func ParseFlags(cmd *cobra.Command, options *PromptPexOptions) error {
121121
}
122122

123123
if groundtruthModel, _ := flags.GetString("groundtruth-model"); groundtruthModel != "" {
124-
options.Models.Groundtruth = &groundtruthModel
124+
options.Models.Groundtruth = groundtruthModel
125125
}
126126

127127
return nil

cmd/generate/generate_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ func TestParseFlags(t *testing.T) {
7979
name: "groundtruth model flag",
8080
args: []string{"--groundtruth-model", "openai/gpt-4o"},
8181
validate: func(t *testing.T, opts *PromptPexOptions) {
82-
require.NotNil(t, opts.Models.Groundtruth)
83-
require.Equal(t, "openai/gpt-4o", *opts.Models.Groundtruth)
82+
require.Equal(t, "openai/gpt-4o", opts.Models.Groundtruth)
8483
},
8584
},
8685
}

cmd/generate/options.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ func GetDefaultOptions() *PromptPexOptions {
1010
MaxRulesPerTestGen: util.Ptr(3),
1111
Verbose: util.Ptr(false),
1212
Models: &PromptPexModelAliases{
13-
Rules: util.Ptr("openai/gpt-4o"),
14-
Tests: util.Ptr("openai/gpt-4o"),
15-
Groundtruth: util.Ptr("openai/gpt-4o"),
13+
Rules: "openai/gpt-4o",
14+
Tests: "openai/gpt-4o",
15+
Groundtruth: "openai/gpt-4o",
1616
},
1717
}
1818
}

cmd/generate/pipeline.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (h *generateCommandHandler) RunTestGenerationPipeline(context *PromptPexCon
5252
}
5353

5454
// Step 8: Generate Groundtruth (if model specified)
55-
if h.options.Models.Groundtruth != nil && *h.options.Models.Groundtruth != "" && *h.options.Models.Groundtruth != "none" {
55+
if h.options.Models.Groundtruth != "" && h.options.Models.Groundtruth != "none" {
5656
if err := h.generateGroundtruth(context); err != nil {
5757
return fmt.Errorf("failed to generate groundtruth: %w", err)
5858
}
@@ -93,7 +93,7 @@ Intent:`, RenderMessagesToString(context.Prompt.Messages))
9393
{Role: azuremodels.ChatMessageRoleUser, Content: util.Ptr(prompt)},
9494
}
9595
options := azuremodels.ChatCompletionOptions{
96-
Model: *h.options.Models.Rules, // GitHub Models compatible model
96+
Model: h.options.Models.Rules, // GitHub Models compatible model
9797
Messages: messages,
9898
Temperature: util.Ptr(0.0),
9999
Stream: false,
@@ -130,7 +130,7 @@ Input Specification:`, RenderMessagesToString(context.Prompt.Messages))
130130
}
131131

132132
options := azuremodels.ChatCompletionOptions{
133-
Model: *h.options.Models.Rules,
133+
Model: h.options.Models.Rules,
134134
Messages: messages,
135135
Temperature: util.Ptr(0.0),
136136
}
@@ -168,7 +168,7 @@ Output Rules:`, RenderMessagesToString(context.Prompt.Messages))
168168
}
169169

170170
options := azuremodels.ChatCompletionOptions{
171-
Model: *h.options.Models.Rules, // GitHub Models compatible model
171+
Model: h.options.Models.Rules, // GitHub Models compatible model
172172
Messages: messages,
173173
Temperature: util.Ptr(0.0),
174174
}
@@ -211,7 +211,7 @@ Inverse Output Rules:`, strings.Join(context.Rules, "\n"))
211211
}
212212

213213
options := azuremodels.ChatCompletionOptions{
214-
Model: *h.options.Models.Rules, // GitHub Models compatible model
214+
Model: h.options.Models.Rules, // GitHub Models compatible model
215215
Messages: messages,
216216
Temperature: util.Ptr(0.0),
217217
}
@@ -294,7 +294,7 @@ Generate exactly %d diverse test cases:`, nTests,
294294
}
295295

296296
options := azuremodels.ChatCompletionOptions{
297-
Model: *h.options.Models.Tests, // GitHub Models compatible model
297+
Model: h.options.Models.Tests, // GitHub Models compatible model
298298
Messages: messages,
299299
Temperature: util.Ptr(0.3),
300300
}
@@ -397,19 +397,19 @@ func (h *generateCommandHandler) runSingleTestWithContext(input string, modelNam
397397
// generateGroundtruth generates groundtruth outputs using the specified model
398398
func (h *generateCommandHandler) generateGroundtruth(context *PromptPexContext) error {
399399
groundtruthModel := h.options.Models.Groundtruth
400-
h.WriteStartBox("Groundtruth", fmt.Sprintf("with %s", *groundtruthModel))
400+
h.WriteStartBox("Groundtruth", fmt.Sprintf("with %s", groundtruthModel))
401401
for i := range context.Tests {
402402
test := &context.Tests[i]
403403
h.WriteToLine(test.TestInput)
404404
if test.Groundtruth == nil || *test.Groundtruth == "" {
405405
// Generate groundtruth output
406-
output, err := h.runSingleTestWithContext(test.TestInput, *groundtruthModel, context)
406+
output, err := h.runSingleTestWithContext(test.TestInput, groundtruthModel, context)
407407
if err != nil {
408408
h.cfg.WriteToOut(fmt.Sprintf("Failed to generate groundtruth for test %d: %v", i, err))
409409
continue
410410
}
411411
test.Groundtruth = &output
412-
test.GroundtruthModel = groundtruthModel
412+
test.GroundtruthModel = &groundtruthModel
413413

414414
h.SaveContext(context) // Save context after generating groundtruth
415415
}

cmd/generate/types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import "github.com/github/gh-models/pkg/prompt"
44

55
// PromptPexModelAliases represents model aliases for different purposes
66
type PromptPexModelAliases struct {
7-
Rules *string `yaml:"rules,omitempty" json:"rules,omitempty"`
8-
Tests *string `yaml:"tests,omitempty" json:"tests,omitempty"`
9-
Groundtruth *string `yaml:"groundtruth,omitempty" json:"groundtruth,omitempty"`
7+
Rules string `yaml:"rules,omitempty" json:"rules,omitempty"`
8+
Tests string `yaml:"tests,omitempty" json:"tests,omitempty"`
9+
Groundtruth string `yaml:"groundtruth,omitempty" json:"groundtruth,omitempty"`
1010
}
1111

1212
// PromptPexPrompts contains custom prompts for different stages
1313
type PromptPexPrompts struct {
14-
InputSpec *string `yaml:"inputSpec,omitempty" json:"inputSpec,omitempty"`
15-
OutputRules *string `yaml:"outputRules,omitempty" json:"outputRules,omitempty"`
16-
InverseOutputRules *string `yaml:"inverseOutputRules,omitempty" json:"inverseOutputRules,omitempty"`
17-
Intent *string `yaml:"intent,omitempty" json:"intent,omitempty"`
14+
InputSpec string `yaml:"inputSpec,omitempty" json:"inputSpec,omitempty"`
15+
OutputRules string `yaml:"outputRules,omitempty" json:"outputRules,omitempty"`
16+
InverseOutputRules string `yaml:"inverseOutputRules,omitempty" json:"inverseOutputRules,omitempty"`
17+
Intent string `yaml:"intent,omitempty" json:"intent,omitempty"`
1818
}
1919

2020
// PromptPexOptions contains all configuration options for PromptPex

0 commit comments

Comments
 (0)