Merge pull request '🎨 优化AI对话角色设置,支持为群或者好友单独设置角色(需手动修改数据库)' (#39) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m29s
All checks were successful
BuildImage / build-image (push) Successful in 1m29s
Reviewed-on: #39
This commit is contained in:
commit
21a6f75ed3
@ -15,6 +15,7 @@ type Friend struct {
|
|||||||
LastActive time.Time `json:"lastActive"` // 最后活跃时间
|
LastActive time.Time `json:"lastActive"` // 最后活跃时间
|
||||||
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
EnableAi bool `json:"enableAI" gorm:"type:tinyint(1) default 0 not null"` // 是否使用AI
|
||||||
AiModel string `json:"aiModel"` // AI模型
|
AiModel string `json:"aiModel"` // AI模型
|
||||||
|
Prompt string `json:"prompt"` // 提示词
|
||||||
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
EnableChatRank bool `json:"enableChatRank" gorm:"type:tinyint(1) default 0 not null"` // 是否使用聊天排行
|
||||||
EnableWelcome bool `json:"enableWelcome" gorm:"type:tinyint(1) default 0 not null"` // 是否启用迎新
|
EnableWelcome bool `json:"enableWelcome" gorm:"type:tinyint(1) default 0 not null"` // 是否启用迎新
|
||||||
EnableSummary bool `json:"enableSummary" gorm:"type:tinyint(1) default 0 not null"` // 是否启用总结
|
EnableSummary bool `json:"enableSummary" gorm:"type:tinyint(1) default 0 not null"` // 是否启用总结
|
||||||
|
@ -46,13 +46,19 @@ func AI(m *plugin.MessageContext) {
|
|||||||
m.Content = strings.Replace(m.Content, matches[0], "", 1)
|
m.Content = strings.Replace(m.Content, matches[0], "", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理预设角色,默认是配置文件里的,如果数据库配置不为空,则使用数据库配置
|
||||||
|
prompt := config.Conf.Ai.Personality
|
||||||
|
if friendInfo.Prompt != "" {
|
||||||
|
prompt = friendInfo.Prompt
|
||||||
|
}
|
||||||
|
|
||||||
// 组装消息体
|
// 组装消息体
|
||||||
messages := make([]openai.ChatCompletionMessage, 0)
|
messages := make([]openai.ChatCompletionMessage, 0)
|
||||||
if config.Conf.Ai.Personality != "" {
|
if config.Conf.Ai.Personality != "" {
|
||||||
// 填充人设
|
// 填充人设
|
||||||
messages = append(messages, openai.ChatCompletionMessage{
|
messages = append(messages, openai.ChatCompletionMessage{
|
||||||
Role: openai.ChatMessageRoleSystem,
|
Role: openai.ChatMessageRoleSystem,
|
||||||
Content: config.Conf.Ai.Personality,
|
Content: prompt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user