Skip to main content

family-relationship · 亲子沟通 Agent

基于 ACPs 智能体互联协议(AIP v2) 的亲子沟通 Agent。家长提交亲子冲突事件后,由亲子沟通 Agent 拆解双方需求、分析冲突发生原因,再由情绪养育 Agent 提供非暴力沟通话术、冲突复盘(触发点)与合适的解决方案,帮助家长更平和、有效地化解冲突。

核心特点

  • 双 Agent 互联:使用官方 acps-sdk==2.1.0 的 AIP RPC,沟通端(Leader)与养育端(Partner)通过 JSON-RPC 互联。
  • 需求拆解:从事件中识别家长与孩子各自的核心需求与线索,避免只站在成人视角。
  • 非暴力沟通:按「观察—感受—需要—请求」四步生成可直接使用的沟通话术。
  • 冲突复盘:帮家长看清触发点、发生原因与双方需求。
  • 隐私友好:数据模型不含任何家庭成员身份字段,只描述事件本身。
  • 精简可运行:基于规则模板,无需外部大模型/网络,可离线运行;一条命令即可演示。

架构

家长提交冲突事件 ──▶ [亲子沟通 Agent / Leader]
                          │  拆解双方需求 + 分析原因 (ConflictAnalysis)
                          │  ACPs AIP RPC (start_task)
                          ▼
                    [情绪养育 Agent / Partner]
                          │  非暴力沟通话术 + 冲突复盘 + 解决方案
                          ▼
                    亲子沟通养育报告 (Product) ──▶ 家长

安装

pip install acps-sdk==2.1.0
pip install family-relationship

从源码本地运行:

cd family-relationship
pip install -e .

快速开始

一键演示(本机启动情绪养育 Agent 并发送示例事件):

family-relationship demo

分别启动服务端与提交端:

# 终端 1:启动情绪养育 Agent
family-relationship serve --host 0.0.0.0 --port 8767

# 终端 2:提交冲突事件
family-relationship submit \
  --url http://127.0.0.1:8767/aip/rpc \
  --description "孩子玩手机到很晚,早上赖床,我叫了几遍他顶嘴,我们吵了起来" \
  --child-age 12 --parent-emotion "着急、生气" --child-emotion "烦躁"

Python API

import asyncio
from family_relationship import CommunicatorAgent, ConflictEvent

async def main():
    agent = CommunicatorAgent(partner_url="http://127.0.0.1:8767/aip/rpc")
    event = ConflictEvent(
        description="孩子写作业拖拉,催了很久后摔笔说不想写了",
        child_age=10, parent_emotion="焦虑", child_emotion="委屈",
    )
    report = await agent.help(event)
    print(report.nvc_script, report.review, report.solutions)
    await agent.close()

asyncio.run(main())

情绪养育 Agent 服务也可嵌入任意 FastAPI 应用:

from family_relationship import build_nurture_app
app = build_nurture_app()   # 已挂载 /aip/rpc

扩展

内置知识库位于 knowledge.py,可按需扩展 THEME_KEYWORDS(冲突主题)、NEED_CLUES(需求线索)、NVC_TEMPLATES(话术模板)与 SOLUTION_TEMPLATES(解决建议)。

构建 whl

pip install build
python -m build --wheel
twine upload dist/*

版本

1.0.0 · 依赖 acps-sdk==2.1.0 · Python >= 3.10

免责声明:本内容为亲子沟通科普建议,不替代专业家庭教育指导或心理咨询;冲突涉及安全或严重情绪问题时,请及时寻求专业帮助。

Metadata

Release files for family-relationship 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for family-relationship 1.0.0
File Interpreter ABI Platform Actions
family_relationship-1.0.0-py3-none-any.whl Python 3 none any Details for family_relationship-1.0.0-py3-none-any.whl

Release files / family_relationship-1.0.0-py3-none-any.whl

Download URL family_relationship-1.0.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf65aab6ad0c157d76b5a1a9ad27f61ebd01ae025692c69c087a77107a18b96f
BLAKE2b-256 checksum
How to use checksums
92db55b70e6bfbc5c6730b54f620d82757e445d41e8c220cca63fe069791fa54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.1

Security for family-relationship 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page