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

Serialize pydantic and other tricky objects correctly from Rust. #1392

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

obi1kenobi
Copy link
Collaborator

@obi1kenobi obi1kenobi commented Jan 8, 2025

From the Rust bindings, import the _serialize_json function from langsmith._internal._serde, then use it as the default fallback if orjson serialization can't handle some object. This makes the Rust serialization code equivalent to the _orjson.dumps() call inside langsmith._internal._serde.dumps_json.

I will handle UTF surrogate characters in a subsequent PR.

From the Rust bindings, import the `_serialize_json` function from `langsmith._internal._serde`, then use it as the default fallback if `orjson` serialization can't handle some object. This makes the Rust serialization code equivalent to the `_orjson.dumps()` call inside `langsmith._internal._serde.dumps_json`.

Open question: do we need to handle UTF surrogate characters similarly to what `langsmith._internal._serde.dumps_json` does? I wasn't able to find enough information on the issue encountered there. If that's still needed, we should do that in a new PR.
@obi1kenobi obi1kenobi force-pushed the pg/serialize_more_python_objects branch from d1abf7c to 7fe888e Compare January 8, 2025 21:06
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