from typing import Dict def format_agent_profile(profile: Dict) -> str: fields = [ ('name', '名字'), ('gender', '性别'), ('age', '年龄'), ('region', '所在地'), ('previous_location', '之前所在地'), ('education', '学历'), ('occupation', '职业'), ('work_experience', '工作经历'), ('family_members', '家庭成员'), ('family_occupation', '家庭成员职业') ] strings_to_join = [] for field in fields: if not profile.get(field[0], None): continue cur_string = f"- {field[1]}:{profile[field[0]]}" strings_to_join.append(cur_string) return "\n".join(strings_to_join) def format_user_profile(profile: Dict) -> str: """ :param profile: :return: formatted string. example: - 微信昵称:{nickname} - 姓名:{name} - 头像:{avatar} - 偏好的称呼:{preferred_nickname} - 年龄:{age} - 地区:{region} - 健康状况:{health_conditions} - 用药信息:{medications} - 兴趣爱好:{interests} """ fields = [ ('nickname', '微信昵称'), ('preferred_nickname', '希望对其的称呼'), ('name', '姓名'), ('avatar', '头像'), ('gender', '性别'), ('age', '年龄'), ('region', '地区'), ('health_conditions', '健康状况'), ('interests', '兴趣爱好'), ('interaction_frequency', '联系频率'), ('flexible_params', '动态特征'), ] strings_to_join = [] for field in fields: value = profile.get(field[0], None) if not value: continue if isinstance(value, list): value = ','.join(value) elif isinstance(value, dict): value = ';'.join(f"{k}: {v}" for k, v in value.items()) else: value = profile[field[0]] cur_string = f"- {field[1]}:{value}" strings_to_join.append(cur_string) return "\n".join(strings_to_join)