Back to Promptfoo

config-node-package (Node Package)

examples/config-node-package/README.md

0.121.91002 B
Original Source

config-node-package (Node Package)

You can run this example with:

bash
npx promptfoo@latest init --example config-node-package
cd config-node-package

This example demonstrates using promptfoo from a Node.js script.

Prerequisites

You can set these in a .env file:

text
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here

Running the Example

  1. Install dependencies:
bash
npm install
  1. Execute the script:
bash
node full-eval.js

Expected Results

The script will:

  • Run evaluations programmatically using the promptfoo Node.js API
  • Save results to output.json
  • Display evaluation metrics in the console
  • Allow you to view detailed results with promptfoo view