Skip to content

Conversation

@natemoo-re
Copy link
Member

This PR adds a stream API which has all the same methods as log but has support for Iterator and AsyncIterator. This is particularly useful for AI responses which are dynamically generated by LLMs.

stream.info((function *() {
  yield 'Info!';
  yield* generateLLMResponse(question);
})());
stream.success((function *() {
  yield 'Success!';
  yield* generateLLMResponse(question);
})());
stream.step((function *() {
  yield 'Step!';
  yield* generateLLMResponse(question);
})());
stream.warn((function *() {
  yield 'Warn!';
  yield* generateLLMResponse(question);
})());
stream.error((function *() {
  yield 'Error!';
  yield* generateLLMResponse(question);
})());

Huge thanks to @mattpocock for the original feature request on Bluesky.

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 8d0a20c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clack/prompts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2025

Open in Stackblitz@example/basic@example/changesets

npm i https://pkg.pr.new/bombshell-dev/clack/@clack/core@231
npm i https://pkg.pr.new/bombshell-dev/clack/@clack/prompts@231

commit: 8d0a20c

@natemoo-re natemoo-re merged commit a38b2bc into main Feb 5, 2025
6 checks passed
@natemoo-re natemoo-re deleted the feat/stream branch February 5, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants