-
Notifications
You must be signed in to change notification settings - Fork 8
Support templates in our string evaluators #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Support templated variables in string evaluators for the CLI, allowing test cases to inject dynamic values into string checks.
- Introduces
string
fields in example prompts and switches evaluatorcontains
to use{{string}}
- Updates
runStringEvaluator
signature to accept atestCase
map and appliestemplateString
in each comparison - Adjusts tests to pass an empty
testCase
intorunStringEvaluator
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
examples/sample_prompt.yml | Added string keys under testData and updated evaluator contains |
cmd/eval/eval_test.go | Changed runStringEvaluator calls to include the new testCase param |
cmd/eval/eval.go | Refactored runStringEvaluator to template all string criteria |
Comments suppressed due to low confidence (2)
examples/sample_prompt.yml:9
- [nitpick] The key
string
in testData is very generic and may be confused with the evaluator’sstring
block. Consider renaming it to something more descriptive liketemplateVar
orplaceholder
.
string: hello
cmd/eval/eval_test.go:132
- There are no tests covering the new templating functionality or error paths when a placeholder is missing. Consider adding tests that include
{{string}}
substitutions and missing-key scenarios to validatetemplateString
behavior.
result, err := handler.runStringEvaluator("test", tt.evaluator, map[string]interface{}{}, tt.response)
if err != nil { | ||
return EvaluationResult{}, fmt.Errorf("failed to template message content: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I do agree with Copilot in that this looks a little gnarly. But with the way that Go wants to handle errors we kinda need this everywhere.
That is unless, we create the helper method here — that should there be an error, we just default back to the provided string. But open to suggestions/opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this, nice catch!
Much like our web prompt tooling, we should allow the models cli to support templated variables in string evaluators.
Before
After