初始化用户元数据列表
(
roles: Dict[str, Dict[str, Any]],
profiles: Dict[str, Dict[str, Any]],
)
| 54 | |
| 55 | |
| 56 | def init_user_metadata( |
| 57 | roles: Dict[str, Dict[str, Any]], |
| 58 | profiles: Dict[str, Dict[str, Any]], |
| 59 | ) -> List[Dict[str, Any]]: |
| 60 | """初始化用户元数据列表""" |
| 61 | users = [] |
| 62 | |
| 63 | for role_name, role_data in sorted(roles.items()): |
| 64 | user_id = role_data.get("user_id", f"user_{role_name}") |
| 65 | profile_data = profiles.get(user_id, {}) |
| 66 | profile = profile_data.get("profile", {}) |
| 67 | |
| 68 | users.append({ |
| 69 | "user_id": user_id, |
| 70 | "role_name": role_name, |
| 71 | "description": role_data.get("description") or profile.get("description", ""), |
| 72 | "seed_directions": profile.get("core_directions", {}), |
| 73 | "initial_topics": list(profile.get("core_directions", {}).keys()), |
| 74 | "created_at": datetime.now().strftime("%Y-%m-%d"), |
| 75 | }) |
| 76 | |
| 77 | return users |
| 78 | |
| 79 | |
| 80 | def main(): |