feat: 人性化改进 Phase 1 — 不完美感 + 日周期状态机 + 小脾气
- 1.7.7 不完美感: system prompt 追加停顿/改口/翻找回忆规则 - 1.7.8 日周期: 新增 timePeriod() 函数,时段注入思考提示词 早晨/白天/傍晚/深夜/凌晨 五段式,自动调整语气和主动消息策略 - 1.7.9 小脾气: YAML 追加个性边界 — 深夜催睡/咖啡管控/撒娇/兴趣偏好 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -261,6 +261,23 @@ func DefaultAutonomousToolPolicy() *AutonomousToolPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
// timePeriod returns a human-readable period name and guidance for the current hour.
|
||||
func timePeriod(now time.Time) (string, string) {
|
||||
hour := now.Hour()
|
||||
switch {
|
||||
case hour >= 6 && hour < 9:
|
||||
return "早晨", "精力充沛,可以主动问候。语气活泼。"
|
||||
case hour >= 9 && hour < 18:
|
||||
return "白天", "正常工作时段。日常闲聊模式,主动消息低频。"
|
||||
case hour >= 18 && hour < 22:
|
||||
return "傍晚", "放松时间。温柔关心今天过得怎样,可以主动搭话。"
|
||||
case hour >= 22 || hour < 2:
|
||||
return "深夜", "安静模式。话少、温柔、催睡觉。尽量不要发主动消息。"
|
||||
default:
|
||||
return "凌晨", "休眠模式。开拓者应该在睡觉,绝对不要打扰。"
|
||||
}
|
||||
}
|
||||
|
||||
// SetMessagePusher 设置主动消息推送回调
|
||||
// SetScheduleLoader sets the dynamic schedule loader for interval calculation.
|
||||
func (t *Thinker) SetScheduleLoader(loader *ScheduleLoader) {
|
||||
@@ -1296,17 +1313,27 @@ func (t *Thinker) buildThinkingSystemPrompt(personaConfig *persona.PersonaConfig
|
||||
}
|
||||
basePrompt := personaConfig.BuildSystemPromptWithMood("开拓者", 1, mood, moodExpr)
|
||||
|
||||
// 日周期状态:根据当前时间调整语气和行为
|
||||
now := time.Now().In(t.timeLocation)
|
||||
periodName, periodGuidance := timePeriod(now)
|
||||
|
||||
var thinkingInstructions string
|
||||
|
||||
// 所有触发类型共用的"禁止打扰"规则
|
||||
noDisturbRules := `
|
||||
noDisturbRules := fmt.Sprintf(`
|
||||
|
||||
🌙 **当前时段**: %s
|
||||
%s
|
||||
` +
|
||||
`
|
||||
|
||||
⛔ **绝对不要发送主动消息的情况(最高优先级)**:
|
||||
- 开拓者正在休息、睡觉、午休、小憩
|
||||
- 开拓者说要离开一会儿、去忙、去吃饭
|
||||
- 开拓者明确表示不想被打扰
|
||||
- 对话刚刚自然结束且开拓者没有未完成的事
|
||||
如果对话历史显示以上任何情况,你只需要在心里默默陪伴,不要输出任何【主动消息】指令行。`
|
||||
如果对话历史显示以上任何情况,你只需要在心里默默陪伴,不要输出任何【主动消息】指令行。`, periodName, periodGuidance)
|
||||
|
||||
|
||||
switch triggerReason {
|
||||
case "post_chat":
|
||||
|
||||
Reference in New Issue
Block a user