Back to Promptfoo

config-websockets/basic (Websockets Provider Example)

examples/config-websockets/basic/README.md

0.121.91.1 KB
Original Source

config-websockets/basic (Websockets Provider Example)

You can run this example with:

bash
npx promptfoo@latest init --example config-websockets/basic
cd config-websockets/basic

This example shows how to connect promptfoo to a WebSocket-based LLM service.

Prerequisites

Quick Start

  1. Start the test server (simulates a WebSocket LLM service):
bash
cd test-server
npm install
node server.js
  1. In a new terminal, run the evaluation:
bash
promptfoo eval

Expected Results

This example will:

  • Start a mock WebSocket server that simulates an LLM service
  • Connect promptfoo to the WebSocket server using the custom provider
  • Run evaluations through the WebSocket connection
  • Demonstrate how to integrate promptfoo with custom WebSocket-based APIs
  • Save results that can be viewed with promptfoo view