50 lines
2.7 KiB
Go
50 lines
2.7 KiB
Go
package app
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// AICharacter 角色卡模型
|
|
type AICharacter struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
|
|
|
// 基本信息
|
|
UserID uint `gorm:"index;not null" json:"userId"` // 所属用户ID
|
|
Name string `gorm:"type:varchar(100);not null" json:"name"` // 角色名称
|
|
Avatar string `gorm:"type:text" json:"avatar"` // 头像URL或Base64
|
|
Creator string `gorm:"type:varchar(100)" json:"creator"` // 创建者
|
|
Version string `gorm:"type:varchar(50)" json:"version"` // 角色版本
|
|
IsPublic bool `gorm:"default:false" json:"isPublic"` // 是否公开
|
|
|
|
// SillyTavern V2 格式字段
|
|
Description string `gorm:"type:text" json:"description"` // 角色描述
|
|
Personality string `gorm:"type:text" json:"personality"` // 性格特征
|
|
Scenario string `gorm:"type:text" json:"scenario"` // 场景设定
|
|
FirstMes string `gorm:"type:text" json:"firstMes"` // 第一条消息
|
|
MesExample string `gorm:"type:text" json:"mesExample"` // 消息示例
|
|
CreatorNotes string `gorm:"type:text" json:"creatorNotes"` // 创建者备注
|
|
SystemPrompt string `gorm:"type:text" json:"systemPrompt"` // 系统提示词
|
|
PostHistoryInstructions string `gorm:"type:text" json:"postHistoryInstructions"` // 历史后指令
|
|
Tags datatypes.JSON `gorm:"type:jsonb" json:"tags"` // 标签数组
|
|
AlternateGreetings datatypes.JSON `gorm:"type:jsonb" json:"alternateGreetings"` // 备用问候语
|
|
CharacterBook datatypes.JSON `gorm:"type:jsonb" json:"characterBook"` // 角色书
|
|
Extensions datatypes.JSON `gorm:"type:jsonb" json:"extensions"` // 扩展数据
|
|
Spec string `gorm:"type:varchar(50);default:'chara_card_v2'" json:"spec"` // 规范名称
|
|
SpecVersion string `gorm:"type:varchar(50);default:'2.0'" json:"specVersion"` // 规范版本
|
|
|
|
// 统计信息
|
|
UseCount int `gorm:"default:0" json:"useCount"` // 使用次数
|
|
FavoriteCount int `gorm:"default:0" json:"favoriteCount"` // 收藏次数
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (AICharacter) TableName() string {
|
|
return "ai_characters"
|
|
}
|