Skip to content

Commit 0615664

Browse files
committed
Refactor PromptPexContext by changing RunID and PromptHash fields to values; update related tests for consistency and remove unused test_types.go file
1 parent 7571825 commit 0615664

4 files changed

Lines changed: 7 additions & 33 deletions

File tree

cmd/generate/context.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
"github.com/github/gh-models/pkg/prompt"
10-
"github.com/github/gh-models/pkg/util"
1110
)
1211

1312
// createContext creates a new PromptPexContext from a prompt file
@@ -29,11 +28,11 @@ func (h *generateCommandHandler) CreateContextFromPrompt() (*PromptPexContext, e
2928
runID := fmt.Sprintf("run_%d", time.Now().Unix())
3029
context := &PromptPexContext{
3130
// Unique identifier for the run
32-
RunID: util.Ptr(runID),
31+
RunID: runID,
3332
// The prompt content and metadata
3433
Prompt: prompt,
3534
// Hash of the prompt messages, model, and parameters
36-
PromptHash: util.Ptr(promptHash),
35+
PromptHash: promptHash,
3736
// The options used to generate the prompt
3837
Options: h.options,
3938
}
@@ -51,8 +50,7 @@ func (h *generateCommandHandler) CreateContextFromPrompt() (*PromptPexContext, e
5150
} else {
5251
sessionInfo = fmt.Sprintf("reloading session file at %s", *h.sessionFile)
5352
// Check if prompt hashes match
54-
if existingContext.PromptHash != nil && context.PromptHash != nil &&
55-
*existingContext.PromptHash != *context.PromptHash {
53+
if existingContext.PromptHash != context.PromptHash {
5654
return nil, fmt.Errorf("prompt changed unable to reuse session file")
5755
}
5856

cmd/generate/generate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ messages:
190190
require.NoError(t, err)
191191
require.NotNil(t, ctx)
192192
require.NotEmpty(t, ctx.RunID)
193-
require.True(t, ctx.RunID != nil)
193+
require.True(t, ctx.RunID != "")
194194
require.Equal(t, "Test Context Creation", ctx.Prompt.Name)
195195
require.Equal(t, "Test description for context", ctx.Prompt.Description)
196196
require.Equal(t, options, ctx.Options)

cmd/generate/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ type PromptPexOptions struct {
3737

3838
// PromptPexContext represents the main context for PromptPex operations
3939
type PromptPexContext struct {
40-
RunID *string `json:"runId" yaml:"runId"`
40+
RunID string `json:"runId" yaml:"runId"`
4141
Prompt *prompt.File `json:"prompt" yaml:"prompt"`
42-
PromptHash *string `json:"promptHash" yaml:"promptHash"`
42+
PromptHash string `json:"promptHash" yaml:"promptHash"`
43+
Options *PromptPexOptions `json:"options" yaml:"options"`
4344
Intent *string `json:"intent" yaml:"intent"`
4445
Rules []string `json:"rules" yaml:"rules"`
4546
InverseRules []string `json:"inverseRules" yaml:"inverseRules"`
4647
InputSpec *string `json:"inputSpec" yaml:"inputSpec"`
4748
Tests []PromptPexTest `json:"tests" yaml:"tests"`
48-
Options *PromptPexOptions `json:"options" yaml:"options"`
4949
}
5050

5151
// PromptPexTest represents a single test case

test_types.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)