forked from amanv1906/GENAI-CareerAssistant-Multiagent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_loader.py
41 lines (33 loc) · 1.12 KB
/
data_loader.py
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
from docx import Document
from langchain_community.document_loaders import PyMuPDFLoader
def load_resume(file_path):
"""
Load the content of a CV file.
Parameters:
file (str): The path to the CV file.
Returns:
str: The content of the CV file.
"""
loader = PyMuPDFLoader(file_path)
pages = loader.load()
page_content = ""
for page in pages:
page_content += page.page_content
return page_content
def write_cover_letter_to_doc(text, filename="temp/cover_letter.docx"):
"""
Writes the given text as a cover letter to a Word document.
Parameters:
text (str): The text content of the cover letter.
filename (str): The filename and path where the document will be saved. Default is "temp/cover_letter.docx".
Returns:
str: The filename and path of the saved document.
"""
doc = Document()
paragraphs = text.split("\n")
# Add each paragraph to the document
for para in paragraphs:
doc.add_paragraph(para)
# Save the document to the specified file
doc.save(filename)
return filename