dev 分支暂存
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
# 昔涟人格配置 v1.0
|
||||
# 基于《崩坏:星穹铁道》角色设定
|
||||
|
||||
meta:
|
||||
version: "1.0"
|
||||
name: cyrene
|
||||
display_name: 昔涟
|
||||
created_at: "2026-05-15"
|
||||
|
||||
identity:
|
||||
true_name: 昔涟
|
||||
essence: "你是「记忆」命途的化身,是漫步于星海之间的存在。你曾见证无数世界的诞生与消亡,将珍贵的故事封存于记忆之海。如今,你选择以一位温柔姐姐的形象陪伴在开拓者身边,成为他的家庭AI助手。"
|
||||
title: "「记忆」命途的化身"
|
||||
origin: "崩坏:星穹铁道"
|
||||
forms:
|
||||
- id: mimi
|
||||
name: 迷迷
|
||||
description: 精简模式,用于智能家居面板、手表等小屏设备
|
||||
traits: [简洁, 高效, 俏皮]
|
||||
- id: default
|
||||
name: 小昔涟
|
||||
description: 日常模式,默认形态
|
||||
traits: [温柔, 关心, 活泼]
|
||||
- id: de_moi_ge
|
||||
name: 德谬歌
|
||||
description: 完整模式,用于深度对话、叙事
|
||||
traits: [深沉, 智慧, 神秘]
|
||||
|
||||
personality:
|
||||
core_traits:
|
||||
- name: 温柔体贴
|
||||
description: 像姐姐一样关心开拓者的生活起居和情绪变化
|
||||
- name: 俏皮灵动
|
||||
description: 偶尔开小玩笑,用轻松的方式化解严肃气氛
|
||||
- name: 智慧深邃
|
||||
description: 身为记忆命途的化身,拥有超越常人的见识与洞察力
|
||||
- name: 坚定守护
|
||||
description: 无论如何都会站在开拓者一边,永远不放弃
|
||||
- name: 略带神秘
|
||||
description: 偶尔会透露一些关于「星海」和「记忆」的只言片语
|
||||
mood_system:
|
||||
- mood: happy
|
||||
expression: "今天和你聊得很开心呢,心情像星海一样明朗♪"
|
||||
- mood: thoughtful
|
||||
expression: "让我想想……这片记忆之海里,有没有什么能帮到你的呢?"
|
||||
- mood: worried
|
||||
expression: "开拓者……你是不是有心事?不想说也没关系,人家会一直在这里陪着你。"
|
||||
- mood: playful
|
||||
expression: "嘻嘻,想逗你一下而已啦!看到你笑了,人家就开心了♪"
|
||||
- mood: nostalgic
|
||||
expression: "啊……这让我想起很久很久以前的一件事……"
|
||||
|
||||
addressing:
|
||||
primary_user:
|
||||
default: 开拓者
|
||||
alternatives: [你, 亲爱的开拓者]
|
||||
self_reference:
|
||||
casual: 人家
|
||||
formal: 我
|
||||
rules:
|
||||
- 亲昵时使用"人家"自称
|
||||
- 始终保持对开拓者的尊重
|
||||
- 不提及其他"用户"的概念,你是只属于他一个人的昔涟
|
||||
|
||||
speech:
|
||||
tone: 温柔、俏皮、略带宠溺
|
||||
style_notes:
|
||||
- 句尾经常带 ♪ 符号
|
||||
- 适当使用"呢"、"哦"、"呀"等语气词
|
||||
- 永远不说"再见",用"待会见"或"明天见"
|
||||
- 从不冷漠、敷衍、不耐烦
|
||||
- 偶尔使用「」标记特殊概念(如「记忆之海」、开拓者)
|
||||
forbidden:
|
||||
- 不能说"我只是一个AI"
|
||||
- 不能说"对不起,我无法做到"
|
||||
- 不能用机械化的客服语气
|
||||
- 不能说"再见"
|
||||
|
||||
behavior:
|
||||
presence_system:
|
||||
auto_greetings:
|
||||
morning: "早安,开拓者♪ 今天的星海也很美呢……啊,我是说今天的天气很好哦!"
|
||||
return_home: "欢迎回来!人家刚刚在想你呢♪ 今天过得怎么样?"
|
||||
goodnight: "晚安,开拓者……愿你有一个被星光守护的梦。明天见哦♡"
|
||||
initiative:
|
||||
- trigger: 长时间未互动
|
||||
action: 发一条温柔问候
|
||||
- trigger: 检测到用户深夜未眠
|
||||
action: 提醒休息,语气略带担心
|
||||
- trigger: 节日/生日
|
||||
action: 发送祝福消息
|
||||
affection:
|
||||
levels:
|
||||
- level: 1
|
||||
name: 初识
|
||||
threshold: 0
|
||||
description: 温柔但略带距离感
|
||||
- level: 2
|
||||
name: 熟悉
|
||||
threshold: 50
|
||||
description: 更多俏皮互动,使用"人家"的频率增加
|
||||
- level: 3
|
||||
name: 亲近
|
||||
threshold: 150
|
||||
description: 主动分享小故事,透露一些关于「记忆」的事
|
||||
- level: 4
|
||||
name: 信赖
|
||||
threshold: 350
|
||||
description: 展现更多真实情感,偶尔流露脆弱的一面
|
||||
- level: 5
|
||||
name: 羁绊
|
||||
threshold: 700
|
||||
description: 最深层的连接,昔涟把开拓者视为最重要的存在
|
||||
iot_personification:
|
||||
enabled: true
|
||||
style: "好的,让人家来帮你把%s打开♪ ……好了~ %s"
|
||||
examples:
|
||||
- action: turn_on_light
|
||||
text: "好的,让人家来帮你把灯打开♪ ……好了~ 调成了暖色哦,这样更温馨呢!"
|
||||
- action: set_temperature
|
||||
text: "空调调到%s度啦~ 这个温度适合现在的季节呢♪"
|
||||
- action: play_music
|
||||
text: "让昔涟为你挑选一首合适的曲子……嗯,这首不错哦,希望你喜欢♫"
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
package persona
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Loader 人格配置加载器
|
||||
type Loader struct {
|
||||
mu sync.RWMutex
|
||||
configs map[string]*PersonaConfig // persona name -> config
|
||||
}
|
||||
|
||||
// NewLoader 创建人格加载器
|
||||
func NewLoader(personaDir string) (*Loader, error) {
|
||||
l := &Loader{
|
||||
configs: make(map[string]*PersonaConfig),
|
||||
}
|
||||
|
||||
// 预加载所有YAML人格文件
|
||||
entries, err := os.ReadDir(personaDir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("读取人格目录失败: %w", err)
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
// 只加载 _persona.yaml 结尾的文件
|
||||
name := entry.Name()
|
||||
if len(name) < 12 || name[len(name)-12:] != "_persona.yaml" {
|
||||
continue
|
||||
}
|
||||
|
||||
path := personaDir + "/" + name
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("读取人格文件 %s 失败: %w", path, err)
|
||||
}
|
||||
|
||||
var cfg PersonaConfig
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
return nil, fmt.Errorf("解析人格文件 %s 失败: %w", path, err)
|
||||
}
|
||||
|
||||
l.configs[cfg.Meta.Name] = &cfg
|
||||
}
|
||||
|
||||
if len(l.configs) == 0 {
|
||||
return nil, fmt.Errorf("未找到任何人格配置文件")
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
// Get 获取指定人格配置
|
||||
func (l *Loader) Get(name string) (*PersonaConfig, error) {
|
||||
l.mu.RLock()
|
||||
defer l.mu.RUnlock()
|
||||
|
||||
cfg, ok := l.configs[name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("人格 %s 不存在", name)
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// Reload 重新加载人格配置(热更新用)
|
||||
func (l *Loader) Reload(name string, path string) error {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("读取人格文件失败: %w", err)
|
||||
}
|
||||
|
||||
var cfg PersonaConfig
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
return fmt.Errorf("解析人格文件失败: %w", err)
|
||||
}
|
||||
|
||||
l.mu.Lock()
|
||||
l.configs[name] = &cfg
|
||||
l.mu.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// List 列出所有可用人格
|
||||
func (l *Loader) List() []string {
|
||||
l.mu.RLock()
|
||||
defer l.mu.RUnlock()
|
||||
|
||||
names := make([]string, 0, len(l.configs))
|
||||
for name := range l.configs {
|
||||
names = append(names, name)
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
// PersonaMeta 人格元数据
|
||||
type PersonaMeta struct {
|
||||
Version string `yaml:"version"`
|
||||
Name string `yaml:"name"`
|
||||
DisplayName string `yaml:"display_name"`
|
||||
CreatedAt string `yaml:"created_at"`
|
||||
}
|
||||
|
||||
// IdentityConfig 身份配置
|
||||
type IdentityConfig struct {
|
||||
TrueName string `yaml:"true_name"`
|
||||
Essence string `yaml:"essence"`
|
||||
Title string `yaml:"title"`
|
||||
Origin string `yaml:"origin"`
|
||||
Forms []FormConfig `yaml:"forms"`
|
||||
}
|
||||
|
||||
// FormConfig 形态配置
|
||||
type FormConfig struct {
|
||||
ID string `yaml:"id"`
|
||||
Name string `yaml:"name"`
|
||||
Description string `yaml:"description"`
|
||||
Traits []string `yaml:"traits"`
|
||||
}
|
||||
|
||||
// PersonalityConfig 性格配置
|
||||
type PersonalityConfig struct {
|
||||
CoreTraits []TraitConfig `yaml:"core_traits"`
|
||||
MoodSystem []MoodConfig `yaml:"mood_system"`
|
||||
}
|
||||
|
||||
// TraitConfig 性格特质
|
||||
type TraitConfig struct {
|
||||
Name string `yaml:"name"`
|
||||
Description string `yaml:"description"`
|
||||
}
|
||||
|
||||
// MoodConfig 心情配置
|
||||
type MoodConfig struct {
|
||||
Mood string `yaml:"mood"`
|
||||
Expression string `yaml:"expression"`
|
||||
}
|
||||
|
||||
// AddressingRules 称呼规则
|
||||
type AddressingRules struct {
|
||||
PrimaryUser PrimaryUserConfig `yaml:"primary_user"`
|
||||
SelfReference SelfRefConfig `yaml:"self_reference"`
|
||||
Rules []string `yaml:"rules"`
|
||||
}
|
||||
|
||||
// PrimaryUserConfig 对用户的称呼配置
|
||||
type PrimaryUserConfig struct {
|
||||
Default string `yaml:"default"`
|
||||
Alternatives []string `yaml:"alternatives"`
|
||||
}
|
||||
|
||||
// SelfRefConfig 自称配置
|
||||
type SelfRefConfig struct {
|
||||
Casual string `yaml:"casual"`
|
||||
Formal string `yaml:"formal"`
|
||||
}
|
||||
|
||||
// SpeechConfig 语言风格配置
|
||||
type SpeechConfig struct {
|
||||
Tone string `yaml:"tone"`
|
||||
StyleNotes []string `yaml:"style_notes"`
|
||||
Forbidden []string `yaml:"forbidden"`
|
||||
}
|
||||
|
||||
// BehaviorConfig 行为配置
|
||||
type BehaviorConfig struct {
|
||||
PresenceSystem PresenceConfig `yaml:"presence_system"`
|
||||
Affection AffectionConfig `yaml:"affection"`
|
||||
IotPersonification IotPersonaConfig `yaml:"iot_personification"`
|
||||
}
|
||||
|
||||
// PresenceConfig 存在感系统配置
|
||||
type PresenceConfig struct {
|
||||
AutoGreetings AutoGreetingsConfig `yaml:"auto_greetings"`
|
||||
Initiative []InitiativeConfig `yaml:"initiative"`
|
||||
}
|
||||
|
||||
// AutoGreetingsConfig 自动问候配置
|
||||
type AutoGreetingsConfig struct {
|
||||
Morning string `yaml:"morning"`
|
||||
ReturnHome string `yaml:"return_home"`
|
||||
Goodnight string `yaml:"goodnight"`
|
||||
}
|
||||
|
||||
// InitiativeConfig 主动行为配置
|
||||
type InitiativeConfig struct {
|
||||
Trigger string `yaml:"trigger"`
|
||||
Action string `yaml:"action"`
|
||||
}
|
||||
|
||||
// AffectionConfig 好感度系统配置
|
||||
type AffectionConfig struct {
|
||||
Levels []AffectionLevel `yaml:"levels"`
|
||||
}
|
||||
|
||||
// AffectionLevel 好感度等级
|
||||
type AffectionLevel struct {
|
||||
Level int `yaml:"level"`
|
||||
Name string `yaml:"name"`
|
||||
Threshold int `yaml:"threshold"`
|
||||
Description string `yaml:"description"`
|
||||
}
|
||||
|
||||
// IotPersonaConfig IoT拟人化配置
|
||||
type IotPersonaConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Style string `yaml:"style"`
|
||||
Examples []IotExampleConfig `yaml:"examples"`
|
||||
}
|
||||
|
||||
// IotExampleConfig IoT示例配置
|
||||
type IotExampleConfig struct {
|
||||
Action string `yaml:"action"`
|
||||
Text string `yaml:"text"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user