Skip to content

Use custom chunk_transformer passed to ModelSource - #21

Open
davidbp845 wants to merge 1 commit into
wagtail:mainfrom
davidbp845:fix/20-model-source-custom-chunk-transformer
Open

davidbp845 wants to merge 1 commit into
wagtail:mainfrom
davidbp845:fix/20-model-source-custom-chunk-transformer

Conversation

@davidbp845

Copy link
Copy Markdown

ModelSource.init only assigned self.chunk_transformer when no transformer was passed, so passing one raised AttributeError on the first access.

Fixes #20

Description

Only an else had to be added to assign self.chunk_transformer = chunk_transformer

I reproduced it on main with the snippet below:

source = ModelSource(model=Book, chunk_transformer=ParagraphChunkTransformer())
list(source.get_documents())

AI usage

Note on AI usage: I used Claude Code to help find this bug and to write the test. I wrote the fix myself and ran the full test suite locally.

ModelSource.__init__ only assigned self.chunk_transformer when no
transformer was passed, so passing one raised AttributeError on the
first access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attribute error in a chunk_transformer

1 participant