promptfoo / promptfoo

Test your prompts, agents, and RAGs. Redteaming, pentesting, vulnerability scanning for LLMs. Improve your app's quality and catch problems. Compare performance of GPT, Claude, Gemini, Llama, and more. Simple declarative configs with command line and CI/CD integration.

Home Page:https://www.promptfoo.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run External File from `tests.csv`

sangwoo-joh opened this issue · comments

Thanks to #238 , tests.csv supports Python function calls for assertions.
However, __expected doesn't seem to provide the ability to run external files (not just Python). Assert can execute external files using the file:// prefix to value, which would be nice to have for __expected as well.

Thanks for flagging this. #608 fixes handling for external assertion files that are not Javascript or Python.

Tested with the following:

promptfooconfig.yaml:

prompts:
  - "Write a tweet about {{topic}}"

providers:
  - openai:gpt-3.5-turbo-0613

tests: tests.csv

tests.csv:

topic,__expected1,__expected2,__expected3
bananas,javascript:file://assert.js,contains:file://contains_text.txt,contains:file://contains_json.json

assert.js:

module.exports = (output, { vars }) => {
  console.log(`Received ${output} using variables ${JSON.stringify(vars)}`);
  return {
    pass: true,
    score: 0.5,
    reason: 'Some custom reason',
  };
};

contains_text.txt:

banana

Fix is released in 0.50.0. Thanks!

Wow, I didn't think it'd be fixed so quickly, thank you so much!!