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 fc4a6bbc7d
docs(examples): update model references from gpt-4o-mini to gpt-4.1-mini (#4289)
2 months ago
..
360d7b519d
docs(examples): add uniform init commands to all example READMEs (#4068)
3 months ago
fc4a6bbc7d
docs(examples): update model references from gpt-4o-mini to gpt-4.1-mini (#4289)
2 months ago

README.md

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

ts-config (TypeScript Configuration Example for promptfoo)

You can run this example with:

npx promptfoo@latest init --example ts-config

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...