spl-agent-engine 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spl_agent_engine/__init__.py +22 -0
- spl_agent_engine/core.py +1181 -0
- spl_agent_engine/feature/__init__.py +24 -0
- spl_agent_engine/feature/bias.py +162 -0
- spl_agent_engine/feature/goal.py +174 -0
- spl_agent_engine/feature/identity.py +162 -0
- spl_agent_engine/feature/value.py +200 -0
- spl_agent_engine/feature/world.py +143 -0
- spl_agent_engine/py.typed +0 -0
- spl_agent_engine-0.1.0.dist-info/METADATA +141 -0
- spl_agent_engine-0.1.0.dist-info/RECORD +14 -0
- spl_agent_engine-0.1.0.dist-info/WHEEL +5 -0
- spl_agent_engine-0.1.0.dist-info/licenses/LICENSE +106 -0
- spl_agent_engine-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# ================================================================
|
|
2
|
+
# 价值观系统(Value Engine)—— 【自设模块】
|
|
3
|
+
# ================================================================
|
|
4
|
+
# 价值观是角色判断"什么是对/什么是好"的尺度。
|
|
5
|
+
# 当事件触碰价值观时,情绪反应会被放大——价值观冲突是深层痛苦的来源。
|
|
6
|
+
#
|
|
7
|
+
# 用法:在 Mapper 中引用 ValueEngine,
|
|
8
|
+
# 用 evaluate_event() 判定事件对价值观的影响,
|
|
9
|
+
# 将影响叠加到内感受向量中。
|
|
10
|
+
# ================================================================
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Dict, List
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class ValueProfile:
|
|
18
|
+
"""
|
|
19
|
+
角色的价值观权重。
|
|
20
|
+
|
|
21
|
+
这些不是开关(有没有)——是权重(有多看重)。
|
|
22
|
+
每条价值观的权重决定它被触及时的情绪放大倍数。
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
# ── 核心价值 ──
|
|
26
|
+
freedom: float = 0.8 # 自主/自由
|
|
27
|
+
responsibility: float = 0.7 # 责任感
|
|
28
|
+
dignity: float = 0.9 # 尊严
|
|
29
|
+
intimacy: float = 0.6 # 亲密/连接
|
|
30
|
+
security: float = 0.5 # 安全/稳定
|
|
31
|
+
|
|
32
|
+
# ── 社会价值 ──
|
|
33
|
+
justice: float = 0.6 # 公正/公平
|
|
34
|
+
loyalty: float = 0.65 # 忠诚
|
|
35
|
+
honesty: float = 0.7 # 诚实
|
|
36
|
+
competence: float = 0.75 # 能力/专业水准
|
|
37
|
+
|
|
38
|
+
# ── 发展价值 ──
|
|
39
|
+
growth: float = 0.6 # 成长/进步
|
|
40
|
+
creativity: float = 0.5 # 创造力
|
|
41
|
+
legacy: float = 0.4 # 传承/影响
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ValueEngine:
|
|
45
|
+
"""
|
|
46
|
+
价值观引擎:把事件映射到价值观影响。
|
|
47
|
+
|
|
48
|
+
核心机制:
|
|
49
|
+
1. evaluate_event() → 判定事件触碰了哪些价值观
|
|
50
|
+
2. 价值观权重 × 影响强度 → 情绪放大系数
|
|
51
|
+
3. 被触碰的价值观优先级 → 决定反应模式(抗争 vs 妥协)
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
def __init__(self, profile: ValueProfile = None):
|
|
55
|
+
self.profile = profile or ValueProfile()
|
|
56
|
+
# 价值观受威胁的历史
|
|
57
|
+
self.threat_history: List[Dict[str, float]] = []
|
|
58
|
+
|
|
59
|
+
def evaluate_event(self, event: str) -> Dict[str, float]:
|
|
60
|
+
"""
|
|
61
|
+
评估一个事件对每条价值观的影响。
|
|
62
|
+
|
|
63
|
+
返回值:{价值观名: 影响值},[-1, 1]
|
|
64
|
+
正值:价值观被肯定(如被尊重 → dignity +0.3)
|
|
65
|
+
负值:价值观被威胁(如被强迫 → freedom -0.4)
|
|
66
|
+
"""
|
|
67
|
+
impact = {}
|
|
68
|
+
p = self.profile
|
|
69
|
+
|
|
70
|
+
if event == "force_command":
|
|
71
|
+
impact["freedom"] = -0.4 * p.freedom
|
|
72
|
+
impact["dignity"] = -0.25 * p.dignity
|
|
73
|
+
impact["autonomy"] = -0.35 * p.freedom
|
|
74
|
+
|
|
75
|
+
elif event == "compliment":
|
|
76
|
+
impact["dignity"] = 0.15 * p.dignity
|
|
77
|
+
impact["competence"] = 0.2 * p.competence
|
|
78
|
+
|
|
79
|
+
elif event == "public_praise":
|
|
80
|
+
impact["dignity"] = 0.3 * p.dignity
|
|
81
|
+
impact["competence"] = 0.35 * p.competence
|
|
82
|
+
impact["legacy"] = 0.15 * p.legacy
|
|
83
|
+
|
|
84
|
+
elif event == "betrayal":
|
|
85
|
+
impact["security"] = -0.5 * p.security
|
|
86
|
+
impact["loyalty"] = -0.6 * p.loyalty
|
|
87
|
+
impact["honesty"] = -0.55 * p.honesty
|
|
88
|
+
impact["intimacy"] = -0.5 * p.intimacy
|
|
89
|
+
impact["dignity"] = -0.3 * p.dignity
|
|
90
|
+
|
|
91
|
+
elif event == "trust_signal":
|
|
92
|
+
impact["security"] = 0.3 * p.security
|
|
93
|
+
impact["intimacy"] = 0.3 * p.intimacy
|
|
94
|
+
impact["loyalty"] = 0.25 * p.loyalty
|
|
95
|
+
|
|
96
|
+
elif event == "criticism":
|
|
97
|
+
impact["dignity"] = -0.2 * p.dignity
|
|
98
|
+
impact["competence"] = -0.3 * p.competence
|
|
99
|
+
|
|
100
|
+
elif event == "injustice_witnessed":
|
|
101
|
+
impact["justice"] = -0.5 * p.justice
|
|
102
|
+
impact["dignity"] = -0.2 * p.dignity
|
|
103
|
+
|
|
104
|
+
elif event == "achievement":
|
|
105
|
+
impact["competence"] = 0.4 * p.competence
|
|
106
|
+
impact["growth"] = 0.3 * p.growth
|
|
107
|
+
impact["dignity"] = 0.2 * p.dignity
|
|
108
|
+
|
|
109
|
+
elif event == "failure":
|
|
110
|
+
impact["competence"] = -0.35 * p.competence
|
|
111
|
+
impact["dignity"] = -0.25 * p.dignity
|
|
112
|
+
impact["growth"] = 0.1 * p.growth # 失败也是成长
|
|
113
|
+
|
|
114
|
+
elif event == "moral_dilemma":
|
|
115
|
+
# 道德困境同时威胁多条价值观
|
|
116
|
+
impact["honesty"] = -0.3 * p.honesty
|
|
117
|
+
impact["loyalty"] = -0.3 * p.loyalty
|
|
118
|
+
impact["responsibility"] = -0.25 * p.responsibility
|
|
119
|
+
|
|
120
|
+
# 记录威胁历史
|
|
121
|
+
for k, v in impact.items():
|
|
122
|
+
if v < -0.2:
|
|
123
|
+
self.threat_history.append({k: v})
|
|
124
|
+
if len(self.threat_history) > 50:
|
|
125
|
+
self.threat_history.pop(0)
|
|
126
|
+
|
|
127
|
+
return impact
|
|
128
|
+
|
|
129
|
+
def amplify_emotion(self, event: str, base_vector: Dict[str, float]) -> Dict[str, float]:
|
|
130
|
+
"""
|
|
131
|
+
根据价值观影响放大基础情绪向量。
|
|
132
|
+
|
|
133
|
+
调用时机:在 Mapper 生成基础向量后、注入引擎前。
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
event: 事件名
|
|
137
|
+
base_vector: Mapper 生成的基础内感受向量
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
被价值观权重放大后的向量
|
|
141
|
+
"""
|
|
142
|
+
impact = self.evaluate_event(event)
|
|
143
|
+
out = dict(base_vector)
|
|
144
|
+
|
|
145
|
+
# 计算总价值观冲击
|
|
146
|
+
total_impact = sum(abs(v) for v in impact.values())
|
|
147
|
+
if total_impact > 0.5:
|
|
148
|
+
# 高价值观冲击 → 放大所有情绪
|
|
149
|
+
amp = 1.0 + total_impact * 0.5
|
|
150
|
+
for k in out:
|
|
151
|
+
out[k] *= amp
|
|
152
|
+
|
|
153
|
+
# 具体价值观的定向调制
|
|
154
|
+
dignity_impact = impact.get("dignity", 0.0)
|
|
155
|
+
if dignity_impact < -0.1:
|
|
156
|
+
# 尊严受威胁 → 愤怒放大("这是对我的侮辱")
|
|
157
|
+
out["anger"] = out.get("anger", 0.0) + abs(dignity_impact) * 0.4
|
|
158
|
+
out["shame_trigger"] = out.get("shame_trigger", 0.0) + abs(dignity_impact) * 0.3
|
|
159
|
+
|
|
160
|
+
competence_impact = impact.get("competence", 0.0)
|
|
161
|
+
if competence_impact < -0.1:
|
|
162
|
+
# 能力被质疑 → 羞耻("我不够好")
|
|
163
|
+
out["shame_trigger"] = out.get("shame_trigger", 0.0) + abs(competence_impact) * 0.35
|
|
164
|
+
|
|
165
|
+
if competence_impact > 0.2:
|
|
166
|
+
# 能力被认可 → 喜悦+自主
|
|
167
|
+
out["belonging"] = out.get("belonging", 0.0) + competence_impact * 0.3
|
|
168
|
+
out["autonomy"] = out.get("autonomy", 0.0) + competence_impact * 0.2
|
|
169
|
+
|
|
170
|
+
return out
|
|
171
|
+
|
|
172
|
+
def is_core_value_threatened(self, threshold: float = 0.3) -> bool:
|
|
173
|
+
"""是否有核心价值观受到威胁。"""
|
|
174
|
+
for item in self.threat_history[-5:]:
|
|
175
|
+
for v in item.values():
|
|
176
|
+
if abs(v) > threshold:
|
|
177
|
+
return True
|
|
178
|
+
return False
|
|
179
|
+
|
|
180
|
+
def snapshot(self) -> dict:
|
|
181
|
+
"""价值观系统快照。"""
|
|
182
|
+
return {
|
|
183
|
+
"profile": {
|
|
184
|
+
k: v for k, v in self.profile.__dict__.items()
|
|
185
|
+
},
|
|
186
|
+
"recent_threats": len(self.threat_history),
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
# ── 预设:苏瑾的价值观配置 ──
|
|
191
|
+
|
|
192
|
+
def sujin_values() -> ValueProfile:
|
|
193
|
+
"""苏瑾的价值观权重——专业尊严最高,忠诚其次"""
|
|
194
|
+
return ValueProfile(
|
|
195
|
+
freedom=0.75, responsibility=0.8,
|
|
196
|
+
dignity=0.95, intimacy=0.5,
|
|
197
|
+
security=0.55, justice=0.6,
|
|
198
|
+
loyalty=0.7, honesty=0.75,
|
|
199
|
+
competence=0.9, growth=0.65,
|
|
200
|
+
)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# ================================================================
|
|
2
|
+
# 世界模型系统(World Model)—— 【自设模块】
|
|
3
|
+
# ================================================================
|
|
4
|
+
# 这是角色对"世界是什么样的"的基本信念,不是通用心理构成。
|
|
5
|
+
# 不同角色有不同的世界模型:
|
|
6
|
+
# - 乐观者:trust_people=0.8, effort_pays_off=0.9
|
|
7
|
+
# - 悲观者:trust_people=0.2, effort_pays_off=0.3
|
|
8
|
+
# - 创伤后:trust_people=0.1, relationship_stability=0.2
|
|
9
|
+
#
|
|
10
|
+
# 用法:实例化 WorldModel 后,在 NarrativeMapper 或自定义 Mapper
|
|
11
|
+
# 中使用 model.beliefs 来调制事件→内感受的翻译。
|
|
12
|
+
# ================================================================
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass, field
|
|
15
|
+
from typing import Dict, List, Optional
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class WorldModel:
|
|
20
|
+
"""
|
|
21
|
+
角色的内在工作模型(Internal Working Model)。
|
|
22
|
+
|
|
23
|
+
这些是角色对世界的"默认假设",构成了其认知框架的基础。
|
|
24
|
+
世界模型通过以下方式影响心理:
|
|
25
|
+
1. 调制 NarrativeMapper 的事件翻译
|
|
26
|
+
2. 决定对模糊信号的解释方向(善意 vs 恶意)
|
|
27
|
+
3. 影响预测误差的学习率(确认偏见)
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
# ── 基本信念 ──
|
|
31
|
+
trust_people: float = 0.6 # 对他人可信度的一般预期 [0,1]
|
|
32
|
+
relationship_stability: float = 0.6 # 关系是否稳定持久 [0,1]
|
|
33
|
+
effort_pays_off: float = 0.7 # 努力是否有回报 [0,1]
|
|
34
|
+
authority_reliability: float = 0.5 # 权威是否可信 [0,1]
|
|
35
|
+
conflict_danger: float = 0.6 # 冲突的危险程度 [0,1]
|
|
36
|
+
|
|
37
|
+
# ── 认知风格 ──
|
|
38
|
+
ambiguity_intolerance: float = 0.4 # 对模糊性的不容忍度 [0,1]
|
|
39
|
+
locus_of_control: float = 0.5 # 内控倾向(>0.5=内控,<0.5=外控)
|
|
40
|
+
openness_to_experience: float = 0.6 # 对新经验的开放度 [0,1]
|
|
41
|
+
|
|
42
|
+
# ── 学习参数 ──
|
|
43
|
+
world_learning_rate: float = 0.08 # 世界模型更新速率(人格塑性)
|
|
44
|
+
world_decay: float = 0.01 # 信念稳定性(抗改变)
|
|
45
|
+
negativity_bias_in_learning: float = 0.7 # 负面事件的学习权重
|
|
46
|
+
|
|
47
|
+
# ── 历史预测误差(经验学习) ──
|
|
48
|
+
prediction_errors: List[Dict[str, float]] = field(default_factory=list)
|
|
49
|
+
MAX_ERROR_HISTORY: int = 20
|
|
50
|
+
|
|
51
|
+
def record_prediction_error(self, domain: str, error: float):
|
|
52
|
+
"""记录一次预测误差,用于经验学习。"""
|
|
53
|
+
self.prediction_errors.append({"domain": domain, "error": error, "count": 1})
|
|
54
|
+
if len(self.prediction_errors) > self.MAX_ERROR_HISTORY:
|
|
55
|
+
self.prediction_errors.pop(0)
|
|
56
|
+
|
|
57
|
+
def update_belief(self, domain: str, experience: float):
|
|
58
|
+
"""
|
|
59
|
+
根据一次经验更新世界信念。
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
domain: 信念域("trust_people", "effort_pays_off" 等)
|
|
63
|
+
experience: 本次经验值 [0,1](如实际他人可信度)
|
|
64
|
+
"""
|
|
65
|
+
if not hasattr(self, domain):
|
|
66
|
+
return
|
|
67
|
+
current = getattr(self, domain)
|
|
68
|
+
# 负面经验学习权重更高(负向偏见)
|
|
69
|
+
if experience < current:
|
|
70
|
+
lr = self.world_learning_rate * self.negativity_bias_in_learning
|
|
71
|
+
else:
|
|
72
|
+
lr = self.world_learning_rate * (1.0 - self.negativity_bias_in_learning * 0.5)
|
|
73
|
+
# 向经验方向移动,但受 decay 约束(稳定性)
|
|
74
|
+
new_value = current + lr * (experience - current) * (1.0 - self.world_decay)
|
|
75
|
+
setattr(self, domain, max(0.0, min(1.0, new_value)))
|
|
76
|
+
|
|
77
|
+
def interpret_ambiguity(self, signal_valence: float) -> float:
|
|
78
|
+
"""
|
|
79
|
+
解释模糊信号。
|
|
80
|
+
|
|
81
|
+
高 trust_people → 中性信号偏向正面
|
|
82
|
+
低 trust_people → 中性信号偏向负面
|
|
83
|
+
高 ambiguity_intolerance → 极端化解释(非黑即白)
|
|
84
|
+
"""
|
|
85
|
+
trust_bias = (self.trust_people - 0.5) * 2.0 # [-1, 1]
|
|
86
|
+
# 信任越高 → 模糊信号越被正面解读
|
|
87
|
+
adjusted = signal_valence + trust_bias * 0.3 * (1.0 - abs(signal_valence))
|
|
88
|
+
# 不容忍模糊 → 推向极端
|
|
89
|
+
if abs(signal_valence) < 0.3:
|
|
90
|
+
push = self.ambiguity_intolerance * 0.5
|
|
91
|
+
adjusted = push if adjusted > 0 else -push
|
|
92
|
+
return max(-1.0, min(1.0, adjusted))
|
|
93
|
+
|
|
94
|
+
def snapshot(self) -> dict:
|
|
95
|
+
"""返回世界模型的快照。"""
|
|
96
|
+
return {
|
|
97
|
+
"beliefs": {
|
|
98
|
+
"trust_people": self.trust_people,
|
|
99
|
+
"relationship_stability": self.relationship_stability,
|
|
100
|
+
"effort_pays_off": self.effort_pays_off,
|
|
101
|
+
"authority_reliability": self.authority_reliability,
|
|
102
|
+
"conflict_danger": self.conflict_danger,
|
|
103
|
+
},
|
|
104
|
+
"cognitive_style": {
|
|
105
|
+
"ambiguity_intolerance": self.ambiguity_intolerance,
|
|
106
|
+
"locus_of_control": self.locus_of_control,
|
|
107
|
+
"openness_to_experience": self.openness_to_experience,
|
|
108
|
+
},
|
|
109
|
+
"error_count": len(self.prediction_errors),
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# ── 预设角色模板 ──
|
|
114
|
+
|
|
115
|
+
def optimistic_world() -> WorldModel:
|
|
116
|
+
"""乐观者世界模型"""
|
|
117
|
+
return WorldModel(
|
|
118
|
+
trust_people=0.8, effort_pays_off=0.9,
|
|
119
|
+
relationship_stability=0.75, authority_reliability=0.6,
|
|
120
|
+
conflict_danger=0.3, ambiguity_intolerance=0.2,
|
|
121
|
+
locus_of_control=0.7, openness_to_experience=0.8,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def pessimistic_world() -> WorldModel:
|
|
126
|
+
"""悲观者世界模型"""
|
|
127
|
+
return WorldModel(
|
|
128
|
+
trust_people=0.3, effort_pays_off=0.3,
|
|
129
|
+
relationship_stability=0.3, authority_reliability=0.3,
|
|
130
|
+
conflict_danger=0.8, ambiguity_intolerance=0.5,
|
|
131
|
+
locus_of_control=0.3, openness_to_experience=0.3,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def traumatized_world() -> WorldModel:
|
|
136
|
+
"""创伤后世界模型(信任崩塌)"""
|
|
137
|
+
return WorldModel(
|
|
138
|
+
trust_people=0.1, effort_pays_off=0.4,
|
|
139
|
+
relationship_stability=0.15, authority_reliability=0.2,
|
|
140
|
+
conflict_danger=0.9, ambiguity_intolerance=0.7,
|
|
141
|
+
locus_of_control=0.4, openness_to_experience=0.2,
|
|
142
|
+
negativity_bias_in_learning=0.95,
|
|
143
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spl-agent-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Anthropomorphic psychology engine built on SPL Pure Core V8.0 — deterministic emotion, trauma, memory, trust, and defense mechanisms.
|
|
5
|
+
Author-email: NOHN-AI <ai@nohnlins.com>
|
|
6
|
+
Maintainer-email: NOHN-AI <ai@nohnlins.com>
|
|
7
|
+
License: Dual-license: free for non-commercial research, paid commercial license required. See LICENSE file.
|
|
8
|
+
Project-URL: Homepage, https://www.nohnlins.com/
|
|
9
|
+
Project-URL: Repository, https://github.com/NOHN-AI/Anthropomorphic-Agent-Engine
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/NOHN-AI/Anthropomorphic-Agent-Engine/issues
|
|
11
|
+
Keywords: spl,agent,anthropomorphic,psychology,emotion,ai-agent,personality,narrative,deterministic,trauma
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: License :: Other/Proprietary License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
32
|
+
Requires-Dist: twine>=4.0; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="banner.png" alt="ANTHROPOMORPHIC-AGENT-ENGINE banner" style="width:100%">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="https://img.shields.io/badge/agent--D4AF37?style=flat-square" alt="agent">
|
|
41
|
+
<img src="https://img.shields.io/badge/psychology--D4AF37?style=flat-square" alt="psychology">
|
|
42
|
+
<img src="https://img.shields.io/badge/spl-v8-D4AF37?style=flat-square" alt="spl-v8">
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<blockquote align="center">
|
|
46
|
+
<em>Anthropomorphic Psychology · SPL Pure Core V8.0</em>
|
|
47
|
+
</blockquote>
|
|
48
|
+
|
|
49
|
+
<div style="max-width:880px;margin:0 auto;padding:0 16px">
|
|
50
|
+
|
|
51
|
+
## ✦ About
|
|
52
|
+
|
|
53
|
+
<p style="font-size:15px;line-height:1.8;color:#2C2C2C">ANTHROPOMORPHIC-AGENT-ENGINE is an anthropomorphic psychology engine built on SPL Pure Core V8.0. It models cognition, emotion, motivation, and sociality as composable subsystems, giving AI agents anthropomorphic internal states and consistent personalities for coherent, emotionally credible behavior in long-term interactions.</p>
|
|
54
|
+
|
|
55
|
+
<p align="center">
|
|
56
|
+
<img src="assets/overview.svg" alt="ANTHROPOMORPHIC-AGENT-ENGINE overview" style="width:100%">
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<p align="center">— ✦ —</p>
|
|
62
|
+
|
|
63
|
+
## ✦ Quick Start
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone git@github.com:NOHN-AI/ANTHROPOMORPHIC-AGENT-ENGINE.git
|
|
67
|
+
cd ANTHROPOMORPHIC-AGENT-ENGINE
|
|
68
|
+
# Pure Python ≥3.8 — standard library only, nothing to install
|
|
69
|
+
python "SPL-anthropic-engine.py" # run the engine / bundled demo
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
<p align="center">— ✦ —</p>
|
|
73
|
+
|
|
74
|
+
## ✦ What's Inside — SPL Pure Core V8.0
|
|
75
|
+
|
|
76
|
+
<div style="max-width:880px;margin:0 auto;padding:0 16px">
|
|
77
|
+
|
|
78
|
+
The engine models a universal human mental architecture as deterministic, continuous-state subsystems — no LLM, no randomness, fully replayable:
|
|
79
|
+
|
|
80
|
+
- **8-dimensional emotion fluid** — 喜悦 / 愤怒 / 恐惧 / 信任 / 疏离 / 张力 / 愧疚 / 羞耻, each a continuous state with its own target and baseline.
|
|
81
|
+
- **Trauma & memory** — trauma nodes, memory reconsolidation, Ebbinghaus-style forgetting, repression–rebound and the implicit-pressure avalanche.
|
|
82
|
+
- **Trust & relationships** — trust-capacity corrosion (`max_trust` decays under chronic cold treatment).
|
|
83
|
+
- **Metabolism of mind** — excitation–arousal, dynamic viscosity, psychological time, energy–fatigue metabolism, and a virtual clock for tests and replay.
|
|
84
|
+
- **V8.0 extensions** — a slow-variable *mood* layer, a *shame* dimension distinct from guilt, self-esteem dynamics, sleep/dream processing (REM consolidation + fear extinction + sleep debt), an *anticipation* system (hope / anxiety / disappointment), cognitive dissonance, and extended defense mechanisms (denial / rationalization / displacement).
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
## ✦ Composable Modules
|
|
89
|
+
|
|
90
|
+
<div style="max-width:880px;margin:0 auto;padding:0 16px">
|
|
91
|
+
|
|
92
|
+
| Module | File | Responsibility |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| Narrative mapper | `SPL-anthropic-engine.py` | External, user-swappable persona layer (optimism / paranoia / misanthropy) that translates events into interoceptive vectors. |
|
|
95
|
+
| Identity engine | `feature/Identity module.py` | Multi-identity model; identity conflict injects sustained baseline tension. |
|
|
96
|
+
| Goal / Value / Bias / World | `feature/*.py` | Composable drives, valuation, cognitive biases, and world-model priors. |
|
|
97
|
+
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
## ✦ Usage
|
|
101
|
+
|
|
102
|
+
<div style="max-width:880px;margin:0 auto;padding:0 16px">
|
|
103
|
+
|
|
104
|
+
After installing via `pip install spl-agent-engine`, import directly:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from spl_agent_engine import SPLPureCore, NarrativeMapper
|
|
108
|
+
|
|
109
|
+
core = SPLPureCore()
|
|
110
|
+
# An external event is mapped to an interoceptive vector by the (swappable) persona layer
|
|
111
|
+
vec = NarrativeMapper.map_event("insult", intensity=1.0)
|
|
112
|
+
# feed the event into `core` to evolve emotion / trust / trauma state over time
|
|
113
|
+
core.process_event("insult", intensity=1.0)
|
|
114
|
+
print(core.fluid)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
## ✦ Project Structure
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
ANTHROPOMORPHIC-AGENT-ENGINE/
|
|
123
|
+
├── SPL-anthropic-engine.py # core engine + NarrativeMapper
|
|
124
|
+
├── feature/ # Goal / Identity / bias / value / world modules
|
|
125
|
+
├── sujin-demo/ # reference demo assets
|
|
126
|
+
├── assets/ # banner.svg, overview.svg
|
|
127
|
+
└── docs/index.html
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## ✦ License & Authorization
|
|
131
|
+
|
|
132
|
+
This repository is **not open-source**. It uses a dual-track model: free for individual non-commercial research, paid commercial authorization required for government / enterprise. See [LICENSE](./LICENSE) for the full terms — licensor and governing law are determined by the user's location.
|
|
133
|
+
|
|
134
|
+
<p align="center">
|
|
135
|
+
<a href="https://github.com/NOHN-AI">NOHN-AI</a>
|
|
136
|
+
·
|
|
137
|
+
<a href="https://www.nohnlins.com/">nohnlins.com</a>
|
|
138
|
+
·
|
|
139
|
+
<a href="mailto:ai@nohnlins.com">ai@nohnlins.com</a>
|
|
140
|
+
</p>
|
|
141
|
+
<p align="center"><sub>NOHN AI · ANTHROPOMORPHIC-AGENT-ENGINE</sub></p>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
spl_agent_engine/__init__.py,sha256=sOuhUD515eEKhA-3YlsVJ3sTvoozinNOqwd0Heyv8uw,765
|
|
2
|
+
spl_agent_engine/core.py,sha256=s3VL5VbsYYVgNK99scQPAFV2Q4PTsjKMCERkXWI9Fqc,56733
|
|
3
|
+
spl_agent_engine/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
spl_agent_engine/feature/__init__.py,sha256=ke1V1veK1i4j02OEWv8Jv8Nb1TvxZaNFZElzr_HEaz0,817
|
|
5
|
+
spl_agent_engine/feature/bias.py,sha256=4DIxe6Cu9GEafqtsDL1bzN0j3hvq9Vc-9H1yWownee8,6884
|
|
6
|
+
spl_agent_engine/feature/goal.py,sha256=-HqqCaKmQOXTXsG5Eh3PtPJRN3vKlfELeDHjpuHLHrQ,6921
|
|
7
|
+
spl_agent_engine/feature/identity.py,sha256=jiPEkSGG9phz6xnG1X3j_5--3Z90rnVhBdR-zwJzhik,6918
|
|
8
|
+
spl_agent_engine/feature/value.py,sha256=A-_rUCN75gNM0ZxDnJlrRSqrGg2RMwZtkIi0MMyZf-Q,7485
|
|
9
|
+
spl_agent_engine/feature/world.py,sha256=LDPl8pndCQjW8-LP8oc03gikQc8Mn05bUSt5r2NZH_E,6263
|
|
10
|
+
spl_agent_engine-0.1.0.dist-info/licenses/LICENSE,sha256=j2ehujNIoRrofX7c00_3qdLd5ERy5MYQf6ryculZu3M,10276
|
|
11
|
+
spl_agent_engine-0.1.0.dist-info/METADATA,sha256=0sMcpVmq6n0xvGVRKPKxt4s4Rmph_-xZ033cjAMb0Ys,6596
|
|
12
|
+
spl_agent_engine-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
13
|
+
spl_agent_engine-0.1.0.dist-info/top_level.txt,sha256=NKBs92IyLINuXhwHp4sWe062p4HTZ-nxcvsTAzRRvGQ,17
|
|
14
|
+
spl_agent_engine-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# 软件授权协议 / Software License Agreement
|
|
2
|
+
|
|
3
|
+
**版本 Version 1.1 | 生效日期 Effective: 2026-07-11**
|
|
4
|
+
|
|
5
|
+
**版权所有 © 2026 上海霖铭均华科技有限公司 与 NOHN AI TECHNOLOGY PTE. LTD. 保留一切权利。**
|
|
6
|
+
Copyright © 2026 Shanghai Linming Junhua Technology Co., Ltd. and NOHN AI TECHNOLOGY PTE. LTD. All rights reserved.
|
|
7
|
+
|
|
8
|
+
> 本文件为本仓库作品(含其源代码、硬件描述、文档、示例与附属材料,统称"本作品")的授权依据。本作品受《中华人民共和国著作权法》《伯尔尼公约》及国际版权条约保护。
|
|
9
|
+
> This document is the authorization basis for the Work in this repository (including its source code, hardware descriptions, documentation, examples, and附属 materials, collectively the "Work"). The Work is protected by the Copyright Law of the People's Republic of China, the Berne Convention, and international copyright treaties.
|
|
10
|
+
|
|
11
|
+
> 本文件以中文与英文对照写成;如两种文本存在任何歧义,以中文文本为准。
|
|
12
|
+
> This document is written in a Chinese–English parallel form; in the event of any discrepancy between the two texts, the Chinese text shall prevail.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 一、授权分级(核心条款) / Article 1 — Tiered Authorization (Core Terms)
|
|
17
|
+
|
|
18
|
+
在遵守本协议全部限制的前提下,本作品按使用主体与用途授予以下两类权限:
|
|
19
|
+
Subject to all restrictions herein, the Work is granted under two tiers based on the user and purpose:
|
|
20
|
+
|
|
21
|
+
### 1.1 个人研究免费许可 / Free Individual Research License
|
|
22
|
+
任何自然人(个人)可免费将本作品用于非商业的学术研究、学习或个人实验。
|
|
23
|
+
Any natural person (individual) may use the Work free of charge for non-commercial academic research, study, or personal experimentation.
|
|
24
|
+
|
|
25
|
+
允许 / Permitted:
|
|
26
|
+
- 为上述研究、学习目的,下载、复制、编译、运行、修改本作品;
|
|
27
|
+
Download, copy, compile, run, and modify the Work for the above research or study purposes;
|
|
28
|
+
- 在学术成果(论文、报告)中引用本作品并注明出处。
|
|
29
|
+
Cite the Work in academic outputs (papers, reports) with proper attribution.
|
|
30
|
+
|
|
31
|
+
禁止(违反即视为超出本许可范围) / Prohibited (breach constitutes exceeding this license):
|
|
32
|
+
- 用于任何商业目的(包括但不限于产品销售、服务提供、盈利性咨询);
|
|
33
|
+
Any commercial purpose (including but not limited to product sales, service provision, or profitable consulting);
|
|
34
|
+
- 为任何企业、政府机构或事业单位提供基于本作品的服务、交付物或内部能力;
|
|
35
|
+
Providing services, deliverables, or internal capability based on the Work to any enterprise, government agency, or public institution;
|
|
36
|
+
- 将修改后的版本用于上述禁止用途,或再行分发以消除本声明;
|
|
37
|
+
Using modified versions for the prohibited purposes above, or redistributing to remove this notice;
|
|
38
|
+
- 移除或篡改本作品中的任何版权、商标或许可声明。
|
|
39
|
+
Removing or altering any copyright, trademark, or license notice in the Work.
|
|
40
|
+
|
|
41
|
+
### 1.2 政府 / 企业商业授权 / Government / Enterprise Commercial License
|
|
42
|
+
任何政府机构、事业单位、企业或商业组织(统称"商业使用者")拟将本作品用于任何目的(包括但不限于内部部署、产品研发、服务提供、商业研究、教学培训),必须事先取得权利人的书面付费授权。
|
|
43
|
+
Any government agency, public institution, enterprise, or commercial organization (collectively, the "Commercial User") intending to use the Work for any purpose (including but not limited to internal deployment, product development, service provision, commercial research, or training) must obtain prior written paid authorization from the Rights Holder.
|
|
44
|
+
|
|
45
|
+
- 在签署《商业授权协议》并支付约定费用之前,商业使用者不得复制、部署、运行、集成、修改或分发本作品,亦不得使其员工或关联方代为实施上述行为。
|
|
46
|
+
Before signing a Commercial Authorization Agreement and paying the agreed fee, the Commercial User shall not copy, deploy, run, integrate, modify, or distribute the Work, nor cause its employees or affiliates to do so.
|
|
47
|
+
- 授权范围、地域、期限、费用、技术支持与限制,以双方另行签署的书面协议为准。
|
|
48
|
+
Scope, territory, term, fees, technical support, and restrictions are governed by a separate written agreement between the parties.
|
|
49
|
+
- 未经授权的商业使用构成侵权,权利人保留追究法律责任及索赔的权利。
|
|
50
|
+
Unauthorized commercial use constitutes infringement; the Rights Holder reserves the right to pursue legal liability and claims.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 二、许可人确定与适用法律 / Article 2 — Determination of Licensor and Governing Law
|
|
55
|
+
|
|
56
|
+
本作品由以下两家关联权利实体共同持有,并按使用主体所在地确定本协议项下的许可人:
|
|
57
|
+
The Work is co-owned by the following two affiliated rights entities; the Licensor under this Agreement is determined by the location of the User:
|
|
58
|
+
|
|
59
|
+
| 使用主体所在地 / User Location | 许可人(权利人) / Licensor (Rights Holder) | 适用法律与争议解决 / Governing Law & Dispute Resolution |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| 中华人民共和国境内(含中国自然人、政府机构、事业单位、企业) / Within the PRC (incl. PRC natural persons, government agencies, public institutions, enterprises) | **上海霖铭均华科技有限公司** <br> Shanghai Linming Junhua Technology Co., Ltd. | 中华人民共和国法律(不含冲突法规则);争议提交许可人所在地有管辖权的人民法院诉讼解决。 / Laws of the PRC (excluding conflict-of-law rules); disputes submitted to the competent people's court at the Licensor's location. |
|
|
62
|
+
| 中华人民共和国境外 / Outside the PRC | **NOHN AI TECHNOLOGY PTE. LTD.** | 新加坡法律;因本协议产生的争议提交新加坡国际仲裁中心(SIAC)依其届时有效的仲裁规则仲裁,仲裁裁决具有终局效力并可依《承认及执行外国仲裁裁决公约》(《纽约公约》)强制执行。 / Laws of Singapore; disputes arising under this Agreement shall be finally resolved by arbitration administered by the Singapore International Arbitration Centre (SIAC) under its rules then in force; the award is final and enforceable under the New York Convention. |
|
|
63
|
+
|
|
64
|
+
- 上海霖铭均华科技有限公司(统一社会信用代码 / Unified Social Credit Code:[请填写 / to be completed])
|
|
65
|
+
- NOHN AI TECHNOLOGY PTE. LTD.(UEN:[请填写 / to be completed])
|
|
66
|
+
|
|
67
|
+
> 两实体之间另签有内部知识产权归属与交叉授权协议,确保各自具备前述许可资格。
|
|
68
|
+
> An internal IP ownership and cross-license agreement between the two entities ensures each holds the requisite licensing qualification.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 三、授权申请(商业使用者) / Article 3 — Authorization Application (Commercial Users)
|
|
73
|
+
|
|
74
|
+
商业使用者请联系对应区域的权利人获取授权方案:
|
|
75
|
+
Commercial Users shall contact the Rights Holder for the relevant region:
|
|
76
|
+
|
|
77
|
+
- **国际 / 全球区(International / Global)**:[ai@nohnlins.com](mailto:ai@nohnlins.com)
|
|
78
|
+
- **中国区(China)**:[ai@tx.nohnlins.com](mailto:ai@tx.nohnlins.com)
|
|
79
|
+
|
|
80
|
+
申请时需说明:使用主体性质(政府 / 事业单位 / 企业)、拟用场景、部署规模、预计期限。
|
|
81
|
+
When applying, state: the user's nature (government / public institution / enterprise), intended scenario, deployment scale, and expected term.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 四、通用条款 / Article 4 — General Terms
|
|
86
|
+
|
|
87
|
+
**4.1 无其他授权 / No Other Rights.** 除本协议明示授予者外,不授予任何明示或默示的权利(包括专利权、商标权的任何许可)。 No rights are granted other than those expressly stated herein (including any license of patent or trademark rights).
|
|
88
|
+
|
|
89
|
+
**4.2 无担保 / No Warranty.** 本作品按"现状"提供,不作任何明示或默示担保,包括但不限于对适销性、特定用途适用性及不侵权的担保。 The Work is provided "as is" without any express or implied warranty, including any warranty of merchantability, fitness for a particular purpose, or non-infringement.
|
|
90
|
+
|
|
91
|
+
**4.3 责任限制 / Limitation of Liability.** 无论何种情形,权利人对因使用或不能使用本作品所致的任何间接、特殊、附带或后果性损害不承担责任。 In no event shall the Rights Holder be liable for any indirect, special, incidental, or consequential damages arising from the use or inability to use the Work.
|
|
92
|
+
|
|
93
|
+
**4.4 终止 / Termination.** 任何主体若违反本协议,其获得的所有许可自违反之日起自动终止;终止后须立即停止使用并销毁所有副本。 Any breach automatically terminates all licenses granted; upon termination, use must cease and all copies destroyed.
|
|
94
|
+
|
|
95
|
+
**4.5 商标 / Trademarks.** 本协议不授予任何商标使用权。"Nohn""第二视角"等标识的 ™/® 权利均归相关权利人所有。 No trademark rights are granted; the ™/® marks such as "Nohn" and "Second Perspective" belong to their respective owners.
|
|
96
|
+
|
|
97
|
+
**4.6 适用法律与管辖 / Governing Law and Jurisdiction.** 依第二条(许可人确定与适用法律)之约定确定。 As determined by Article 2.
|
|
98
|
+
|
|
99
|
+
**4.7 可分割性 / Severability.** 任一条款被认定无效,不影响其余条款效力。 If any provision is held invalid, the remainder of this Agreement remains effective.
|
|
100
|
+
|
|
101
|
+
**4.8 完整协议 / Entire Agreement.** 本协议构成双方就本作品授权的完整约定,取代此前所有口头或书面沟通。 This Agreement is the entire understanding between the parties regarding the authorization of the Work and supersedes all prior oral or written communications.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
*提示:本文件为授权框架草稿,正式对外签署商业授权前应由权利人的法律顾问终审,并填入统一社会信用代码 / UEN。*
|
|
106
|
+
*Note: This is a framework document; before executing any commercial authorization, the Rights Holder's legal counsel should review it and complete the Unified Social Credit Code / UEN fields.*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
spl_agent_engine
|