One question answered side by side by two or three set-ups (a model and a temperature each), streaming at once with their latency, tokens and cost turning as they go; rate them and pick the winner. Variables in the prompt get fields of their own. On motion.
Installation
When to use
- Comparing set-ups for one prompt: models, temperatures, wording, on the same question, before you ship one.
- AI products where a team tunes prompts and needs to see quality, speed and cost side by side.
When not to use
- A conversation with the assistant: AI assistant or Agent workspace.
- Evaluating hundreds of cases at once: a Data Table of runs fits better.
Usage
Prompt playground with your own data: every prop has the sample as its default, so pass only what you have.
"use client"
import { PromptPlayground } from "@/components/dashral/blocks/prompt-playground"
export default function Playground() {
return (
<PromptPlayground
models={[
{ id: "large", name: "Large model", provider: "Your provider", pricePerMillion: 9 },
{ id: "small", name: "Small model", provider: "Your provider", pricePerMillion: 1.2 },
]}
prompt="You are the support assistant for {{company}}. Answer in two sentences."
values={{ company: "Acme" }}
message="Can I get a refund?"
variants={[
{ id: "a", model: "large", temperature: 0.3 },
{ id: "b", model: "small", temperature: 0.7 },
]}
results={{}}
onRun={async (variant, input, stream) => {
// Stream your model here: stream.write adds text; stop when stream.signal is aborted.
for (const word of `(${variant.model}) You asked: ${input.message}`.split(" ")) {
if (stream.signal.aborted) return
stream.write(word + " ")
await new Promise((resolve) => setTimeout(resolve, 50))
}
stream.done()
}}
onPick={(variant) => console.log("winner", variant.model, variant.temperature)}
/>
)
}API reference
PromptPlayground
A prompt playground: a system prompt with its variables and a message, answered by two or three variants side by side (a model and a temperature each), streaming at once, each with its latency, tokens and cost. Rate them, pick the winner. Run all with the button or ⌘↵; stop any time.
| Prop | Type | Default |
|---|---|---|
title | React.ReactNode | "Prompt playground" |
models | PlaygroundModel[] | sample |
prompt | stringThe system prompt at first; {{name}} marks a variable, each with a field of its own. | sample |
values | Record<string, string>The variables' values at first. | sample |
message | stringThe customer's message, at first. | sample |
variants | PlaygroundVariant[]The variants at first: two or three. | sample |
results | Record<string, PlaygroundResult>What each variant showed before (by variant id), e.g. a saved comparison. | sample |
onRun | (variant: PlaygroundVariant, input: { system: string; message: string }, stream: PlaygroundStream) => Promise<void> | voidRun one variant: stream its answer into | — |
onPick | (variant: PlaygroundVariant) => voidA variant picked as the winner, with what was asked. | — |
onRate | (variant: PlaygroundVariant, rating: "up" | "down" | undefined) => voidA rating given. | — |
className | string | — |
type PlaygroundModel
| Prop | Type | Default |
|---|---|---|
id | string | — |
name | string | — |
provider | string | — |
icon | React.ReactNode | — |
pricePerMillion | number | — |
type PlaygroundVariant
| Prop | Type | Default |
|---|---|---|
id | string | — |
model | string | — |
temperature | number | — |
type PlaygroundResult
| Prop | Type | Default |
|---|---|---|
status | "idle" | "running" | "done" | "error" | — |
text | string | — |
latency | numberIn milliseconds. | — |
tokens | number | — |
cost | numberIn US dollars. | — |
error | string | — |
rating | "up" | "down" | — |
type PlaygroundStream
What onRun writes into: text as it streams, then done with what it used (latency is measured if left out).
| Prop | Type | Default |
|---|---|---|
write | (text: string) => void | — |
done | (usage?: { tokens?: number; latency?: number; cost?: number }) => void | — |
signal | AbortSignalTurns true when the run is stopped; stop streaming then. | — |