Skip to content

feat: add withSnapshot API #97

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

Merged
merged 22 commits into from
May 20, 2025
Merged

feat: add withSnapshot API #97

merged 22 commits into from
May 20, 2025

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Apr 30, 2025

add snapshot API, for human in the loop feature. The API is designed for cross JavaScript platform, including node.js, browser, and serverless platform such as cloudflare worker and edge runtime

  • workflow.createContext(): Context
  • context.snapshot(): Promise<[requestEvent, snapshot]>
    This will stop all incoming handler, lock the context and wait until all existing handler get result.
  • workflow.resume(data, snapshot)

Recover all pending events in the queue and send request event back

Test Code sample

image

Copy link

changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: 6784e5b

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

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 Apr 30, 2025

Open in StackBlitz

npm i https://pkg.pr.new/run-llama/llama-flow/@llama-flow/core@97
npm i https://pkg.pr.new/run-llama/llama-flow/@llama-flow/http@97
npm i https://pkg.pr.new/run-llama/llama-flow/@llama-flow/llamaindex@97

commit: 6784e5b

Copy link
Contributor

github-actions bot commented Apr 30, 2025

@himself65 himself65 marked this pull request as ready for review April 30, 2025 21:39
@himself65 himself65 marked this pull request as draft May 1, 2025 00:00
@himself65
Copy link
Member Author

waiting for feedback

@himself65
Copy link
Member Author

self review:

  • move some async iterator helper into WorkflowStream
  • type is missing in resume API?

@himself65 himself65 mentioned this pull request Apr 30, 2025
2 tasks
@himself65 himself65 marked this pull request as ready for review May 20, 2025 02:46
@himself65 himself65 merged commit 9c65785 into main May 20, 2025
11 checks passed
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