Skip to content

Commit e668ba8

Browse files
committed
Refactor effort configuration and remove test expansions; update command line flags and options for improved clarity
1 parent 507ec74 commit e668ba8

10 files changed

Lines changed: 14 additions & 745 deletions

File tree

cmd/generate/effort.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type EffortConfiguration struct {
77
TestGenerations *int `json:"testGenerations,omitempty"`
88
TestsPerRule *int `json:"testsPerRule,omitempty"`
99
RunsPerTest *int `json:"runsPerTest,omitempty"`
10-
TestExpansions *int `json:"testExpansions,omitempty"`
1110
MaxRules *int `json:"maxRules,omitempty"`
1211
MaxRulesPerTestGeneration *int `json:"maxRulesPerTestGeneration,omitempty"`
1312
MaxTestsToRun *int `json:"maxTestsToRun,omitempty"`
@@ -17,19 +16,8 @@ type EffortConfiguration struct {
1716
// Based on the reference TypeScript implementation in constants.mts
1817
func GetEffortConfiguration(effort string) *EffortConfiguration {
1918
switch effort {
20-
case EffortMin:
21-
return &EffortConfiguration{
22-
TestGenerations: util.Ptr(1),
23-
TestsPerRule: util.Ptr(1),
24-
RunsPerTest: util.Ptr(1),
25-
TestExpansions: util.Ptr(0),
26-
MaxRules: util.Ptr(6),
27-
MaxRulesPerTestGeneration: util.Ptr(100),
28-
MaxTestsToRun: util.Ptr(10),
29-
}
3019
case EffortLow:
3120
return &EffortConfiguration{
32-
TestExpansions: util.Ptr(0),
3321
TestGenerations: util.Ptr(1),
3422
MaxRules: util.Ptr(3),
3523
TestsPerRule: util.Ptr(2),
@@ -39,7 +27,6 @@ func GetEffortConfiguration(effort string) *EffortConfiguration {
3927
}
4028
case EffortMedium:
4129
return &EffortConfiguration{
42-
TestExpansions: util.Ptr(0),
4330
MaxRules: util.Ptr(20),
4431
TestsPerRule: util.Ptr(3),
4532
RunsPerTest: util.Ptr(1),
@@ -48,7 +35,6 @@ func GetEffortConfiguration(effort string) *EffortConfiguration {
4835
}
4936
case EffortHigh:
5037
return &EffortConfiguration{
51-
TestExpansions: util.Ptr(1),
5238
MaxRules: util.Ptr(50),
5339
MaxRulesPerTestGeneration: util.Ptr(2),
5440
TestGenerations: util.Ptr(2),
@@ -79,9 +65,6 @@ func ApplyEffortConfiguration(options *PromptPexOptions, effort string) {
7965
if config.RunsPerTest != nil && options.RunsPerTest == nil {
8066
options.RunsPerTest = config.RunsPerTest
8167
}
82-
if config.TestExpansions != nil && options.TestExpansions == nil {
83-
options.TestExpansions = config.TestExpansions
84-
}
8568
if config.MaxRules != nil && options.MaxRules == nil {
8669
options.MaxRules = config.MaxRules
8770
}

cmd/generate/export.go

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,12 @@
11
package generate
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"regexp"
76
"strings"
8-
9-
"github.com/github/gh-models/pkg/prompt"
107
)
118

12-
// toGitHubModelsPrompt converts PromptPex context to GitHub Models format
13-
func (h *generateCommandHandler) toGitHubModelsPrompt(modelID string, context *PromptPexContext) (*prompt.File, error) {
14-
// Resolve model name (simplified - in real implementation would use LLM client)
15-
resolvedModel := modelID
16-
if modelID == "evals" {
17-
resolvedModel = "gpt-4o" // Default model for evals
18-
}
19-
20-
// Convert messages from the prompt file
21-
var messages []prompt.Message
22-
if context.Prompt != nil {
23-
messages = context.Prompt.Messages
24-
}
25-
26-
// Convert test data
27-
var testData []prompt.TestDataItem
28-
// Extract template variables from prompt content to determine allowed fields
29-
allowedFields := h.extractTemplateVariables(context)
30-
31-
for _, test := range context.Tests {
32-
// Skip empty test inputs
33-
if strings.TrimSpace(test.TestInput) == "" {
34-
h.cfg.WriteToOut(fmt.Sprintf("Warning: Skipping test with empty input (scenario: %s)", getTestScenario(test)))
35-
continue
36-
}
37-
38-
item := prompt.TestDataItem{}
39-
40-
// Parse test input if it's JSON
41-
if strings.HasPrefix(test.TestInput, "{") {
42-
var inputMap map[string]interface{}
43-
if err := json.Unmarshal([]byte(test.TestInput), &inputMap); err == nil {
44-
// Use the parsed JSON as individual fields, only including template variables
45-
for k, v := range inputMap {
46-
if allowedFields[k] {
47-
item[k] = v
48-
} else {
49-
h.cfg.WriteToOut(fmt.Sprintf("Warning: Skipping field '%s' (not a template variable) in test data", k))
50-
}
51-
}
52-
} else {
53-
h.cfg.WriteToOut(fmt.Sprintf("Failed to parse test input as JSON: %v. Using as plain text input.", err))
54-
// Fall back to single input field
55-
item["input"] = test.TestInput
56-
}
57-
} else {
58-
// Simple text input
59-
item["input"] = test.TestInput
60-
}
61-
62-
// Add expected output if available (groundtruth)
63-
if test.Groundtruth != nil {
64-
item["expected"] = *test.Groundtruth
65-
}
66-
67-
// Add reasoning if available
68-
if test.Reasoning != nil {
69-
item["reasoning"] = *test.Reasoning
70-
}
71-
72-
testData = append(testData, item)
73-
}
74-
75-
// Create model parameters
76-
var modelParams prompt.ModelParameters
77-
if h.options.Temperature != nil {
78-
modelParams = prompt.ModelParameters{
79-
Temperature: h.options.Temperature,
80-
}
81-
}
82-
9+
/*
8310
// Create the base evaluator using rules
8411
evaluators := []prompt.Evaluator{
8512
{
@@ -101,23 +28,8 @@ func (h *generateCommandHandler) toGitHubModelsPrompt(modelID string, context *P
10128
},
10229
}
10330
104-
// Create the prompt file structure
105-
promptFile := &prompt.File{
106-
Model: resolvedModel,
107-
ModelParameters: modelParams,
108-
Messages: messages,
109-
TestData: testData,
110-
Evaluators: evaluators,
111-
}
112-
113-
// Set name and description from the original prompt if available
114-
if context.Prompt != nil {
115-
promptFile.Name = context.Prompt.Name
116-
promptFile.Description = context.Prompt.Description
117-
}
11831
119-
return promptFile, nil
120-
}
32+
*/
12133

12234
// generateRulesEvaluatorSystemPrompt generates the system prompt for rules evaluation
12335
func (h *generateCommandHandler) generateRulesEvaluatorSystemPrompt(context *PromptPexContext) string {

0 commit comments

Comments
 (0)