(self, content: str)
| 20 | ) |
| 21 | |
| 22 | def split(self, content: str) -> List[Chunk]: |
| 23 | try: |
| 24 | if not content: |
| 25 | logger.warning("Empty content provided") |
| 26 | return [] |
| 27 | |
| 28 | logger.info(f"Starting to split content of length {len(content)}") |
| 29 | |
| 30 | # use LangChain splitter |
| 31 | texts = self.text_splitter.split_text(content) |
| 32 | |
| 33 | chunks = [ |
| 34 | Chunk( |
| 35 | id=None, |
| 36 | document_id=None, |
| 37 | content=text, |
| 38 | embedding=None, |
| 39 | tags=None, |
| 40 | topic=None, |
| 41 | ) |
| 42 | for text in texts |
| 43 | ] |
| 44 | |
| 45 | logger.info(f"Split completed, created {len(chunks)} chunks") |
| 46 | return chunks |
| 47 | |
| 48 | except Exception as e: |
| 49 | logger.error(f"Error in split method: {str(e)}") |
| 50 | logger.error(traceback.format_exc()) |
| 51 | raise |
no test coverage detected