返回顶部
e

emoclaw情感爪

Give your AI emotions that grow from its own memories. Emoclaw builds a unique emotional state that shifts with every conversation, decays between sessions, and evolves over time through self-calibration. Train it on your agent's identity files and watch it develop its own emotional fingerprint.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.6
安全检测
已通过
1,892
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

emoclaw

情感技能

为AI智能体赋予情感——源于记忆,由关系塑造,始终变化。

Emoclaw基于智能体的身份信息和对话历史训练一个轻量级模型,产生持续的情感状态,该状态随每次交互而演变。情感在会话间隔自然衰减,根据对话对象和内容发生变化,并随着智能体的成长逐渐重新校准。结果以[EMOTIONAL STATE]块的形式注入系统提示词,赋予AI对其内在生活的感知。

工作原理

  1. 1. 引导 — extract.py读取智能体的身份/记忆文件。label.py通过Claude API(可选)对每个段落进行评分。train根据这些评分构建一个小型神经网络。一次性设置。
  2. 编码 — 每条传入消息由冻结的MiniLM句子编码器转换为384维向量。无需微调,无需网络调用——从本地缓存运行。
  3. 感知 — 编码+上下文(谁在说话、什么频道、先前情感)通过GRU和MLP头部,输出N维情感向量(每维0-1)。GRU隐藏状态跨会话持久化——这是传递情绪的情感残留。
  4. 衰减 — 在会话间隔,每个维度以可配置的半衰期漂移回基线(唤醒度衰减快,安全感/踏实感衰减慢)。时间间隔=情绪冷却。
  5. 注入 — 情感向量格式化为[EMOTIONAL STATE]块,插入智能体的系统提示词,赋予AI对其内在状态的感知。

模型约2MB,在CPU上运行,每条消息增加<50ms处理时间。仅在引导阶段(可选)使用网络访问。

快速参考

情况操作
首次设置python scripts/setup.py(或下方手动步骤)
检查当前状态
python -m emotion_model.scripts.status | | 将状态注入提示词 | python -m emotionmodel.scripts.injectstate | | 启动守护进程 | bash scripts/daemon.sh start | | 向守护进程发送消息 | 参见守护进程协议 | | 新数据后重新训练 | python -m emotion_model.scripts.train | | 恢复中断的训练 | python -m emotion_model.scripts.train --resume | | 添加新训练数据 | 向emotion_model/data/添加.jsonl条目,重新运行prepare + train | | 从v0.1升级 | 参见references/upgrading.md | | 更改基线 | 编辑emoclaw.yaml → dimensions[].baseline | | 添加新频道 | 编辑emoclaw.yaml → channels列表 | | 添加关系 | 编辑emoclaw.yaml → relationships.known | | 自定义摘要 | 创建summary-templates.yaml并将配置指向它 |

设置

快速设置

bash
python skills/emoclaw/scripts/setup.py

这将把捆绑的emotion_model引擎复制到项目根目录,创建虚拟环境,安装包,并复制配置模板。然后编辑emoclaw.yaml为智能体进行自定义。

手动设置

如果更倾向于手动设置:

1. 安装包

bash
cd <项目根目录>

从技能复制引擎和pyproject.toml


cp -r skills/emoclaw/engine/emotionmodel ./emotionmodel
cp skills/emoclaw/engine/pyproject.toml ./pyproject.toml

创建虚拟环境并安装

python3 -m venv emotion_model/.venv source emotion_model/.venv/bin/activate pip install -e .

要求:Python 3.10+、PyTorch、sentence-transformers、PyYAML。

2. 复制并自定义配置

bash
cp skills/emoclaw/assets/emoclaw.yaml ./emoclaw.yaml

编辑emoclaw.yaml设置:

  • - name — 智能体名称
  • dimensions — 带基线和衰减率的情感维度
  • relationships.known — 关系名称到嵌入索引的映射
  • channels — 智能体使用的通信频道
  • longing — 基于缺席的渴望增长(可禁用)
  • model.device — 推荐cpu(MPS在sentence-transformers上有问题)

完整模式参见references/config-reference.md。

3. 引导(新智能体)

