Loading...
const outline = await llm.generate({ prompt: outlinePrompt(topic) });
const draft = await llm.generate({ prompt: draftPrompt(outline.text) });const outline = await llm.generate({ prompt: outlinePrompt(topic) });
const sections = parseOutline(outline.text);
if (sections.length === 0) throw new Error('Outline step failed');
const draft = await llm.generate({ prompt: draftPrompt(sections) });Validating each step's output stops a bad outline from silently ruining every step after it.
A chain splits the task so each step is simpler to test and debug. One big prompt needs fewer calls but is harder to control.
Yes. Steps that do not depend on each other can run at the same time, and their results are merged later.
In a chain, code fixes the order of steps. An agent lets the model choose the next step itself.