models.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from sqlalchemy import Column, Integer, String, DateTime, Text, BigInteger, Index, JSON
  2. from datetime import datetime
  3. from .db import Base
  4. class KnowledgeParsingContent(Base):
  5. __tablename__ = 'knowledge_parsing_content'
  6. id = Column(BigInteger, primary_key=True, autoincrement=True)
  7. content_id = Column(String(128), nullable=False)
  8. request_id = Column(String(128), nullable=False)
  9. task_id = Column(BigInteger, nullable=False)
  10. parsing_data = Column(Text, comment='结构化数据')
  11. create_time = Column(DateTime, default=datetime.now)
  12. status = Column(Integer, default=0, comment='0: 未开始,1:处理中 2: 处理完成 3:处理失败')
  13. indentify_data = Column(Text, comment='理解的数据')
  14. def __repr__(self):
  15. return f"<KnowledgeParsingContent(id={self.id}, content_id={self.content_id}, status={self.status})>"
  16. class KnowledgeExtractionContent(Base):
  17. __tablename__ = 'knowledge_extraction_content'
  18. id = Column(BigInteger, primary_key=True, autoincrement=True)
  19. request_id = Column(String(128), nullable=False)
  20. parsing_id = Column(BigInteger, nullable=False)
  21. score = Column(Integer, default=-1)
  22. score_reason = Column(Text, comment='打分原因')
  23. data = Column(Text, comment='结构化数据')
  24. clean_reason = Column(Text, comment='清洗原因')
  25. create_at = Column(DateTime, default=datetime.now)
  26. status = Column(Integer, default=0, comment='0: 未开始,1:处理中 2: 处理完成 3:处理失败')
  27. def __repr__(self):
  28. return f"<KnowledgeExtractionContent(id={self.id}, request_id={self.request_id}, status={self.status})>"
  29. class KnowledgeExpandContent(Base):
  30. __tablename__ = 'knowledge_expand_content'
  31. __table_args__ = {
  32. 'comment': '拓展字段'
  33. }
  34. id = Column(BigInteger, primary_key=True, autoincrement=True)
  35. request_id = Column(String(128), nullable=False)
  36. create_time = Column(DateTime, default=datetime.now)
  37. expand_querys = Column(JSON, comment='拓展的query词列表')
  38. keywords = Column(JSON, comment='提取的内容关键词列表')
  39. query = Column(Text, comment='搜索词')
  40. def __repr__(self):
  41. return f"<KnowledgeExpandContent(id={self.id}, request_id={self.request_id})>"