From 7da512eded72efc93628f3568ce9939165535e33 Mon Sep 17 00:00:00 2001 From: Sebastian Husch Lee Date: Tue, 17 Dec 2024 09:06:28 +0100 Subject: [PATCH] Add RuntimeError message --- haystack/components/preprocessors/nltk_document_splitter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/haystack/components/preprocessors/nltk_document_splitter.py b/haystack/components/preprocessors/nltk_document_splitter.py index 1026c78d39..ab787d599d 100644 --- a/haystack/components/preprocessors/nltk_document_splitter.py +++ b/haystack/components/preprocessors/nltk_document_splitter.py @@ -150,6 +150,11 @@ def run(self, documents: List[Document]) -> Dict[str, List[Document]]: :raises TypeError: if the input is not a list of Documents. :raises ValueError: if the content of a document is None. """ + if self.sentence_splitter is None: + raise RuntimeError( + "The component NLTKDocumentSplitter wasn't warmed up. Run 'warm_up()' before calling 'run()'." + ) + if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)): raise TypeError("DocumentSplitter expects a List of Documents as input.")