Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21a6f75ed3 | ||
|
|
daa36f308b | ||
|
|
e78f6a6d6e | ||
|
|
bb92c67069 | ||
|
|
542a2d5ef6 | ||
|
|
c13771be22 | ||
|
|
982ddef0da | ||
|
|
99447d332d |
@@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,17 +28,17 @@ func AiSummary() {
|
|||||||
log.Printf("获取群[%s]对话记录失败, 错误信息: %v", group.Wxid, err)
|
log.Printf("获取群[%s]对话记录失败, 错误信息: %v", group.Wxid, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//if len(records) < 100 {
|
if len(records) < 100 {
|
||||||
// log.Printf("群[%s]对话记录不足100条,跳过总结", group.Wxid)
|
log.Printf("群[%s]对话记录不足100条,跳过总结", group.Wxid)
|
||||||
// continue
|
continue
|
||||||
//}
|
}
|
||||||
// 组装对话记录为字符串
|
// 组装对话记录为字符串
|
||||||
var content []string
|
var content []string
|
||||||
for _, record := range records {
|
for _, record := range records {
|
||||||
content = append(content, fmt.Sprintf("%s: %s\n-----end-----", record.Nickname, record.Message))
|
content = append(content, fmt.Sprintf("%s: %s\n-----end-----", record.Nickname, record.Message))
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := fmt.Sprintf("请帮我总结一下一下的群聊内容的梗概(内容尽可能详细一些)。\n"+
|
msg := fmt.Sprintf("请帮我总结一下一下的群聊内容的梗概,生成的梗概尽可能详细,并且最好带上名字。\n"+
|
||||||
"注意,他们可能是多个话题,请仔细甄别。\n"+
|
"注意,他们可能是多个话题,请仔细甄别。\n"+
|
||||||
"每一行代表一个人的发言,每一行的的格式为: \n{nickname}: {content}\n-----end-----"+
|
"每一行代表一个人的发言,每一行的的格式为: \n{nickname}: {content}\n-----end-----"+
|
||||||
"\n\n聊天记录如下: \n%s", strings.Join(content, "\n"))
|
"\n\n聊天记录如下: \n%s", strings.Join(content, "\n"))
|
||||||
@@ -75,7 +75,7 @@ func AiSummary() {
|
|||||||
if resp.Choices[0].Message.Content == "" {
|
if resp.Choices[0].Message.Content == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
replyMsg := fmt.Sprintf("#昨日消息总结\n\n%s", resp.Choices[0].Message.Content)
|
replyMsg := fmt.Sprintf("#昨日消息总结\n又是一天过去了,让我们一起来看看昨儿群友们都聊了什么有趣的话题吧~\n\n%s", resp.Choices[0].Message.Content)
|
||||||
utils.SendMessage(group.Wxid, "", replyMsg, 0)
|
utils.SendMessage(group.Wxid, "", replyMsg, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user