Skip to content

Commit 80341fa

Browse files
committed
docs(prompts): adds stream docs
1 parent 1e1f29b commit 80341fa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/prompts/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,20 @@ log.error('Error!');
188188
log.message('Hello, World', { symbol: color.cyan('~') });
189189
```
190190

191+
192+
### Stream
193+
194+
When interacting with dynamic LLMs or other streaming message providers, use the `stream` APIs to log messages from an iterable, even an async one.
195+
196+
```js
197+
import { stream } from '@clack/prompts';
198+
199+
stream.info((function *() { yield 'Info!'; })());
200+
stream.success((function *() { yield 'Success!'; })());
201+
stream.step((function *() { yield 'Step!'; })());
202+
stream.warn((function *() { yield 'Warn!'; })());
203+
stream.error((function *() { yield 'Error!'; })());
204+
stream.message((function *() { yield 'Hello'; yield ", World" })(), { symbol: color.cyan('~') });
205+
```
206+
191207
[clack-log-prompts](https://github.com/natemoo-re/clack/blob/main/.github/assets/clack-logs.png)

0 commit comments

Comments
 (0)