Loading...
const res = await llm.generate({
prompt: 'Write a short product description.',
stop: ['\n'],
});const res = await llm.generate({
prompt: 'Write a product description, then write </answer>.',
stop: ['</answer>'],
});
const text = res.text.trim();A newline appears in normal prose and cuts the answer short; a unique closing tag appears only where the answer ends.
Usually not. Most APIs stop before it and leave it out of the returned text, so do not search for it there.
Max tokens ends output at a length limit; a stop sequence ends it when a chosen string appears. Check the stop reason to tell which one fired.
To end output at a known boundary, such as a closing tag or a turn marker. This saves tokens and makes parsing simpler.