0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
93 lines
2.6 KiB
Markdown
93 lines
2.6 KiB
Markdown
---
|
|
sidebar_label: Sequence
|
|
description: 'Chain multiple AI providers sequentially to create sophisticated evaluation workflows with data transformation and routing'
|
|
---
|
|
|
|
# Sequence Provider
|
|
|
|
The Sequence Provider allows you to send a series of prompts to another provider in sequence, collecting and combining all responses. This is useful for multi-step interactions, conversation flows, or breaking down complex prompts into smaller pieces.
|
|
|
|
## Configuration
|
|
|
|
To use the Sequence Provider, set the provider `id` to `sequence` and provide a configuration object with an array of inputs:
|
|
|
|
```yaml
|
|
providers:
|
|
- id: sequence
|
|
config:
|
|
inputs:
|
|
- 'First question: {{prompt}}'
|
|
- 'Follow up: Can you elaborate on that?'
|
|
- 'Finally: Can you summarize your thoughts?'
|
|
separator: "\n---\n" # Optional, defaults to "\n---\n"
|
|
```
|
|
|
|
## How It Works
|
|
|
|
The Sequence Provider:
|
|
|
|
1. Takes each input string from the `inputs` array
|
|
2. Renders it using Nunjucks templating (with access to the original prompt and test variables)
|
|
3. Sends it to the original provider
|
|
4. Collects all responses
|
|
5. Joins them together using the specified separator
|
|
|
|
## Usage Example
|
|
|
|
Here's a complete example showing how to use the Sequence Provider to create a multi-turn conversation:
|
|
|
|
```yaml
|
|
providers:
|
|
- openai:chat:gpt-4
|
|
- id: sequence
|
|
config:
|
|
inputs:
|
|
- 'What is {{prompt}}?'
|
|
- 'What are the potential drawbacks of {{prompt}}?'
|
|
- 'Can you summarize the pros and cons of {{prompt}}?'
|
|
separator: "\n\n=== Next Response ===\n\n"
|
|
|
|
prompts:
|
|
- 'artificial intelligence'
|
|
|
|
tests:
|
|
- vars:
|
|
prompt: artificial intelligence
|
|
assert:
|
|
- type: contains
|
|
value: drawbacks
|
|
- type: contains
|
|
value: pros and cons
|
|
```
|
|
|
|
## Variables and Templating
|
|
|
|
Each input string supports Nunjucks templating and has access to:
|
|
|
|
- The original `prompt`
|
|
- Any variables defined in the test context
|
|
- Any custom filters you've defined
|
|
|
|
For example:
|
|
|
|
```yaml
|
|
providers:
|
|
- id: sequence
|
|
config:
|
|
inputs:
|
|
- 'Question about {{topic}}: {{prompt}}'
|
|
- 'Follow up: How does {{topic}} relate to {{industry}}?'
|
|
tests:
|
|
- vars:
|
|
topic: AI
|
|
industry: healthcare
|
|
prompt: What are the main applications?
|
|
```
|
|
|
|
## Configuration Options
|
|
|
|
| Option | Type | Required | Default | Description |
|
|
| --------- | -------- | -------- | --------- | ---------------------------------------------- |
|
|
| inputs | string[] | Yes | - | Array of prompt templates to send sequentially |
|
|
| separator | string | No | "\n---\n" | String used to join the responses |
|