-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: Add functionality to pass custom serializer #1116
base: main
Are you sure you want to change the base?
Conversation
…se class This refactoring introduces a new BaseEventSerializer abstract base class that provides a common interface and shared functionality for JSON serialization. Key changes include: - Creating an abstract base class with common serialization methods - Moving shared serialization logic to the base class - Adding an abstract default method for object serialization - Implementing safe integer range checking - Updating references in other files to use the new base class
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.
5 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
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.
5 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -60,7 +61,7 @@ def post(self, **kwargs) -> httpx.Response: | |||
"""Post the `kwargs` to the API""" | |||
log = logging.getLogger("langfuse") | |||
url = self._remove_trailing_slash(self._base_url) + "/api/public/ingestion" | |||
data = json.dumps(kwargs, cls=EventSerializer) | |||
data = json.dumps(kwargs, cls=self._serializer) |
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.
Ensure _serializer is initialized (e.g. self._serializer = EventSerializer) in init as it's used in json.dumps but not set.
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.
LGTM
5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Introduce BaseEventSerializer as an abstract base class
This refactoring introduces a new BaseEventSerializer abstract base class that provides a common interface and shared functionality for JSON serialization. Key changes include:
Creating an abstract base class with common serialization methods
Moving shared serialization logic to the base class
Adding an abstract default method for object serialization
Implementing safe integer range checking
Updating references in other files to use the new base class
documentation with explanation
JS SDK
Greptile Summary
Disclaimer: Experimental PR review
Introduces a new BaseEventSerializer abstract base class to standardize JSON serialization across the codebase, enabling custom serializer implementations while maintaining existing functionality.
_serializer
field inLangfuseClient.__init__
inlangfuse/request.py
needs to be added to prevent runtime errorsIngestionConsumer._serializer
defined as class variable could cause shared state issues with multiple instancesIngestionConsumer
to configure custom serializers without subclassingBaseEventSerializer
with requireddefault()
method inlangfuse/serializer.py
💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!