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

Allowing asynchronous serialization and deserialization within checkpoint savers #529

Open
wpoynter opened this issue Sep 28, 2024 · 1 comment

Comments

@wpoynter
Copy link

wpoynter commented Sep 28, 2024

I am currently in the process of writing a package that uses AWS's Dynamno DB as the persistence store for checkpoint saving. I am keeping the implementation as close to the existing Sqlite and MongoDB checkpoint savers as possible.

In my use case for the library I am creating, I would like the serde to be able to encrypt and decrypt the data. My intention is to use an encryption library that performs asynchronously. There is no reason within my package I cannot support both serdes that work synchronously and asynchronously, but it does deviate from the existing classes.

Proposed Change

My idea is that the SerializationProtocol is updated to allow async methods, e.g.

export interface SerializerProtocol {
    dumpsTyped(data: any): Promise<[string, Uint8Array]> | [string, Uint8Array];
    loadsTyped(type: string, data: Uint8Array | string): Promise<any> | unknown;
}

Then changes are made to MemorySaver, MongoDBSaver, SqliteSaver, and tests to await the calls of dumpsTyped and loadsTyped. This should allow existing users to continue to use synchronous methods without an issue and will allow future use of asynchronous methods.

Possible Issue

The only possible issue that occurs to me is how Langgraph JS behaves if someone provides slow async methods for serialization for some reason?

Doing the work

I am happy to take a stab at the work if it seems like a reasonable idea.

@wpoynter
Copy link
Author

wpoynter commented Oct 2, 2024

PR: #543

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

No branches or pull requests

1 participant