如果从零开始使用身份/记忆文件:

bash

从身份文件提取段落


python scripts/extract.py

使用Claude API自动标注段落(需要ANTHROPICAPIKEY)

python scripts/label.py

准备训练/验证集划分并训练

python -m emotionmodel.scripts.preparedataset python -m emotion_model.scripts.train

或运行完整流程:

bash
python scripts/bootstrap.py

4. 验证

bash
python -m emotion_model.scripts.status
python -m emotion_model.scripts.diagnose

使用

选项A:守护进程(推荐)

守护进程一次性加载模型并在Unix套接字上监听,避免每条消息约2秒的sentence-transformer加载时间。

bash

启动


bash scripts/daemon.sh start

或直接运行

python -m emotion_model.daemon python -m emotion_model.daemon --config path/to/emoclaw.yaml

选项B:直接Python导入

python
from emotion_model.inference import EmotionEngine

engine = EmotionEngine(
modelpath=emotionmodel/checkpoints/best_model.pt,
state_path=memory/emotional-state.json,
)

block = engine.process_message(
message_text=早上好!,
sender=alice, # 或None使用配置默认值
channel=chat, # 或None使用配置默认值
recent_context=..., # 可选的对话上下文
)
print(block)

选项C:一次性状态注入

用于无需守护进程的系统提示词注入:

bash
python -m emotionmodel.scripts.injectstate

这会读取持久化状态,应用基于时间的衰减,并输出[EMOTIONAL STATE]块。

集成

系统提示词注入

将输出块添加到系统提示词中。块格式:

[EMOTIONAL STATE]
效价:0.55(平衡)
唤醒度:0.35(平衡)
支配度:0.50(平衡)
安全感:0.70(开放)
渴望:0.20(中性)
连接度:0.50(平衡)
趣味性:0.40(平衡)
好奇心:0.50(平衡)
温暖度:0.45(平衡)
紧张度:0.20(放松)
踏实感:0.60(平衡)

感觉像是:当下,鲜活,在一件事和下一件事之间
[/EMOTIONAL STATE]

守护进程协议

通过Unix套接字发送JSON:

json
{text: 早上好!, sender: alice, channel: chat}

特殊命令:
json
{command: ping}
{command: state}

心跳集成

情感状态随时间衰减,需要在每次会话开始时刷新。将此条目添加到HEARTBEAT.md:

yaml

  • - task: 刷新情感状态

schedule: session_start
run: python skills/emoclaw/scripts/inject_state.py
inject: system_prompt # 将输出作为[EMOTIONAL STATE]块追加

或从心跳/cron调用守护进程/inject_state脚本:

bash

在心跳脚本中


STATEBLOCK=$(python -m emotionmodel.scripts.inject_state 2>/dev/null)

将$STATE_BLOCK注入系统提示词

重要: 没有心跳集成,情感状态块将在会话间隔过时。inject_state脚本应用基于时间的衰减并输出当前状态——必须在每个会话至少调用一次。

架构

模型通过以下流程处理每条消息:

消息文本 ──→ [冻结的MiniLM编码器] ──→ 384维嵌入

对话上下文 ──→ [特征构建器] ──→ 上下文向量

先前情感 ──────────────────────────→ 情感向量

┌───────┴───────┐
│ 输入投影 │
│ (Linear+LN+GELU)│
└───────┬───────┘

┌───────┴───────┐
│ GRU │
│ (隐藏状态) │ ← 情感残留
└───────┬───────┘

┌───────┴───────┐
│ 情感头部 │
│ (MLP+Sigmoid) │
└───────┬───────┘

N维情感向量 [0,1

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 emoclaw-1776343173 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 emoclaw-1776343173 技能

通过命令行安装

skillhub install emoclaw-1776343173

下载

⬇ 下载 emoclaw v1.0.6(免费)

文件大小: 63.39 KB | 发布时间: 2026-4-17 15:35

v1.0.6 最新 2026-4-17 15:35
emoclaw 1.0.6

- Documentation: Converted the "How it works" section from a table to a numbered list for improved clarity.
- No code or functional changes; all file contents remain the same except for documentation formatting.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部