Find answers from the community

Updated 2 months ago

Hi I am trying to customize the

Hi, I am trying to customize the SentenceWindowNodeParser e.g. change the chunk_length and the splitter. How can I do it?
b
L
P
7 comments
If you're using the SentenceWindowNodeParser it doesn't look like you can customize the splitter,

you can only customize sentence_splitter etc

If you want more customization try the SimpleNodeParser
You can actually change the splitter, but it's a bit janky (so I decided not to expose it in the docs lol)

In from_defaults(), you can pass in sentence_splitter which is a callable function with str in , List[str] out
@Logan M Hi, I have tried doing it but getting some errors. Can you give me an example of how to pass the sentence_splitter into it?
Here's a very bad/naive example

Plain Text
def my_splitter(text: str) -> List[str]:
  return text.split('. ')

node_parser = SentenceWindowNodeParser.from_defaults(..., sentence_splitter=my_splitter)
got it thanks
Add a reply
Sign up and join the conversation on Discord