Files
wehub-resource-sync 0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
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) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
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
chore: import upstream snapshot with attribution
2026-07-13 13:24:08 +08:00

67 lines
2.1 KiB
YAML

# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
# Per-test structured output example
# Demonstrates using different JSON schemas for different tests with the same prompt
#
# This example shows how to vary the structured output schema on a per-test basis,
# allowing you to use a single prompt with different response formats.
description: 'Per-test structured output with different JSON schemas'
prompts:
# Single prompt used for all tests
- 'Answer this question: {{question}}'
providers:
- id: openai:gpt-4o-mini
config:
temperature: 0
# Parse JSON output so assertions can access properties directly
defaultTest:
options:
transform: JSON.parse(output)
tests:
# Test 1: Math problem - expects structured math response
- vars:
question: 'What is 15 * 7?'
options:
# Load complete response_format from external file
response_format: file://./schemas/math-response-format.json
assert:
- type: javascript
value: output.answer === 105
- type: javascript
value: typeof output.explanation === 'string'
# Test 2: Another math problem with same schema
- vars:
question: 'What is 23 + 19?'
options:
response_format: file://./schemas/math-response-format.json
assert:
- type: javascript
value: output.answer === 42
# Test 3: Comparison question - different schema!
- vars:
question: 'Compare apples and oranges as fruits'
options:
# Different schema for comparison responses
response_format: file://./schemas/comparison-response-format.json
assert:
- type: javascript
value: output.winner === 'item1' || output.winner === 'item2' || output.winner === 'tie'
- type: javascript
value: output.reasoning.length > 20
# Test 4: Another comparison with same schema
- vars:
question: 'Compare cats and dogs as pets'
options:
response_format: file://./schemas/comparison-response-format.json
assert:
- type: javascript
value: output.winner === 'item1' || output.winner === 'item2' || output.winner === 'tie'