offer-puplayer / backend /app /orchestrator.py
tryprogram's picture
Upload 46 files
61fd574 verified
Raw History Blame Contribute Delete
1.48 kB
import json
from typing import AsyncGenerator
from app.agents.jd_parser import JdParser
from app.agents.matcher import Matcher
from app.agents.advisor import Advisor
class ReportOrchestrator:
def __init__(self):
self.jd_parser = JdParser()
self.matcher = Matcher()
self.advisor = Advisor()
async def generate_report(self, resume_data: dict, jd_text: str) -> AsyncGenerator[str, None]:
yield json.dumps({"type": "agent_start", "agent": "agent1"}, ensure_ascii=False)
jd_parsed = await self.jd_parser.parse_jd(jd_text)
yield json.dumps({"type": "agent_complete", "agent": "agent1", "data": jd_parsed}, ensure_ascii=False)
yield json.dumps({"type": "agent_start", "agent": "agent2"}, ensure_ascii=False)
match_report = await self.matcher.match_resume(resume_data, jd_parsed)
yield json.dumps({"type": "agent_complete", "agent": "agent2", "data": match_report}, ensure_ascii=False)
yield json.dumps({"type": "agent_start", "agent": "agent3"}, ensure_ascii=False)
advice = await self.advisor.generate_suggestions(match_report, jd_text)
yield json.dumps({"type": "agent_complete", "agent": "agent3", "data": advice}, ensure_ascii=False)
full_report = {
"jd_parsed": jd_parsed,
"match_report": match_report,
"advice": advice,
}
yield json.dumps({"type": "report_complete", "data": full_report}, ensure_ascii=False)