Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Promptfoo Promptfoo Table Renderer

From Leeroopedia
Knowledge Sources
Domains CLI, Display
Last Updated 2026-02-14 07:45 GMT

Overview

Concrete tool for rendering evaluation results as formatted ASCII tables for terminal output, with color-coded PASS/FAIL indicators.

Description

The Table_Renderer module (table.ts) provides two functions: generateTable() renders an EvaluateTable (evaluation results) as a colored ASCII table with PASS (green) and FAIL/ERROR (red) indicators, and wrapTable() renders arbitrary key-value row data as a plain ASCII table. Both respect TERMINAL_MAX_WIDTH for column sizing and use cli-table3 for formatting.

Usage

Called after evaluation completion to display results in the terminal. The generateTable function is used for evaluation output, while wrapTable is used for general tabular displays (e.g., provider lists, config summaries).

Code Reference

Source Location

Signature

export function generateTable(
  evaluateTable: EvaluateTable,
  tableCellMaxLength?: number,
  maxRows?: number,
): string

export function wrapTable(
  rows: Record<string, string | number>[],
  columnWidths?: Record<string, number>,
): string

Import

import { generateTable, wrapTable } from './table';

I/O Contract

Inputs

Name Type Required Description
evaluateTable EvaluateTable Yes Evaluation results with head (prompts/vars) and body (outputs)
tableCellMaxLength number No Maximum characters per cell (default: 250)
maxRows number No Maximum rows to display (default: 25)
rows Record[] Yes (wrapTable) Array of row objects

Outputs

Name Type Description
table string Formatted ASCII table string for terminal output

Usage Examples

import { generateTable, wrapTable } from './table';

// Render evaluation results
const tableStr = generateTable(evaluateTable, 250, 25);
console.log(tableStr);

// Render arbitrary data
const summary = wrapTable([
  { Provider: 'openai:gpt-4o', Tests: 10, Pass: 8, Fail: 2 },
  { Provider: 'anthropic:claude-3', Tests: 10, Pass: 9, Fail: 1 },
]);
console.log(summary);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment