package app import ( "git.echol.cn/loser/ai_proxy/server/global" ) // AiPreset AI预设模型 type AiPreset struct { global.GVA_MODEL Name string `json:"name" gorm:"type:varchar(100);not null;uniqueIndex;comment:预设名称"` Description string `json:"description" gorm:"type:text;comment:预设描述"` Temperature float64 `json:"temperature" gorm:"type:decimal(3,2);default:1.0;comment:温度"` FrequencyPenalty float64 `json:"frequency_penalty" gorm:"type:decimal(3,2);default:0;comment:频率惩罚"` PresencePenalty float64 `json:"presence_penalty" gorm:"type:decimal(3,2);default:0;comment:存在惩罚"` TopP float64 `json:"top_p" gorm:"type:decimal(3,2);default:0.9;comment:Top P"` TopK int `json:"top_k" gorm:"type:int;default:0;comment:Top K"` MaxTokens int `json:"max_tokens" gorm:"type:int;default:4096;comment:最大token数"` Prompts PresetPrompts `json:"prompts" gorm:"type:json;serializer:json;comment:提示词列表"` PromptOrder []PromptOrder `json:"prompt_order" gorm:"type:json;serializer:json;comment:提示词顺序"` RegexScripts []RegexScript `json:"regex_scripts" gorm:"type:json;serializer:json;comment:正则脚本"` Extensions PresetExtensions `json:"extensions" gorm:"type:json;serializer:json;comment:扩展配置"` Enabled bool `json:"enabled" gorm:"default:true;comment:是否启用"` UserID uint `json:"user_id" gorm:"index;comment:用户ID"` } // PresetPrompt 预设提示词 type PresetPrompt struct { Identifier string `json:"identifier"` Name string `json:"name"` Role string `json:"role"` // system, user, assistant Content string `json:"content"` SystemPrompt bool `json:"system_prompt"` Enabled bool `json:"enabled"` Marker bool `json:"marker"` InjectionPosition int `json:"injection_position"` // 0=相对, 1=绝对 InjectionDepth int `json:"injection_depth"` InjectionOrder int `json:"injection_order"` InjectionTrigger []string `json:"injection_trigger"` ForbidOverrides bool `json:"forbid_overrides"` } type PresetPrompts []PresetPrompt // PromptOrder 提示词顺序配置 type PromptOrder struct { CharacterID int `json:"character_id"` Order []PromptOrderItem `json:"order"` } type PromptOrderItem struct { Identifier string `json:"identifier"` Enabled bool `json:"enabled"` } // RegexScript 正则替换脚本 type RegexScript struct { ID string `json:"id"` ScriptName string `json:"scriptName"` FindRegex string `json:"findRegex"` ReplaceString string `json:"replaceString"` TrimStrings []string `json:"trimStrings"` Placement []int `json:"placement"` // 1=用户输入前, 2=AI输出后 Disabled bool `json:"disabled"` MarkdownOnly bool `json:"markdownOnly"` PromptOnly bool `json:"promptOnly"` RunOnEdit bool `json:"runOnEdit"` SubstituteRegex int `json:"substituteRegex"` MinDepth *int `json:"minDepth"` MaxDepth *int `json:"maxDepth"` } // PresetExtensions 预设扩展配置 type PresetExtensions struct { ChatSquash *ChatSquashConfig `json:"ChatSquash,omitempty"` RegexBinding *RegexBindingConfig `json:"RegexBinding,omitempty"` MacroNest bool `json:"MacroNest"` } type ChatSquashConfig struct { Enabled bool `json:"enabled"` SeparateChatHistory bool `json:"separate_chat_history"` ParseClewd bool `json:"parse_clewd"` UserRoleSystem bool `json:"user_role_system"` Role string `json:"role"` StopString string `json:"stop_string"` UserPrefix string `json:"user_prefix"` UserSuffix string `json:"user_suffix"` CharPrefix string `json:"char_prefix"` CharSuffix string `json:"char_suffix"` PrefixSystem string `json:"prefix_system"` SuffixSystem string `json:"suffix_system"` EnableSquashedSeparator bool `json:"enable_squashed_separator"` SquashedSeparatorRegex bool `json:"squashed_separator_regex"` SquashedSeparatorString string `json:"squashed_separator_string"` SquashedPostScriptEnable bool `json:"squashed_post_script_enable"` SquashedPostScript string `json:"squashed_post_script"` } type RegexBindingConfig struct { Regexes []RegexScript `json:"regexes"` } func (AiPreset) TableName() string { return "ai_presets" }