Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds stream API #231

Merged
merged 5 commits into from
Feb 5, 2025
Merged

Adds stream API #231

merged 5 commits into from
Feb 5, 2025

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.

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

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.

1 participant