🎨 优化项目结构 && 完善ai配置
This commit is contained in:
@@ -4,51 +4,62 @@ import (
|
||||
"git.echol.cn/loser/ai_proxy/server/global"
|
||||
)
|
||||
|
||||
// AiPreset AI预设模板
|
||||
// AiPreset AI预设模型
|
||||
type AiPreset struct {
|
||||
global.GVA_MODEL
|
||||
UserID uint `json:"userId" gorm:"comment:用户ID;index"`
|
||||
Name string `json:"name" gorm:"comment:预设名称;size:200;not null"`
|
||||
Description string `json:"description" gorm:"comment:预设描述;type:text"`
|
||||
Prompts Prompts `json:"prompts" gorm:"comment:提示词数组;type:jsonb;not null"`
|
||||
RegexScripts RegexScripts `json:"regexScripts" gorm:"comment:正则脚本;type:jsonb"`
|
||||
Temperature float64 `json:"temperature" gorm:"comment:温度;default:1.0"`
|
||||
TopP float64 `json:"topP" gorm:"comment:TopP;default:0.9"`
|
||||
MaxTokens int `json:"maxTokens" gorm:"comment:最大Token数;default:4096"`
|
||||
FrequencyPenalty float64 `json:"frequencyPenalty" gorm:"comment:频率惩罚;default:0"`
|
||||
PresencePenalty float64 `json:"presencePenalty" gorm:"comment:存在惩罚;default:0"`
|
||||
StreamEnabled bool `json:"streamEnabled" gorm:"comment:是否启用流式;default:true"`
|
||||
IsDefault bool `json:"isDefault" gorm:"comment:是否默认;default:false"`
|
||||
IsPublic bool `json:"isPublic" gorm:"comment:是否公开;default:false"`
|
||||
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;comment:提示词列表"`
|
||||
PromptOrder []PromptOrder `json:"prompt_order" gorm:"type:json;comment:提示词顺序"`
|
||||
RegexScripts []RegexScript `json:"regex_scripts" gorm:"type:json;comment:正则脚本"`
|
||||
Extensions PresetExtensions `json:"extensions" gorm:"type:json;comment:扩展配置"`
|
||||
Enabled bool `json:"enabled" gorm:"default:true;comment:是否启用"`
|
||||
UserID uint `json:"user_id" gorm:"index;comment:用户ID"`
|
||||
}
|
||||
|
||||
func (AiPreset) TableName() string {
|
||||
return "ai_presets"
|
||||
}
|
||||
|
||||
// Prompt 提示词结构
|
||||
type Prompt struct {
|
||||
Name string `json:"name"`
|
||||
SystemPrompt bool `json:"system_prompt"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
// PresetPrompt 预设提示词
|
||||
type PresetPrompt struct {
|
||||
Identifier string `json:"identifier"`
|
||||
InjectionPosition int `json:"injection_position"`
|
||||
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"`
|
||||
Marker bool `json:"marker"`
|
||||
ForbidOverrides bool `json:"forbid_overrides"`
|
||||
}
|
||||
|
||||
// RegexScript 正则脚本
|
||||
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"`
|
||||
Placement []int `json:"placement"` // 1=用户输入前, 2=AI输出后
|
||||
Disabled bool `json:"disabled"`
|
||||
MarkdownOnly bool `json:"markdownOnly"`
|
||||
PromptOnly bool `json:"promptOnly"`
|
||||
@@ -57,3 +68,38 @@ type RegexScript struct {
|
||||
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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user