Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel
Michael D'Angelo be1cb847b5
chore: update ts-config example README with tsx loader options
11 months ago
..
be1cb847b5
chore: update ts-config example README with tsx loader options
11 months ago
adec5ba3a8
docs: add TypeScript promptfooconfig example (#1427)
1 year ago

README.md

You have to be logged in to leave a comment. Sign In

TypeScript Configuration Example for promptfoo

This guide demonstrates how to set up a TypeScript configuration for promptfoo using promptfooconfig.ts.

Prerequisites

  • Node.js 20 or later
  • A TypeScript loader for Node.js such as @swc-node/register or tsx

Install your chosen loader:

npm install @swc-node/register
# or
npm install tsx

Running the Evaluation

Execute the evaluation using one of the following commands:

# Using @swc-node/register
NODE_OPTIONS='--import @swc-node/register/esm-register' promptfoo eval -c examples/ts-config/promptfooconfig.ts

# Using tsx
NODE_OPTIONS="--import tsx" promptfoo eval -c examples/ts-config/promptfooconfig.ts

View the results:

promptfoo view

TypeScript Support in Node.js

  • Currently, Node.js requires external loaders to run TypeScript files directly. However, future versions of Node.js are expected to include native TypeScript support:
  • Node.js 20 introduced the --experimental-loader flag for ES module.
  • The Node.js team is actively working on enhancing TypeScript integration.
  • Future versions may reduce or eliminate the need for external loaders.
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...