-
Notifications
You must be signed in to change notification settings - Fork 2.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
Document: Explicitly check that pageContents is not an empty string. #2836
base: main
Are you sure you want to change the base?
Document: Explicitly check that pageContents is not an empty string. #2836
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Ideally we shouldn't need this with TypeScript, but an empty string should be permissible, just not a hard |
Sure I change this out to allow it to record an empty string.
…On Mon, 9 Oct 2023, 18:41 Jacob Lee, ***@***.***> wrote:
Ideally we shouldn't need this with TypeScript, but an empty string should
be permissible, just not a hard undefined, null, or non-string value -
can you change?
—
Reply to this email directly, view it on GitHub
<#2836 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAES7ZPDXG2I724JOIJLWXLX6QZMBAVCNFSM6AAAAAA5XQOJCWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJTGQYDQMBXHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@jacoblee93 I added the proposed change and threw in a couple of unit tests for good measure. |
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.
Hey @skarard sorry for taking so long to review, these changes look good! We've moved document.ts
into langchain-core/src/documents/document.ts
, could you push up a change moving your changes into that updated file then re-request my review?
Thanks again!
…cument-constructor-throw-on-empty-pageContent
This PR is related to a discussion in #2807, the current behaviour of the Document constructor
field.pageContent
when given an empty string is to setpageContent
asundefined
. This brokeHNSWLib.addDocuments()
as it attempts a string.replace() onundefined
rather than the typedstring
expected.I suggested allowing
pageContents
to be set as an empty string. @jacoblee93 suggested that a Document with an emptypageContents
should not be created at all.This implementation requires
pageContents
to be a string that is not empty, otherwise it throwsError("pageContents must not be empty")
.