chat.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package models
  2. // AIConversation AI对话主表
  3. type AIConversation struct {
  4. BaseModel
  5. UserId uint64 `gorm:"type:bigint;not null;comment:用户ID" json:"user_id"`
  6. Content string `gorm:"type:text;not null;comment:对话内容" json:"content"`
  7. BusinessType int `gorm:"type:tinyint;not null;comment:业务类型(0、AI问答,1、安全培训,2、AI写作,3、考试工坊)" json:"business_type"`
  8. ExamName string `gorm:"type:varchar(255);not null;comment:考试名称" json:"exam_name"`
  9. //步骤
  10. Step int `gorm:"type:int;not null;comment:步骤" json:"step"`
  11. //封面图
  12. CoverImage string `gorm:"type:varchar(1000);not null;comment:封面图" json:"cover_image"`
  13. //PPTjson地址
  14. PPTJsonUrl string `gorm:"type:varchar(1000);not null;comment:PPTjson地址" json:"ppt_json_url"`
  15. //PPTJson内容
  16. PPTJsonContent string `gorm:"type:longtext;not null;comment:PPTjson内容" json:"ppt_json_content"`
  17. //PPT大纲
  18. PPTOutline string `gorm:"type:longtext;not null;comment:PPT大纲" json:"ppt_outline"`
  19. }
  20. // TableName 指定表名
  21. func (AIConversation) TableName() string {
  22. return "ai_conversation"
  23. }
  24. // AIMessage AI对话消息表
  25. type AIMessage struct {
  26. BaseModel
  27. UserId uint64 `gorm:"type:bigint;not null;comment:用户ID" json:"user_id"`
  28. Content string `gorm:"type:longtext;not null;comment:对话内容" json:"content"`
  29. Type string `gorm:"type:varchar(20);not null;comment:对话类型(user、ai)" json:"type"`
  30. UserFeedback int `gorm:"type:tinyint;not null;comment:用户反馈(0、无反馈,2、满意(赞),3、不满意(踩))" json:"user_feedback"`
  31. //绑定上一句的用户问题ID
  32. PrevUserId uint64 `gorm:"type:bigint;not null;comment:上一句的用户问题ID" json:"prev_user_id"`
  33. AIConversationId uint64 `gorm:"type:bigint;not null;comment:AI对话ID" json:"ai_conversation_id"`
  34. //搜索来源
  35. SearchSource string `gorm:"type:longtext;not null;comment:搜索来源" json:"search_source"`
  36. //猜你想问
  37. GuessYouWant string `gorm:"type:varchar(255);not null;comment:猜你想问" json:"guess_you_want"`
  38. }
  39. // TableName 指定表名
  40. func (AIMessage) TableName() string {
  41. return "ai_message"
  42. }
  43. // 索引文件表
  44. type IndexFile struct {
  45. BaseModel
  46. FileName string `gorm:"type:varchar(255);not null;comment:文件名" json:"file_name"`
  47. FilePath string `gorm:"type:varchar(1000);not null;comment:文件路径" json:"file_path"`
  48. //编码
  49. Encoding string `gorm:"type:varchar(255);not null;comment:编码" json:"encoding"`
  50. }
  51. // TableName 指定表名
  52. func (IndexFile) TableName() string {
  53. return "index_file"
  54. }
  55. // 问答QA对表
  56. type QA struct {
  57. BaseModel
  58. Question string `gorm:"type:varchar(255);not null;comment:问题" json:"question"`
  59. Answer string `gorm:"type:varchar(255);not null;comment:答案" json:"answer"`
  60. }
  61. // TableName 指定表名
  62. func (QA) TableName() string {
  63. return "qa"
  64. }