child-psycho-companion/README.md

108 lines
2.8 KiB
Markdown
Raw Normal View History

# 儿童心理陪伴玩偶
基于小智AI生态的儿童心理筛查插件通过分析儿童与玩偶的对话内容
识别潜在的心理问题(如霸凌、抑郁情绪、焦虑、家庭矛盾等),
为家长提供早期预警。
## 项目结构
```
child-psycho-companion/
├── src/
│ └── psycho_screener/ # 核心筛查模块
│ ├── __init__.py
│ └── screener.py # 筛查器实现
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── test_screener.py # 单元测试
├── .env.example # 环境变量模板
├── pyproject.toml
└── README.md
```
## 快速开始
### 1. 安装
```bash
cd child-psycho-companion
pip install -e .
```
### 2. 配置 API Key
```bash
export MINIMAX_API_KEY=your-api-key-here
```
### 3. 使用示例
```python
from psycho_screener import PsychoScreener
screener = PsychoScreener(api_key="your-api-key")
# 对儿童对话进行筛查
context = """
孩子:今天在学校,小明又打我了,我好害怕。
孩子:他说如果我告诉老师就会打我。
"""
result = screener.screen(context)
if result.detected:
print(f"检测到问题:{result.summary}")
prefix = screener.build_response_prefix(result)
print(f"响应前缀:{prefix}")
```
### 4. 运行测试
```bash
# 安装测试依赖
pip install -e ".[dev]"
# 运行单元测试Mock 模式,不调用真实 API
pytest tests/test_screener.py -v -m unit
# 运行集成测试(需要真实 API key
export MINIMAX_API_KEY=your-key
pytest tests/test_screener.py -v -m integration
```
## 核心流程
```
儿童语音 → 小智AI (STT) → 对话上下文
心理筛查器 (MiniMax API)
ScreeningResult {detected, category, severity}
┌───────────┴───────────┐
detected=True detected=False
↓ ↓
注入前缀标记 原样返回
"已发现特定心理问题:..."
```
## 检测类别
| 类别 | 描述 | 严重程度 |
|------|------|---------|
| bullying | 霸凌/同伴冲突 | low-high |
| depression | 抑郁情绪 | medium-high |
| anxiety | 焦虑/恐惧 | low-medium |
| family_conflict | 家庭矛盾 | medium-high |
| self_esteem | 自卑/自我否定 | low-medium |
| trauma | 创伤事件 | medium-high |
| social_isolation | 社交孤立 | medium-high |
| other | 其他心理需求 | - |
## 下一步
- [ ] 接入 xinnan-tech/xiaozhi-esp32-server MCP 接入点
- [ ] 构建案例库系统
- [ ] 开发咨询师终端
- [ ] 家长端报告界面