Early bird: 30% off Dashral ProSee pricing

Dashral

Prompt playgroundPro

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.

example.tsx
"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.

PropTypeDefault
titleReact.ReactNode"Prompt playground"
modelsPlaygroundModel[]sample
promptstring

The system prompt at first; {{name}} marks a variable, each with a field of its own.

sample
valuesRecord<string, string>

The variables' values at first.

sample
messagestring

The customer's message, at first.

sample
variantsPlaygroundVariant[]

The variants at first: two or three.

sample
resultsRecord<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> | void

Run one variant: stream its answer into stream. A throw shows its message in the variant.

—
onPick(variant: PlaygroundVariant) => void

A variant picked as the winner, with what was asked.

—
onRate(variant: PlaygroundVariant, rating: "up" | "down" | undefined) => void

A rating given.

—
classNamestring—

type PlaygroundModel

PropTypeDefault
idstring—
namestring—
providerstring—
iconReact.ReactNode—
pricePerMillionnumber—

type PlaygroundVariant

PropTypeDefault
idstring—
modelstring—
temperaturenumber—

type PlaygroundResult

PropTypeDefault
status"idle" | "running" | "done" | "error"—
textstring—
latencynumber

In milliseconds.

—
tokensnumber—
costnumber

In US dollars.

—
errorstring—
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).

PropTypeDefault
write(text: string) => void—
done(usage?: { tokens?: number; latency?: number; cost?: number }) => void—
signalAbortSignal

Turns true when the run is stopped; stop streaming then.

—