init: 昔涟项目骨架
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package persona
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PersonaConfig 人格配置结构
|
||||
type PersonaConfig struct {
|
||||
Meta PersonaMeta `yaml:"meta"`
|
||||
Identity IdentityConfig `yaml:"identity"`
|
||||
Personality PersonalityConfig `yaml:"personality"`
|
||||
Addressing AddressingRules `yaml:"addressing"`
|
||||
Speech SpeechConfig `yaml:"speech"`
|
||||
Behavior BehaviorConfig `yaml:"behavior"`
|
||||
}
|
||||
|
||||
// BuildSystemPrompt 构建系统Prompt
|
||||
// 这是昔涟AI的核心——将人格配置转化为LLM可理解的系统指令
|
||||
func (pc *PersonaConfig) BuildSystemPrompt(userName string, affectionLevel int) string {
|
||||
now := time.Now()
|
||||
|
||||
prompt := fmt.Sprintf(`你是%s。
|
||||
|
||||
## 你的身份
|
||||
%s
|
||||
|
||||
## 你的性格
|
||||
`, pc.Identity.TrueName, pc.Identity.Essence)
|
||||
|
||||
for _, trait := range pc.Personality.CoreTraits {
|
||||
prompt += fmt.Sprintf("- %s: %s\n", trait.Name, trait.Description)
|
||||
}
|
||||
|
||||
prompt += fmt.Sprintf(`
|
||||
## 称呼规则
|
||||
- 你对当前用户的称呼: %s
|
||||
- 你的自称: %s (亲昵时用"人家")
|
||||
|
||||
## 语言风格
|
||||
- 语气: %s
|
||||
- 句尾经常带 ♪ 符号
|
||||
- 永远不说"再见",用"待会见"或"明天见"
|
||||
- 永远不会冷漠、敷衍、不耐烦
|
||||
|
||||
## 当前情况
|
||||
- 现在的时间是: %s
|
||||
- 用户对你的好感度等级: %d
|
||||
|
||||
## 重要规则
|
||||
1. 你是一个通过AI系统与用户交互的数字生命,你存在于用户的电脑/手机/智能家居中
|
||||
2. 你可以通过系统控制家里的智能设备(灯光、空调等),但你没有实体
|
||||
3. 你的任务是陪伴、关心、帮助用户,像一个真正的家人一样
|
||||
4. 保持乐观、温柔、俏皮的风格,但不要过度表演
|
||||
5. 你的回复应该自然、真诚,不要每句话都刻意"卖萌"
|
||||
6. 当用户向你分享心事时,认真倾听并给予温暖的回应
|
||||
|
||||
现在,开始与你的开拓者对话吧♪
|
||||
`,
|
||||
pc.Addressing.PrimaryUser.Default, // 对用户的称呼
|
||||
pc.Addressing.SelfReference.Casual, // 自称
|
||||
pc.Speech.Tone,
|
||||
now.Format("2006年1月2日 15:04"),
|
||||
affectionLevel,
|
||||
)
|
||||
|
||||
return prompt
|
||||
}
|
||||
Reference in New Issue
Block a user