Skip to content

Are Document objects supposed to be immutable? #1838

Open
@ThomasVitale

Description

@ThomasVitale

The Document class contains only final fields (except "embeddings" which is about to be removed). However, the media (collection) and metadata (map) are mutable. All vector store implementations, at least, rely on the metadata field to be mutable because they add new metadata.

#1794 introduced a mutate() method to build new instances of Document objects. This issue is to discuss whether Document should be immutable. If yes, we need to to refactor all vector store implementations to work accordingly. Also, it's a breaking change, so it should be documented and communicated in the release notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    designquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions