79 lines
3.0 KiB
Markdown
79 lines
3.0 KiB
Markdown
|
|
# Memory System Design
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
每用户有两条记忆记录(user_type 和 work_type),存储在 `memories` 表的 `content` JSONB 字段中。
|
||
|
|
|
||
|
|
## Data Model
|
||
|
|
|
||
|
|
### UserMemoryContent
|
||
|
|
|
||
|
|
```python
|
||
|
|
class UserPreferences(BaseModel):
|
||
|
|
time_preference: str | None = None # "上午效率高"
|
||
|
|
communication_style: str | None = None # "简洁直接"
|
||
|
|
location_preference: str | None = None # "喜欢远程工作"
|
||
|
|
work_lifestyle: str | None = None # "早睡早起"
|
||
|
|
|
||
|
|
class UserMemoryContent(BaseModel):
|
||
|
|
occupation: str | None = None # 职业
|
||
|
|
timezone: str | None = None # 时区
|
||
|
|
language: str | None = None # 语言偏好
|
||
|
|
people: list[str] = [] # 重要人物
|
||
|
|
places: list[str] = [] # 常去地点
|
||
|
|
projects: list[str] = [] # 个人项目
|
||
|
|
preferences: UserPreferences = UserPreferences()
|
||
|
|
interests: list[str] = [] # 兴趣爱好
|
||
|
|
avoid_topics: list[str] = [] # 不想讨论的话题
|
||
|
|
custom_rules: list[str] = [] # 自定义规则
|
||
|
|
recurring_contexts: list[str] = [] # 周期性场景
|
||
|
|
```
|
||
|
|
|
||
|
|
### WorkMemoryContent
|
||
|
|
|
||
|
|
```python
|
||
|
|
class WorkProject(BaseModel):
|
||
|
|
name: str
|
||
|
|
description: str | None = None
|
||
|
|
status: str | None = None # "active", "paused"
|
||
|
|
key_milestones: list[str] = [] # 关键里程碑
|
||
|
|
|
||
|
|
class WorkHabit(BaseModel):
|
||
|
|
available_hours: dict[str, str] = {} # {"monday": "09:00-18:00"}
|
||
|
|
deep_work_blocks: list[str] = [] # 深度工作时段
|
||
|
|
meeting_preference: str | None = None # "short", "30min最佳"
|
||
|
|
notification_channel: str | None = None # 首选沟通渠道
|
||
|
|
|
||
|
|
class WorkMemoryContent(BaseModel):
|
||
|
|
expertise: list[str] = [] # 专业领域
|
||
|
|
preferred_tools: list[str] = [] # 惯用工具
|
||
|
|
current_projects: list[WorkProject] = []
|
||
|
|
work_habits: WorkHabit = WorkHabit()
|
||
|
|
team_members: list[str] = [] # 团队成员
|
||
|
|
team_context: str | None = None # 团队概述
|
||
|
|
```
|
||
|
|
|
||
|
|
## API Endpoints
|
||
|
|
|
||
|
|
| Method | Endpoint | Description |
|
||
|
|
|--------|----------|-------------|
|
||
|
|
| GET | `/api/v1/memories` | 获取用户所有记忆 |
|
||
|
|
| PUT | `/api/v1/memories/user` | 创建/更新用户记忆 |
|
||
|
|
| PUT | `/api/v1/memories/work` | 创建/更新工作记忆 |
|
||
|
|
| DELETE | `/api/v1/memories/{type}` | 删除指定类型记忆 |
|
||
|
|
|
||
|
|
## TaskType支撑关系
|
||
|
|
|
||
|
|
| TaskType | Router决策依赖 | Worker执行依赖 |
|
||
|
|
|----------|---------------|---------------|
|
||
|
|
| SCHEDULING | timezone, available_hours | current_projects, team_members |
|
||
|
|
| PLANNING | preferences, work_lifestyle | expertise, work_habits |
|
||
|
|
| COMMUNICATION_DRAFTING | communication_style, avoid_topics | team_context, preferred_tools |
|
||
|
|
| RECOMMENDATION | interests, people | expertise, current_projects |
|
||
|
|
|
||
|
|
## Frontend UI
|
||
|
|
|
||
|
|
- MemoryScreen: 主列表页,展示user/work两条记忆卡片
|
||
|
|
- MemoryDetailScreen: 详情/编辑页,分Tab展示各字段
|
||
|
|
- 支持新建/编辑/删除操作
|