1234567891011121314151617181920212223 |
- 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)
|