import { Divider } from "@tremor/react"; import { usePlaygroundContext } from "../context"; import { PromptVariableComponent } from "./PromptVariableComponent"; export const Variables = () => { const { promptVariables } = usePlaygroundContext(); const renderNoVariables = () => (

No variables defined.

Use double curly braces in your prompts to add a variable: {{exampleVariable}}

); const renderVariables = () => (
{promptVariables .slice() .sort((a, b) => { if (a.isUsed && !b.isUsed) return -1; if (!a.isUsed && b.isUsed) return 1; return a.name.localeCompare(b.name); }) .map((promptVariable, index) => (
{index !== promptVariables.length - 1 && ( )}
))}
); return (
{promptVariables.length === 0 ? renderNoVariables() : renderVariables()}
); };