AiMessage.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package io.github.qifan777.knowledge.ai.message;
  2. import io.github.qifan777.knowledge.ai.session.AiSession;
  3. import io.github.qifan777.knowledge.infrastructure.jimmer.BaseEntity;
  4. import jakarta.validation.constraints.Null;
  5. import lombok.AllArgsConstructor;
  6. import lombok.Data;
  7. import lombok.experimental.Accessors;
  8. import org.babyfish.jimmer.sql.*;
  9. import org.springframework.ai.chat.messages.MessageType;
  10. import java.util.List;
  11. /**
  12. * 历史消息
  13. */
  14. @Entity
  15. public interface AiMessage extends BaseEntity {
  16. /**
  17. * 消息类型(用户/助手/系统)
  18. */
  19. MessageType type();
  20. /**
  21. * 消息内容
  22. */
  23. String textContent();
  24. @Serialized
  25. @Null
  26. List<Media> medias();
  27. @IdView
  28. String sessionId();
  29. /**
  30. * 会话
  31. */
  32. @ManyToOne
  33. @JoinColumn(name = "ai_session_id")
  34. @OnDissociate(DissociateAction.DELETE)
  35. AiSession session();
  36. @Data
  37. @Accessors(chain = true)
  38. class Media {
  39. public String type;
  40. public String data;
  41. }
  42. }