File size: 1,479 Bytes
61fd574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)