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', '微信昵称'),
        ('name', '姓名'),
        ('avatar', '头像'),
        ('preferred_nickname', '偏好的称呼'),
        ('age', '年龄'),
        ('region', '地区'),
        ('health_conditions', '健康状况'),
        ('medications', '用药信息'),
        ('interests', '兴趣爱好')
    ]
    strings_to_join = []
    for field in fields:
        if not profile.get(field[0], None):
            continue
        if isinstance(profile[field[0]], list):
            value = ','.join(profile[field[0]])
        else:
            value = profile[field[0]]
        cur_string = f"- {field[1]}:{value}"
        strings_to_join.append(cur_string)
    return "\n".join(strings_to_join)