MCPcopy
hub / github.com/mindverse/Second-Me / ChunkModel

Class ChunkModel

lpm_kernel/file_data/models.py:23–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class ChunkModel(Base):
24 __tablename__ = "chunk"
25
26 id = Column(BigInteger, primary_key=True)
27 document_id = Column(BigInteger, ForeignKey("document.id"), nullable=False)
28 content = Column(Text, nullable=False)
29 has_embedding = Column(Boolean, default=False)
30 tags = Column(JSON)
31 topic = Column(String(255))
32 create_time = Column(DateTime, default=datetime.utcnow)
33
34 document = relationship("DocumentModel", back_populates="chunks")
35
36 def to_dto(self) -> ChunkDTO:
37 return ChunkDTO(
38 id=self.id,
39 document_id=self.document_id,
40 content=self.content,
41 has_embedding=self.has_embedding, # ensure this field is correctly converted
42 tags=self.tags,
43 topic=self.topic,
44 length=len(self.content) if self.content else 0,
45 )
46
47
48class DocumentModel(Base):

Callers 1

save_chunkMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected