Files
st/server/model/app/ai_message.go

47 lines
2.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package app
import (
"git.echol.cn/loser/st/server/global"
"gorm.io/datatypes"
)
// AIMessage 消息表
type AIMessage struct {
global.GVA_MODEL
ChatID uint `json:"chatId" gorm:"not null;index:idx_chat_sequence;comment:所属对话ID"`
Chat *AIChat `json:"chat" gorm:"foreignKey:ChatID"`
Content string `json:"content" gorm:"type:text;not null;comment:消息内容"`
Role string `json:"role" gorm:"type:varchar(50);not null;comment:发送者类型"`
SenderID *uint `json:"senderId" gorm:"comment:发送者ID"`
Sender *AppUser `json:"sender" gorm:"foreignKey:SenderID"`
CharacterID *uint `json:"characterId" gorm:"comment:AI角色ID"`
Character *AICharacter `json:"character" gorm:"foreignKey:CharacterID"`
SequenceNumber int `json:"sequenceNumber" gorm:"not null;index:idx_chat_sequence;comment:消息序号"`
Model string `json:"model" gorm:"type:varchar(200);comment:AI模型"`
PromptTokens int `json:"promptTokens" gorm:"default:0;comment:提示词Token数"`
CompletionTokens int `json:"completionTokens" gorm:"default:0;comment:补全Token数"`
TotalTokens int `json:"totalTokens" gorm:"default:0;comment:总Token数"`
GenerationParams datatypes.JSON `json:"generationParams" gorm:"type:jsonb;comment:生成参数"`
Metadata datatypes.JSON `json:"metadata" gorm:"type:jsonb;comment:消息元数据"`
IsDeleted bool `json:"isDeleted" gorm:"default:false;comment:是否被删除"`
}
func (AIMessage) TableName() string {
return "ai_messages"
}
// AIMessageSwipe 消息变体表swipe 功能)
type AIMessageSwipe struct {
global.GVA_MODEL
MessageID uint `json:"messageId" gorm:"not null;index:idx_message_swipe,unique;comment:消息ID"`
Message *AIMessage `json:"message" gorm:"foreignKey:MessageID"`
Content string `json:"content" gorm:"type:text;not null;comment:变体内容"`
SwipeIndex int `json:"swipeIndex" gorm:"not null;index:idx_message_swipe,unique;comment:变体序号"`
IsActive bool `json:"isActive" gorm:"default:false;comment:是否为当前选中"`
GenerationParams datatypes.JSON `json:"generationParams" gorm:"type:jsonb;comment:生成参数"`
}
func (AIMessageSwipe) TableName() string {
return "ai_message_swipes"
}