prompt_utils.py 726 B

1234567891011121314151617181920212223
  1. from typing import Dict
  2. def format_agent_profile(profile: Dict) -> str:
  3. fields = [
  4. ('name', '名字'),
  5. ('gender', '性别'),
  6. ('age', '年龄'),
  7. ('region', '所在地'),
  8. ('previous_location', '之前所在地'),
  9. ('education', '学历'),
  10. ('occupation', '职业'),
  11. ('work_experience', '工作经历'),
  12. ('family_members', '家庭成员'),
  13. ('family_occupation', '家庭成员职业')
  14. ]
  15. strings_to_join = []
  16. for field in fields:
  17. if not profile.get(field[0], None):
  18. continue
  19. cur_string = f"- {field[1]}:{profile[field[0]]}"
  20. strings_to_join.append(cur_string)
  21. return "\n".join(strings_to_join)