-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix: truncate ByteStream string representation #8673
Conversation
Pull Request Test Coverage Report for Build 12656140645Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
I totally understand the problem.
At this point, I would propose to be more radical, taking inspiration from Document
haystack/haystack/dataclasses/document.py
Line 83 in 7b4d9ba
f"content: '{self.content}'" if len(self.content) < 100 else f"content: '{self.content[:100]}...'" |
- truncate the data to 100 characters
- minor: introduce
__repr__
instead of__str__
, so that this also reflected when a user accesses theByteStream
in a notebook
LMK if you see any drawbacks in these proposals.
Sounds reasonable. I will also remove dataclass's default impl. Just a bit more on this, as there are many opinions on the web that the resulting repr should be unambiguous:
So our approach would be something in between those two. I think this is fine and way better than
One last thing on being unambiguous. The object's |
I agree with your analysis! |
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!
Related Issues
haystack/haystack/components/converters/txt.py
Line 90 in 04fc187
Proposed Changes:
data
in str representation ofByteStream
to 1kHow did you test it?
Notes for the reviewer
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.