Spaces:
Sleeping
Sleeping
Download backend/app/agents/resume_parser.py from tryprogram/offer-puplayer: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/backend/app/agents/resume_parser.py
- Command line
-
hf download hf://spaces/tryprogram/offer-puplayer/backend/app/agents/resume_parser.py
-
curl -L -o resume_parser.py https://huggingface.co/spaces/tryprogram/offer-puplayer/resolve/main/backend/app/agents/resume_parser.py
1.64 kB
| import os | |
| from app.agents.base_agent import BaseAgent | |
| MOCK_RESULT = { | |
| "name": "张三", | |
| "school": "华南理工大学", | |
| "major": "计算机科学与技术", | |
| "grade": "研二", | |
| "skills": ["Python", "Java", "SQL", "PyTorch", "Flask"], | |
| "projects": ["基于协同过滤的推荐系统", "在线商城后端开发"], | |
| "summary": "技术栈集中在Python/Java后端开发,有推荐系统和Web开发项目经验", | |
| } | |
| class ResumeParser(BaseAgent): | |
| name = "resume_parser" | |
| def build_prompt(self, pdf_text: str) -> tuple[str, dict]: | |
| system = ( | |
| "你是一个简历解析专家。从提供的简历文本中提取以下结构化信息,字段名必须精确匹配:\n" | |
| "1. name: 姓名\n" | |
| "2. school: 学校\n" | |
| "3. major: 专业\n" | |
| "4. grade: 年级/学历(如'研二'、'本科四年级'、'硕士')\n" | |
| "5. skills: 技能列表(数组,提取所有技术关键词,不遗漏)\n" | |
| "6. projects: 项目经历列表(数组,每项包含 name 和 description 字段)\n" | |
| "7. summary: 一句话摘要\n\n" | |
| "输出JSON格式,不要markdown代码块。" | |
| ) | |
| user = {"resume_text": pdf_text} | |
| return system, user | |
| async def parse_resume(self, pdf_text: str) -> dict: | |
| if not os.getenv("DEEPSEEK_API_KEY"): | |
| return dict(MOCK_RESULT) | |
| system, user_input = self.build_prompt(pdf_text) | |
| result = await self.call_llm(system, user_input) | |
| if "error" in result: | |
| return dict(MOCK_RESULT) | |
| return result | |