Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
feat: Add promptfoo configuration files for build and fix
ZanzyTHEbar6411c324c6f1
diff --git a/Makefile b/Makefileindex 42e676a1..174fbf8a 100644--- a/Makefile+++ b/Makefile@@ -33,8 +33,11 @@ clean:test: render@$(GOTEST) -v ./...-render:- @cd app/scripts && go run render_config.go+gen-test:+ @$(GOCMD) run app/scripts/cmd/gen/gen.go $(filter-out $@,$(MAKECMDGOALS))++gen-provider:+ @$(GOCMD) run app/scripts/cmd/provider/gen_provider.go# Get dependenciesdeps:@@ -43,4 +46,17 @@ deps:# Default targetdefault: build+# Usage+help:+ @echo "Usage:"+ @echo " make dev - to run the development scripts"+ @echo " make gen-test <directory_path> - to create a new promptfoo eval directory structure"+ @echo " make gen-provider - to create a new promptfoo provider file from the promptfoo diretory structure"+ @echo " make clean - to remove generated files and directories"+ @echo " make help - to display this help message"++# Prevents make from interpreting the arguments as targets+%:+ @:+.PHONY: all render build clean test deps\ No newline at end of filediff --git a/app/scripts/cmd/gen/gen.go b/app/scripts/cmd/gen/gen.gonew file mode 100644index 00000000..40fbd558--- /dev/null+++ b/app/scripts/cmd/gen/gen.go@@ -0,0 +1,116 @@+package main++import (+ "fmt"+ "log"+ "os"+ "path/filepath"+ "text/template"+)++func main() {+ if len(os.Args) < 2 {+ log.Fatalf("Usage: %s <path/to/directory>", os.Args[0])+ }++ dirPath := os.Args[1]+ dirName := filepath.Base(dirPath)++ // Create the main directory+ if err := os.MkdirAll(dirPath, 0755); err != nil {+ log.Fatalf("Error creating directory: %s", err)+ }++ f, err := os.Create(fmt.Sprintf("%s/%s", dirPath, "promptfooconfig.yml"))+ if err != nil {+ log.Fatalf("Error creating file: %s", err)+ }+ f.Close()++ // Create files inside the directory+ files := []string{+ "parameters.json",+ "config.properties",+ "prompt.txt",+ }++ for _, file := range files {+ f, err := os.Create(fmt.Sprintf("%s/%s.%s", dirPath, dirName, file))+ if err != nil {+ log.Fatalf("Error creating file: %s", err)+ }+ f.Close()+ }++ // Create assets and tests directories+ subDirs := []string{"assets", "tests"}++ for _, subDir := range subDirs {+ if err := os.Mkdir(fmt.Sprintf("%s/%s", dirPath, subDir), 0755); err != nil {+ log.Fatalf("Error creating subdirectory: %s", err)+ }+ }++ // Template for promptfooconfig.yml+ ymlTemplate := `description: "{{ .Name }}"++prompts:+ - file://{{ .Name }}.prompt.txt++providers:+ - file://{{ .Name }}.provider.yml++tests: tests/*.tests.yml+`++ // Populate promptfooconfig.yml+ promptFooConfigTmpl, err := template.New("yml").Parse(ymlTemplate)+ if err != nil {+ log.Fatalf("Error creating template: %s", err)+ }++ // Template for config.properties+ propertiesTemplate := `provider_id=openai:gpt-4o+function_name=+tool_type=function+function_param_type=object+tool_choice_type=function+tool_choice_function_name=+nested_parameters_json={{ .Name }}.parameters.json+`++ // Populate config.properties+ configPropertiesTmpl, err := template.New("properties").Parse(propertiesTemplate)+ if err != nil {+ log.Fatalf("Error creating template: %s", err)+ }++ configFile, err := os.Create(fmt.Sprintf("%s/%s.%s", dirPath, dirName, "config.properties"))+ if err != nil {+ log.Fatalf("Error creating config.properties: %s", err)+ }+ defer configFile.Close()++ file, err := os.Create(fmt.Sprintf("%s/promptfooconfig.yml", dirPath))+ if err != nil {+ log.Fatalf("Error creating promptfooconfig.yml: %s", err)+ }+ defer file.Close()++ data := struct {+ Name string+ }{+ Name: dirName,+ }++ if err := promptFooConfigTmpl.Execute(file, data); err != nil {+ log.Fatalf("Error executing template: %s", err)+ }++ if err := configPropertiesTmpl.Execute(configFile, data); err != nil {+ log.Fatalf("Error executing template: %s", err)+ }++ fmt.Println("Directory created successfully!")+ fmt.Println("Please check the contents of the directory and proceed with the implementation.")+}diff --git a/app/scripts/render_config.go b/app/scripts/cmd/provider/gen_provider.gosimilarity index 100%rename from app/scripts/render_config.gorename to app/scripts/cmd/provider/gen_provider.godiff --git a/test/evals/promptfoo-poc/build/build.config.properties b/test/evals/promptfoo-poc/build/build.config.propertiesnew file mode 100644index 00000000..fea41b87--- /dev/null+++ b/test/evals/promptfoo-poc/build/build.config.properties@@ -0,0 +1,7 @@+provider_id=openai:gpt-4o+function_name=+tool_type=function+function_param_type=object+tool_choice_type=function+tool_choice_function_name=+nested_parameters_json=build.parameters.jsondiff --git a/test/evals/promptfoo-poc/build/build.parameters.json b/test/evals/promptfoo-poc/build/build.parameters.jsonnew file mode 100644index 00000000..e69de29bdiff --git a/test/evals/promptfoo-poc/build/build.prompt.txt b/test/evals/promptfoo-poc/build/build.prompt.txtnew file mode 100644index 00000000..e69de29bdiff --git a/test/evals/promptfoo-poc/build/promptfooconfig.yml b/test/evals/promptfoo-poc/build/promptfooconfig.ymlnew file mode 100644index 00000000..363f5bc5--- /dev/null+++ b/test/evals/promptfoo-poc/build/promptfooconfig.yml@@ -0,0 +1,9 @@+description: "build"++prompts:+ - file://build.prompt.txt++providers:+ - file://build.provider.yml++tests: tests/*.tests.ymldiff --git a/test/evals/promptfoo-poc/evals.md b/test/evals/promptfoo-poc/evals.mdnew file mode 100644index 00000000..0ad19fa9--- /dev/null+++ b/test/evals/promptfoo-poc/evals.md@@ -0,0 +1,90 @@+# Evals++Evals for plandex.++## Overview++`Classification:`++- MCC+- Specificity+- Sensitivity+- Accuracy++`Regression:`++- RMSE+- R2+- MSE++## Types of Evals++---++### Build Prompts Evaluations++1. **Syntax Check**+ - Ensure the prompt is syntactically correct and follows the required format.+2. **Completeness Check**+ - Verify that all necessary components (e.g., headers, body, footers) are included.+3. **Clarity and Precision**+ - Evaluate if the instructions are clear and unambiguous.+4. **Context Appropriateness**+ - Assess if the prompt is appropriate for the intended context and audience.+5. **Error Handling**+ - Check if there are adequate instructions for handling potential errors.+6. **Dependency Evaluation**+ - Ensure all dependencies (libraries, tools) are correctly specified.+7. **Output Validation**+ - Define criteria to validate the expected output.++### Verify Prompts Evaluations++1. **Accuracy Check**+ - Ensure the prompt's instructions lead to the correct and intended results.+2. **Validation Criteria**+ - Define and check the validation criteria for the outputs.+3. **Consistency Check**+ - Verify if the prompt maintains consistency in terminology and steps.+4. **Logic and Flow**+ - Evaluate the logical flow of the instructions to ensure they are coherent.+5. **Edge Cases Handling**+ - Assess if the prompt considers and handles edge cases effectively.+6. **User Feedback Integration**+ - Ensure there are provisions for incorporating user feedback.+7. **Performance Metrics**+ - Define and evaluate the performance metrics for the verification process.++### Fix Prompts Evaluations++1. **Error Identification**+ - Ensure the prompt accurately identifies the errors to be fixed.+2. **Correctness of Fix**+ - Verify that the proposed fix is correct and resolves the issue.+3. **Impact Analysis**+ - Assess the impact of the fix on the overall system or application.+4. **Regression Testing**+ - Ensure that the fix does not introduce new issues or regressions.+5. **Documentation Update**+ - Check if the documentation is updated to reflect the fix.+6. **Code Quality**+ - Evaluate the quality of the code after the fix (e.g., readability, maintainability).+7. **Performance Impact**+ - Assess if the fix affects the performance and ensure it remains optimal.++### Function Call Schemas Evaluations++1. **Schema Validity**+ - Ensure the schema is valid and conforms to the defined standards.+2. **Parameter Consistency**+ - Verify that the parameters are consistently defined and used.+3. **Return Type Verification**+ - Ensure the return types are correctly specified and handled.+4. **Error Handling Mechanism**+ - Assess the error handling mechanisms in the schema.+5. **Compatibility Check**+ - Check if the schema is compatible with different environments or systems.+6. **Documentation Completeness**+ - Ensure the schema is well-documented with clear explanations of each parameter and return type.+7. **Security Considerations**+ - Evaluate the schema for potential security vulnerabilities or risks.diff --git a/test/evals/promptfoo-poc/fix/tests/removal/changes.md b/test/evals/promptfoo-poc/fix/assets/removal/changes.mdsimilarity index 100%rename from test/evals/promptfoo-poc/fix/tests/removal/changes.mdrename to test/evals/promptfoo-poc/fix/assets/removal/changes.mddiff --git a/test/evals/promptfoo-poc/fix/tests/removal/post_build.go b/test/evals/promptfoo-poc/fix/assets/removal/post_build.gosimilarity index 100%rename from test/evals/promptfoo-poc/fix/tests/removal/post_build.gorename to test/evals/promptfoo-poc/fix/assets/removal/post_build.godiff --git a/test/evals/promptfoo-poc/fix/tests/removal/problems.txt b/test/evals/promptfoo-poc/fix/assets/removal/problems.txtsimilarity index 100%rename from test/evals/promptfoo-poc/fix/tests/removal/problems.txtrename to test/evals/promptfoo-poc/fix/assets/removal/problems.txtdiff --git a/test/evals/promptfoo-poc/fix/tests/shared/pre_build.go b/test/evals/promptfoo-poc/fix/assets/shared/pre_build.gosimilarity index 100%rename from test/evals/promptfoo-poc/fix/tests/shared/pre_build.gorename to test/evals/promptfoo-poc/fix/assets/shared/pre_build.godiff --git a/test/evals/promptfoo-poc/fix/config.properties b/test/evals/promptfoo-poc/fix/fix.config.propertiessimilarity index 80%rename from test/evals/promptfoo-poc/fix/config.propertiesrename to test/evals/promptfoo-poc/fix/fix.config.propertiesindex dc796603..28127414 100644--- a/test/evals/promptfoo-poc/fix/config.properties+++ b/test/evals/promptfoo-poc/fix/fix.config.properties@@ -4,4 +4,4 @@ tool_type=functionfunction_param_type=objecttool_choice_type=functiontool_choice_function_name=listChangesWithLineNums-nested_parameters_json=fix.parameters.json+nested_parameters_json=build.parameters.jsondiff --git a/test/evals/promptfoo-poc/fix/prompt.txt b/test/evals/promptfoo-poc/fix/fix.prompt.txtsimilarity index 100%rename from test/evals/promptfoo-poc/fix/prompt.txtrename to test/evals/promptfoo-poc/fix/fix.prompt.txtdiff --git a/test/evals/promptfoo-poc/fix/promptfooconfig.yaml b/test/evals/promptfoo-poc/fix/promptfooconfig.yamlindex 9f50157f..87fbe232 100644--- a/test/evals/promptfoo-poc/fix/promptfooconfig.yaml+++ b/test/evals/promptfoo-poc/fix/promptfooconfig.yaml@@ -1,30 +1,11 @@# This configuration compares LLM output of 2 prompts x 2 GPT models across 3 test cases.# Learn more: https://promptfoo.dev/docs/configuration/guide-description: "Fixes"+description: "fix"prompts:- - file://prompt.txt+ - file://fix.prompt.txtproviders:- file://fix.provider.yml-tests:- - vars:- preBuildState: file://tests/shared/pre_build.go- changes: file://tests/removal/changes.md- problems: file://tests/removal/problems.txt- postBuildState: file://tests/removal/post_build.go- assert:- - type: is-json- - type: is-valid-openai-tools-call- - type: javascript- value: |- var args = JSON.parse(output[0].function.arguments)- return (- args.problems &&- args.changes.length > 0 &&- args.changes.some(- change => change.hasChange &&- change.new.includes("var contextRmCmd = &cobra.Command{")- )- )+tests: tests/*.tests.ymldiff --git a/test/evals/promptfoo-poc/fix/tests/fix.test.yml b/test/evals/promptfoo-poc/fix/tests/fix.test.ymlnew file mode 100644index 00000000..1084185a--- /dev/null+++ b/test/evals/promptfoo-poc/fix/tests/fix.test.yml@@ -0,0 +1,20 @@+- description: "Check Fix with Line numbers"+ vars:+ preBuildState: file://assets/shared/pre_build.go+ changes: file://assets/removal/changes.md+ problems: file://assets/removal/problems.txt+ postBuildState: file://assets/removal/post_build.go+ assert:+ - type: is-json+ - type: is-valid-openai-tools-call+ - type: javascript+ value: |+ var args = JSON.parse(output[0].function.arguments)+ return (+ args.problems &&+ args.changes.length > 0 &&+ args.changes.some(+ change => change.hasChange &&+ change.new.includes("var contextRmCmd = &cobra.Command{")+ )+ )diff --git a/test/evals/promptfoo-poc/verify/tests/removal/changes.md b/test/evals/promptfoo-poc/verify/assets/removal/changes.mdsimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/removal/changes.mdrename to test/evals/promptfoo-poc/verify/assets/removal/changes.mddiff --git a/test/evals/promptfoo-poc/verify/tests/removal/diff.txt b/test/evals/promptfoo-poc/verify/assets/removal/diff.txtsimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/removal/diff.txtrename to test/evals/promptfoo-poc/verify/assets/removal/diff.txtdiff --git a/test/evals/promptfoo-poc/verify/tests/removal/post_build.go b/test/evals/promptfoo-poc/verify/assets/removal/post_build.gosimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/removal/post_build.gorename to test/evals/promptfoo-poc/verify/assets/removal/post_build.godiff --git a/test/evals/promptfoo-poc/verify/tests/shared/pre_build.go b/test/evals/promptfoo-poc/verify/assets/shared/pre_build.gosimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/shared/pre_build.gorename to test/evals/promptfoo-poc/verify/assets/shared/pre_build.godiff --git a/test/evals/promptfoo-poc/verify/tests/valid/changes.md b/test/evals/promptfoo-poc/verify/assets/valid/changes.mdsimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/valid/changes.mdrename to test/evals/promptfoo-poc/verify/assets/valid/changes.mddiff --git a/test/evals/promptfoo-poc/verify/tests/valid/diff.txt b/test/evals/promptfoo-poc/verify/assets/valid/diff.txtsimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/valid/diff.txtrename to test/evals/promptfoo-poc/verify/assets/valid/diff.txtdiff --git a/test/evals/promptfoo-poc/verify/tests/valid/post_build.go b/test/evals/promptfoo-poc/verify/assets/valid/post_build.gosimilarity index 100%rename from test/evals/promptfoo-poc/verify/tests/valid/post_build.gorename to test/evals/promptfoo-poc/verify/assets/valid/post_build.godiff --git a/test/evals/promptfoo-poc/verify/promptfooconfig.yaml b/test/evals/promptfoo-poc/verify/promptfooconfig.yamlindex f71ea646..62cee381 100644--- a/test/evals/promptfoo-poc/verify/promptfooconfig.yaml+++ b/test/evals/promptfoo-poc/verify/promptfooconfig.yaml@@ -1,41 +1,9 @@# This configuration compares LLM output of 2 prompts x 2 GPT models across 3 test cases.# Learn more: https://promptfoo.dev/docs/configuration/guide-description: "Verification"+description: "verify"prompts:- - file://prompt.txt-+ - file://verify.prompt.txtproviders:- file://verify.provider.yml--tests:- - vars:- preBuildState: file://tests/shared/pre_build.go- changes: file://tests/valid/changes.md- postBuildState: file://tests/valid/post_build.go- diffs: file://tests/valid/diff.txt- assert:- - type: is-json- - type: is-valid-openai-tools-call- - type: javascript- value: |- var args = JSON.parse(output[0].function.arguments)- return !(- args.hasSyntaxErrors ||- args.hasRemovedCodeErrors ||- args.hasDuplicationErrors ||- args.hasReferenceErrors- )-- - vars:- preBuildState: file://tests/shared/pre_build.go- changes: file://tests/removal/changes.md- postBuildState: file://tests/removal/post_build.go- diffs: file://tests/removal/diff.txt- assert:- - type: is-json- - type: is-valid-openai-tools-call- - type: javascript- value: |- var args = JSON.parse(output[0].function.arguments)- return args.hasRemovedCodeErrors+tests: tests/*.test.ymldiff --git a/test/evals/promptfoo-poc/verify/tests/removal.test.yml b/test/evals/promptfoo-poc/verify/tests/removal.test.ymlnew file mode 100644index 00000000..d48fbf95--- /dev/null+++ b/test/evals/promptfoo-poc/verify/tests/removal.test.yml@@ -0,0 +1,13 @@+- description: "Removal of code errors"+ vars:+ preBuildState: file://assets/shared/pre_build.go+ changes: file://assets/removal/changes.md+ postBuildState: file://assets/removal/post_build.go+ diffs: file://assets/removal/diff.txt+ assert:+ - type: is-json+ - type: is-valid-openai-tools-call+ - type: javascript+ value: |+ var args = JSON.parse(output[0].function.arguments)+ return args.hasRemovedCodeErrors\ No newline at end of filediff --git a/test/evals/promptfoo-poc/verify/tests/validate.test.yml b/test/evals/promptfoo-poc/verify/tests/validate.test.ymlnew file mode 100644index 00000000..13eab397--- /dev/null+++ b/test/evals/promptfoo-poc/verify/tests/validate.test.yml@@ -0,0 +1,18 @@+- description: "Validation of the code changes"+ vars:+ preBuildState: file://assets/shared/pre_build.go+ changes: file://assets/valid/changes.md+ postBuildState: file://assets/valid/post_build.go+ diffs: file://assets/valid/diff.txt+ assert:+ - type: is-json+ - type: is-valid-openai-tools-call+ - type: javascript+ value: |+ var args = JSON.parse(output[0].function.arguments)+ return !(+ args.hasSyntaxErrors ||+ args.hasRemovedCodeErrors ||+ args.hasDuplicationErrors ||+ args.hasReferenceErrors+ )diff --git a/test/evals/promptfoo-poc/verify/config.properties b/test/evals/promptfoo-poc/verify/verify.config.propertiessimilarity index 100%rename from test/evals/promptfoo-poc/verify/config.propertiesrename to test/evals/promptfoo-poc/verify/verify.config.propertiesdiff --git a/test/evals/promptfoo-poc/verify/prompt.txt b/test/evals/promptfoo-poc/verify/verify.prompt.txtsimilarity index 100%rename from test/evals/promptfoo-poc/verify/prompt.txtrename to test/evals/promptfoo-poc/verify/verify.prompt.txt