examples/config-csv-metadata/README.md
You can run this example with:
npx promptfoo@latest init --example config-csv-metadata
cd config-csv-metadata
This example demonstrates how to use metadata columns in CSV and Excel test files to organize and filter your test cases. You can see more details on how to build test cases from CSV in the Promptfoo docs
promptfooconfig.yaml: Configuration file with a simple prompt and provider setuptests.csv: Test cases with metadata columns for categorization and filteringtests.xlsx: Same test cases in Excel format (optional - requires npm install read-excel-file)The CSV/Excel file includes two types of metadata columns:
__metadata:category - Single value metadata for broad categorization__metadata:tags[] - Array metadata for multiple tags, with comma separation and escape supportBasic evaluation:
promptfoo eval
To use Excel file instead of CSV:
# First install the read-excel-file package
npm install read-excel-file
# Then run with Excel file
promptfoo eval -c promptfooconfig.yaml -t file://tests.xlsx
Filter by category:
promptfoo eval --filter-metadata category=technology
Filter by tags:
promptfoo eval --filter-metadata tags=ai
Note that array metadata values (tags) support escaped commas. For example, "global,warming" is treated as a single tag.
The example includes basic assertions using the __expected column to verify outputs contain relevant keywords.