Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

feat: Add promptfoo configuration files for build and fix

ZanzyTHEbar6411c324c6f1
diff --git a/Makefile b/Makefile
index 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 dependencies
deps:
@@ -43,4 +46,17 @@ deps:
# Default target
default: 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 file
diff --git a/app/scripts/cmd/gen/gen.go b/app/scripts/cmd/gen/gen.go
new file mode 100644
index 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.go
similarity index 100%
rename from app/scripts/render_config.go
rename to app/scripts/cmd/provider/gen_provider.go
diff --git a/test/evals/promptfoo-poc/build/build.config.properties b/test/evals/promptfoo-poc/build/build.config.properties
new file mode 100644
index 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.json
diff --git a/test/evals/promptfoo-poc/build/build.parameters.json b/test/evals/promptfoo-poc/build/build.parameters.json
new file mode 100644
index 00000000..e69de29b
diff --git a/test/evals/promptfoo-poc/build/build.prompt.txt b/test/evals/promptfoo-poc/build/build.prompt.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/test/evals/promptfoo-poc/build/promptfooconfig.yml b/test/evals/promptfoo-poc/build/promptfooconfig.yml
new file mode 100644
index 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.yml
diff --git a/test/evals/promptfoo-poc/evals.md b/test/evals/promptfoo-poc/evals.md
new file mode 100644
index 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.md
similarity index 100%
rename from test/evals/promptfoo-poc/fix/tests/removal/changes.md
rename to test/evals/promptfoo-poc/fix/assets/removal/changes.md
diff --git a/test/evals/promptfoo-poc/fix/tests/removal/post_build.go b/test/evals/promptfoo-poc/fix/assets/removal/post_build.go
similarity index 100%
rename from test/evals/promptfoo-poc/fix/tests/removal/post_build.go
rename to test/evals/promptfoo-poc/fix/assets/removal/post_build.go
diff --git a/test/evals/promptfoo-poc/fix/tests/removal/problems.txt b/test/evals/promptfoo-poc/fix/assets/removal/problems.txt
similarity index 100%
rename from test/evals/promptfoo-poc/fix/tests/removal/problems.txt
rename to test/evals/promptfoo-poc/fix/assets/removal/problems.txt
diff --git a/test/evals/promptfoo-poc/fix/tests/shared/pre_build.go b/test/evals/promptfoo-poc/fix/assets/shared/pre_build.go
similarity index 100%
rename from test/evals/promptfoo-poc/fix/tests/shared/pre_build.go
rename to test/evals/promptfoo-poc/fix/assets/shared/pre_build.go
diff --git a/test/evals/promptfoo-poc/fix/config.properties b/test/evals/promptfoo-poc/fix/fix.config.properties
similarity index 80%
rename from test/evals/promptfoo-poc/fix/config.properties
rename to test/evals/promptfoo-poc/fix/fix.config.properties
index 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=function
function_param_type=object
tool_choice_type=function
tool_choice_function_name=listChangesWithLineNums
-nested_parameters_json=fix.parameters.json
+nested_parameters_json=build.parameters.json
diff --git a/test/evals/promptfoo-poc/fix/prompt.txt b/test/evals/promptfoo-poc/fix/fix.prompt.txt
similarity index 100%
rename from test/evals/promptfoo-poc/fix/prompt.txt
rename to test/evals/promptfoo-poc/fix/fix.prompt.txt
diff --git a/test/evals/promptfoo-poc/fix/promptfooconfig.yaml b/test/evals/promptfoo-poc/fix/promptfooconfig.yaml
index 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.txt
providers:
- 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.yml
diff --git a/test/evals/promptfoo-poc/fix/tests/fix.test.yml b/test/evals/promptfoo-poc/fix/tests/fix.test.yml
new file mode 100644
index 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.md
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/removal/changes.md
rename to test/evals/promptfoo-poc/verify/assets/removal/changes.md
diff --git a/test/evals/promptfoo-poc/verify/tests/removal/diff.txt b/test/evals/promptfoo-poc/verify/assets/removal/diff.txt
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/removal/diff.txt
rename to test/evals/promptfoo-poc/verify/assets/removal/diff.txt
diff --git a/test/evals/promptfoo-poc/verify/tests/removal/post_build.go b/test/evals/promptfoo-poc/verify/assets/removal/post_build.go
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/removal/post_build.go
rename to test/evals/promptfoo-poc/verify/assets/removal/post_build.go
diff --git a/test/evals/promptfoo-poc/verify/tests/shared/pre_build.go b/test/evals/promptfoo-poc/verify/assets/shared/pre_build.go
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/shared/pre_build.go
rename to test/evals/promptfoo-poc/verify/assets/shared/pre_build.go
diff --git a/test/evals/promptfoo-poc/verify/tests/valid/changes.md b/test/evals/promptfoo-poc/verify/assets/valid/changes.md
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/valid/changes.md
rename to test/evals/promptfoo-poc/verify/assets/valid/changes.md
diff --git a/test/evals/promptfoo-poc/verify/tests/valid/diff.txt b/test/evals/promptfoo-poc/verify/assets/valid/diff.txt
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/valid/diff.txt
rename to test/evals/promptfoo-poc/verify/assets/valid/diff.txt
diff --git a/test/evals/promptfoo-poc/verify/tests/valid/post_build.go b/test/evals/promptfoo-poc/verify/assets/valid/post_build.go
similarity index 100%
rename from test/evals/promptfoo-poc/verify/tests/valid/post_build.go
rename to test/evals/promptfoo-poc/verify/assets/valid/post_build.go
diff --git a/test/evals/promptfoo-poc/verify/promptfooconfig.yaml b/test/evals/promptfoo-poc/verify/promptfooconfig.yaml
index 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.txt
providers:
- 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.yml
diff --git a/test/evals/promptfoo-poc/verify/tests/removal.test.yml b/test/evals/promptfoo-poc/verify/tests/removal.test.yml
new file mode 100644
index 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 file
diff --git a/test/evals/promptfoo-poc/verify/tests/validate.test.yml b/test/evals/promptfoo-poc/verify/tests/validate.test.yml
new file mode 100644
index 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.properties
similarity index 100%
rename from test/evals/promptfoo-poc/verify/config.properties
rename to test/evals/promptfoo-poc/verify/verify.config.properties
diff --git a/test/evals/promptfoo-poc/verify/prompt.txt b/test/evals/promptfoo-poc/verify/verify.prompt.txt
similarity index 100%
rename from test/evals/promptfoo-poc/verify/prompt.txt
rename to test/evals/promptfoo-poc/verify/verify.prompt.txt