examples/config-ts/README.md
You can run this example with:
npx promptfoo@latest init --example config-ts
cd config-ts
This example demonstrates TypeScript configuration for promptfoo, including:
tsx recommended)Install dependencies:
npm install
NODE_OPTIONS="--import tsx" promptfoo eval -c promptfooconfig.ts
This example translates text into French and Pirate speak.
NODE_OPTIONS="--import tsx" promptfoo eval -c promptfooconfig-with-schema.ts
This example shows structured JSON outputs with fun translations into Pirate speak, Shakespeare English, and Gen Z slang.
View results:
promptfoo view
promptfooconfig.ts)Demonstrates:
UnifiedConfig typepromptfooconfig-with-schema.ts)Shows advanced features:
Both OpenAI and Gemini support strict schema enforcement to ensure outputs match your Zod schema exactly.
Node.js currently requires external loaders to run TypeScript files directly:
--import flagtsx loader provides the best developer experience