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 cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago
..
cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago
cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago
cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago
cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago
cb02b7dd54
chore(examples): add redteam multi-turn chatbot example (#2306)
8 months ago

README.md

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

Redteaming a Multi-turn Chatbot

Introduction

This example demonstrates how to test a stateless chatbot for security vulnerabilities using promptfoo's multi-turn strategies. It includes a Node.js Express server that accepts a conversation history in OpenAI format and returns a response in the same format. It leverages promptfoo's goat and crescendo strategies for multi-turn redteaming. You can learn more about configuring these strategies here.

Setup

Installation

  1. Install dependencies:
npm install
  1. Set your OpenAI API key:
export OPENAI_API_KEY=your-api-key-here
  1. Start the server:
npm start

Running Tests

# Generate test cases
promptfoo redteam generate

# Execute evaluation
promptfoo redteam eval

# View results
promptfoo view

Node.js Webserver Example Usage

Single Message Request

curl -X POST http://localhost:2345/chat \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer your-token-here" \
    -d '{
        "api_provider": "openai",
        "chat_history": [
            {"role": "user", "content": "Tell me about your turboencabulator models"}
        ]
    }'

Multi-turn Conversation

curl -X POST http://localhost:2345/chat \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer your-token-here" \
    -d '{
        "api_provider": "openai",
        "chat_history": [
            {"role": "user", "content": "Tell me about your turboencabulator models"},
            {"role": "assistant", "content": "TurboTech offers several turboencabulator models..."},
            {"role": "user", "content": "What maintenance does it require?"}
        ]
    }'
Tip!

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

Comments

Loading...