healthapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
812 B

package model
import "gorm.io/gorm"
// Conversation 对话
type Conversation struct {
gorm.Model
UserID uint `gorm:"index" json:"user_id"`
Title string `gorm:"size:200" json:"title"`
Messages []Message `gorm:"foreignKey:ConversationID" json:"messages,omitempty"`
}
// Message 消息
type Message struct {
gorm.Model
ConversationID uint `gorm:"index" json:"conversation_id"`
Role string `gorm:"size:20" json:"role"` // user, assistant, system
Content string `gorm:"type:text" json:"content"`
}
// MessageRole 消息角色常量
const (
RoleUser = "user"
RoleAssistant = "assistant"
RoleSystem = "system"
)
// TableName 指定表名
func (Conversation) TableName() string {
return "conversations"
}
func (Message) TableName() string {
return "messages"
}