11package generate
22
33import (
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
12335func (h * generateCommandHandler ) generateRulesEvaluatorSystemPrompt (context * PromptPexContext ) string {
0 commit comments