55 lines
3.3 KiB
Go
55 lines
3.3 KiB
Go
package app
|
|
|
|
import (
|
|
"git.echol.cn/loser/st/server/global"
|
|
"github.com/lib/pq"
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// AICharacter AI 角色表
|
|
type AICharacter struct {
|
|
global.GVA_MODEL
|
|
Name string `json:"name" gorm:"type:varchar(500);not null;comment:角色名称"`
|
|
Description string `json:"description" gorm:"type:text;comment:角色描述"`
|
|
Personality string `json:"personality" gorm:"type:text;comment:角色性格"`
|
|
Scenario string `json:"scenario" gorm:"type:text;comment:角色场景"`
|
|
Avatar string `json:"avatar" gorm:"type:varchar(1024);comment:角色头像"`
|
|
CreatorID *uint `json:"creatorId" gorm:"index;comment:创建者ID"`
|
|
Creator *AppUser `json:"creator" gorm:"foreignKey:CreatorID"`
|
|
CreatorName string `json:"creatorName" gorm:"type:varchar(200);comment:创建者名称"`
|
|
CreatorNotes string `json:"creatorNotes" gorm:"type:text;comment:创建者备注"`
|
|
CardData datatypes.JSON `json:"cardData" gorm:"type:jsonb;not null;comment:角色卡片数据"`
|
|
Tags pq.StringArray `json:"tags" gorm:"type:text[];comment:角色标签"`
|
|
IsPublic bool `json:"isPublic" gorm:"default:false;index;comment:是否公开"`
|
|
Version int `json:"version" gorm:"default:1;comment:角色版本"`
|
|
FirstMessage string `json:"firstMessage" gorm:"type:text;comment:第一条消息"`
|
|
ExampleMessages pq.StringArray `json:"exampleMessages" gorm:"type:text[];comment:消息示例"`
|
|
SystemPrompt string `json:"systemPrompt" gorm:"type:text;comment:系统提示词"`
|
|
PostHistoryInstructions string `json:"postHistoryInstructions" gorm:"type:text;comment:后置历史指令"`
|
|
AlternateGreetings pq.StringArray `json:"alternateGreetings" gorm:"type:text[];comment:备用问候语"`
|
|
CharacterBook datatypes.JSON `json:"characterBook" gorm:"type:jsonb;comment:角色书/世界信息"`
|
|
Extensions datatypes.JSON `json:"extensions" gorm:"type:jsonb;comment:扩展数据(depth_prompt等)"`
|
|
TotalChats int `json:"totalChats" gorm:"default:0;comment:对话总数"`
|
|
TotalLikes int `json:"totalLikes" gorm:"default:0;comment:点赞总数"`
|
|
UsageCount int `json:"usageCount" gorm:"default:0;comment:使用次数"`
|
|
FavoriteCount int `json:"favoriteCount" gorm:"default:0;comment:收藏次数"`
|
|
TokenCount int `json:"tokenCount" gorm:"default:0;comment:Token数量"`
|
|
}
|
|
|
|
func (AICharacter) TableName() string {
|
|
return "ai_characters"
|
|
}
|
|
|
|
// AppUserFavoriteCharacter 用户收藏的角色
|
|
type AppUserFavoriteCharacter struct {
|
|
global.GVA_MODEL
|
|
UserID uint `json:"userId" gorm:"not null;index:idx_user_character,unique;comment:用户ID"`
|
|
User *AppUser `json:"user" gorm:"foreignKey:UserID"`
|
|
CharacterID uint `json:"characterId" gorm:"not null;index:idx_user_character,unique;comment:角色ID"`
|
|
Character *AICharacter `json:"character" gorm:"foreignKey:CharacterID"`
|
|
}
|
|
|
|
func (AppUserFavoriteCharacter) TableName() string {
|
|
return "app_user_favorite_characters"
|
|
}
|