File size: 1,550 Bytes
c6d9110
 
a5883c9
c6d9110
c2e4879
a5883c9
 
c6d9110
c2e4879
c6d9110
 
 
 
 
 
 
c2e4879
a5883c9
 
c2e4879
 
 
 
a5883c9
c2e4879
 
 
 
a5883c9
c2e4879
c6d9110
a5883c9
 
c2e4879
 
 
a5abd3b
 
 
a5883c9
c6d9110
a5883c9
 
c6d9110
 
 
 
c2e4879
c6d9110
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pypdf
from streamlit.runtime.uploaded_file_manager import UploadedFile

# from docx import Document
from resume_maker_ai_agent.crew import ResumeMakerAIAgent


def read_pdf(uploaded_file: UploadedFile) -> str:
    text = ""
    try:
        pdf_reader = pypdf.PdfReader(uploaded_file)

        for page in pdf_reader.pages:
            text += page.extract_text()
    except Exception as e:
        print(f"An unexpected error occurred: {e}")
    return text


def run(pdf_file_path: UploadedFile, job_description: str) -> str:
    """
    Processes a PDF resume file, customizes it based on the job description,
    and returns the updated resume text.

    :param pdf_file_path: Path to the PDF file containing the resume.
    :param job_description: Description of the job for which the resume needs to be customized.
    :return: A string representing the updated resume content.
    """

    print("Extracting text from PDF")
    resume_text = read_pdf(pdf_file_path)

    # Run the crew
    print("Running the crew")
    inputs = {"resume_text": resume_text, "job_description": job_description}
    result = ResumeMakerAIAgent().crew().kickoff(inputs=inputs)
    print("Done")

    print(result.raw)

    return str(result.raw)


# def create_docx(content) -> bytes | None:
#     """Create a Word document with the content."""
#     # doc = Document()
#     # doc.add_paragraph(content)

#     # # Save to bytes buffer
#     # buffer = io.BytesIO()
#     # doc.save(buffer)
#     # buffer.seek(0)
#     # return buffer
#     return None