fix: 思考对话历史中识别管理员 — 含【管理员】标记的消息标签为'管理员'而非'用户'
之前所有非昔涟的消息都标为[用户],管理员在群聊中的发言也不例外, 导致模型将管理员误认为普通群友。现在检测内容中的【管理员】前缀。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -818,6 +818,36 @@ func (t *Thinker) performThink(triggerReason string) {
|
|||||||
log.Printf("[后台思考] 频道记忆补充 %d 条", len(memories)-oldCount)
|
log.Printf("[后台思考] 频道记忆补充 %d 条", len(memories)-oldCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also pull recent channel/group memories so the model is aware of group activity.
|
||||||
|
if t.memClient != nil && len(t.platformChannels) > 0 {
|
||||||
|
chanSeen := make(map[string]bool)
|
||||||
|
for _, m := range memories {
|
||||||
|
chanSeen[m.ID] = true
|
||||||
|
}
|
||||||
|
oldCount := len(memories)
|
||||||
|
for _, ch := range t.platformChannels {
|
||||||
|
namespace := fmt.Sprintf("platform_%s_%s_%s", ch.Platform, ch.ChannelType, ch.ChannelID)
|
||||||
|
chanMems, cErr := t.memClient.Query(ctx, model.MemoryQuery{
|
||||||
|
UserID: namespace,
|
||||||
|
Limit: 5,
|
||||||
|
})
|
||||||
|
if cErr != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, m := range chanMems {
|
||||||
|
if !chanSeen[m.ID] {
|
||||||
|
chanSeen[m.ID] = true
|
||||||
|
labeled := m
|
||||||
|
labeled.Content = fmt.Sprintf("[群聊%s] %s", ch.ChannelID, m.Content)
|
||||||
|
memories = append(memories, labeled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(memories) > oldCount {
|
||||||
|
log.Printf("[后台思考] 频道记忆补充 %d 条", len(memories)-oldCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 查询 IoT 设备状态(每次都查询,无间隔限制)
|
// 4. 查询 IoT 设备状态(每次都查询,无间隔限制)
|
||||||
@@ -1150,6 +1180,8 @@ func (t *Thinker) buildThinkingUserPrompt(
|
|||||||
roleLabel := "用户"
|
roleLabel := "用户"
|
||||||
if msg.Role == model.RoleAssistant {
|
if msg.Role == model.RoleAssistant {
|
||||||
roleLabel = "昔涟"
|
roleLabel = "昔涟"
|
||||||
|
} else if strings.Contains(msg.Content, "【管理员】") {
|
||||||
|
roleLabel = "管理员"
|
||||||
}
|
}
|
||||||
content := msg.Content
|
content := msg.Content
|
||||||
runes := []rune(content)
|
runes := []rune(content)
|
||||||
|
|||||||
Reference in New Issue
Block a user