Save document chunk to database Args: chunk (Chunk): Chunk object to save Raises: Exception: Error when saving fails
(self, chunk: Chunk)
| 54 | return topics_data |
| 55 | |
| 56 | def save_chunk(self, chunk: Chunk) -> None: |
| 57 | """ |
| 58 | Save document chunk to database |
| 59 | Args: |
| 60 | chunk (Chunk): Chunk object to save |
| 61 | Raises: |
| 62 | Exception: Error when saving fails |
| 63 | """ |
| 64 | try: |
| 65 | # Create ChunkModel instance |
| 66 | chunk_model = ChunkModel( |
| 67 | document_id=chunk.document_id, |
| 68 | content=chunk.content, |
| 69 | tags=chunk.tags, |
| 70 | topic=chunk.topic, |
| 71 | ) |
| 72 | # Save to database |
| 73 | self._repository.save_chunk(chunk_model) |
| 74 | logger.debug(f"Saved chunk for document {chunk.document_id}") |
| 75 | except Exception as e: |
| 76 | logger.error(f"Error saving chunk: {str(e)}") |
| 77 | raise |
| 78 | |
| 79 | |
| 80 | # Usage elsewhere: |
no test coverage detected