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 modular SERDE approach #175
base: main
Are you sure you want to change the base?
Conversation
LC documents can now be serialized properly. Note: LC produces things that can look like documents that aren't. E.g. _DocumentWithState Should add tests here eventually.
@@ -20,9 +20,13 @@ | |||
|
|||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, we'll want to put this in a plugin and have a registry. Specifically for default serializers. But this OK as a temporary fix -- the "common" models aren't throw-away code, so let's do the following:
- Comment on TODO
- Open an issue on ser/deser (if we don't have one already) + plugins and document this out
- Link to that issue
I know we already have one in this, but having anything referring lanchain in the core code feels icky, even though its in a guarded setting.
if isinstance(d, list): | ||
return [_serialize_object(x) for x in d] | ||
elif isinstance(d, dict): | ||
return {k: _serialize_object(v) for k, v in d.items()} | ||
elif lc_messages is not None and isinstance(d, lc_messages.BaseMessage): | ||
return lc_messages.message_to_dict(d) | ||
elif lc_documents is not None and isinstance(d, lc_documents.Document): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto with the above. Blech custom serde is ugly...
Singledispatch for type serialization. For non-primitive types, make them return a dict with a serde key. Then use a string value based mechanism to deserialize. This way we can be "field agnostic" during deserialization. Otherwise deserialization without knowing what it is, is a challenge. Thus the idea to include a key in a dict for it. Otherwise the only other way for deserialization is to field registries... TODO: - determine module naming and location - actually wire in - proper tests - how to override these - think about any other edge/error cases
This PR introduces a modular SERDE approach.
of a "string dispatcher function". i.e. like single dispatch, but you register a string value for it. This approach
means that most people will get around the need for field level deserialization / having to tell Burr about state types explicitly.
TODOs:
Changes
How I tested this
Notes
Checklist