///
import {
computed,
Default,
generateText,
ifElse,
NAME,
pattern,
UI,
type VNode,
} from "commontools";
// ===== Types =====
type SvgDiagramInput = {
topic?: Default;
context?: Default, Record>;
};
type SvgDiagramOutput = {
[NAME]: string;
[UI]: VNode;
topic: string;
diagram: string;
pending: boolean;
};
// ===== Pattern =====
/**
* Generates an SVG diagram illustrating relationships, flows, or structures.
* Designed as "suggestion fuel" - a lightweight utility pattern for visual
* representation of concepts using scalable vector graphics.
*/
const SvgDiagram = pattern(
({ topic, context }) => {
const prompt = computed(() => {
const t = topic || "the following";
return `Create a clear SVG diagram illustrating: ${t}`;
});
const response = generateText({
system:
"You create clear, well-structured SVG diagrams. Output a single