-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NA] Improve langchain data serialization (#414)
* Move jsonable_encoder.py to Opik root * Implement langchain extension for encoder. Fix lint errors * Add missing file, move encoder extension registering to opik_tracer file * Fix lint errors
- Loading branch information
1 parent
e553bf2
commit de25b6f
Showing
7 changed files
with
32 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from .opik_tracer import OpikTracer | ||
|
||
|
||
__all__ = ["OpikTracer"] |
13 changes: 13 additions & 0 deletions
13
sdks/python/src/opik/integrations/langchain/opik_encoder_extension.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Any | ||
from langchain.load import serializable | ||
from opik import jsonable_encoder | ||
|
||
|
||
def register() -> None: | ||
def encoder_extension(obj: serializable.Serializable) -> Any: | ||
return obj.to_json() | ||
|
||
jsonable_encoder.register_encoder_extension( | ||
obj_type=serializable.Serializable, | ||
encoder=encoder_extension, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters