File size: 815 Bytes
0ae385b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from jinja2 import Environment, FileSystemLoader

from gradio_app.backend.ChatGptInteractor import ChatGptInteractor


with open('data/cv_data/resume.txt', 'r', encoding='utf-8') as f:
    resume = f.read().strip()

with open('data/cv_data/job_description.txt', 'r', encoding='utf-8') as f:
    job_description = f.read().strip()

env = Environment(loader=FileSystemLoader('job_app_helper'))
template = env.get_template('cover_letter_template.j2')
prompt = template.render(resume=resume, job_description=job_description)

with open('data/cv_data/prompt.txt', 'w', encoding='utf-8') as f:
    f.write(prompt)

cgi = ChatGptInteractor(model_name='gpt-4-1106-preview')
result = cgi.chat_completion_simple(user_text=prompt)

with open('data/cv_data/cover_letter.txt', 'w', encoding='utf-8') as f:
    f.write(result)