Prompt Template

View as Markdown

Write a prompt with {{variables}} the app fills in: they stand out, unknown ones are flagged, and a preview shows it with samples.

326 characters

Unknown: {{agent.nmae}} isn't a variable the app fills in, so it would be sent as written.

Variables

  • Used 1 time

    The customer's first name

  • Used 1 time

    Their plan: Free, Team or Business

  • Used 1 time

    The ticket's subject line

  • Used 1 time

    What they wrote, as plain text

  • Not used

    The person the reply is signed by

  • Not used

    Today's date in the customer's language

  • UnknownUsed 1 time

Preview

You draft replies for the support team. Be brief and warm, and never promise dates. The customer is Ada, on the Team plan. Subject: Can't export invoices to CSV They wrote: Every export since Monday comes back empty. We close the month on Friday. Answer what they asked, in their language. If it's a bug, say we've passed it to the team. Sign off as {{agent.nmae}}.

When to use

Write a prompt with {{variables}} the app fills in: they stand out, unknown ones are flagged, and a preview shows it with samples. Use Composer instead when the text is a message to send now, with no {{variables}} for the app to fill in.

Usage

import { PromptTemplate } from "./ui/uicontext/components/PromptTemplate.ts"
export const Instructions = <M>(h: Html.H<M>, prompt: string, onChange: (text: string) => M) =>	PromptTemplate(h, {		props: {			label: "Instructions",			value: prompt,			variables: [{ name: "customer.name", description: "The customer's first name", sample: "Ada" }],		},		onEmit: { RequestedChange: ({ value }) => onChange(value) },	})

Examples

Variables the writer makes up

Without variables, any name goes: each is listed so it can be tried with a sample.

118 characters

Variables

  • Used 1 time
  • Used 1 time
  • Used 1 time

Preview

Summarize {{doc}} for {{audience}} in {{length}} bullet points. Keep the numbers exact and say what's still undecided.

API reference

Props

PromptTemplate props
NameTypeDefaultDescription
labelrequiredstring—The editor's name: "Instructions".
valuerequiredstring—The template to start with.
variablesTemplateVariable[]—The variables the app fills in. Without it, any name goes and nothing is flagged.
rowsnumber6The editor's height in lines before it grows; 6 by default.
idstring"prompt"Starts the ids inside it, unique on the page; "prompt" by default.
placeholderstring——
localestring—For the counts; the browser's by default.

Events

PromptTemplate events
EventPayloadDescription
RequestedChange{ value: string; unknown: string[] }The text changed: the template, and the variables in it the app doesn't offer.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/prompt-template

Source