What's Changed
* feat: ability to load `vars` values at runtime by typpo in https://github.com/promptfoo/promptfoo/pull/496
* feat(anthropic): Add Claude 3 support by streichsbaer in https://github.com/promptfoo/promptfoo/pull/526
Breaking
496 makes it possible to return dynamic data as a variable. This is useful for testing RAG applications.
Users importing Javascript or Python vars files must adhere to the new [dynamic vars format](https://promptfoo.dev/docs/configuration/guide#import-vars-from-separate-files).
Javascript example:
js
module.exports = function (varName, prompt, otherVars) {
// Example logic to return a value based on the varName
if (varName === 'context') {
return `Processed ${otherVars.input} for prompt: ${prompt}`;
}
return {
output: 'default value',
};
// Handle potential errors
// return { error: 'Error message' }
};
Python example:
py
def get_var(var_name, prompt, other_vars):
Example logic to dynamically generate variable content
if var_name == 'context':
return {
'output': f"Context for {other_vars['input']} in prompt: {prompt}"
}
return {'output': 'default context'}
Handle potential errors
return { 'error': 'Error message' }
**Full Changelog**: https://github.com/promptfoo/promptfoo/compare/0.44.0...0.45.0