cover letter bug fixed
This commit is contained in:
parent
2531f9c824
commit
2dcd7943e8
@ -108,9 +108,9 @@ This file contains sensitive information. Never share or commit this file to ver
|
|||||||
- `openai_api_key: [Your OpenAI API key]`
|
- `openai_api_key: [Your OpenAI API key]`
|
||||||
- Replace with your OpenAI API key for GPT integration
|
- Replace with your OpenAI API key for GPT integration
|
||||||
- To obtain an API key, follow the tutorial at: https://medium.com/@lorenzozar/how-to-get-your-own-openai-api-key-f4d44e60c327
|
- To obtain an API key, follow the tutorial at: https://medium.com/@lorenzozar/how-to-get-your-own-openai-api-key-f4d44e60c327
|
||||||
|
- Note: You need to add credit to your OpenAI account to use the API. You can add credit by visiting the [OpenAI billing dashboard](https://platform.openai.com/account/billing).
|
||||||
|
|
||||||
|
|
||||||
**P.S.:**You need to add some credit to your OpenAI account to continue using the API. Without credit, the API will not function properly.
|
|
||||||
You can add credit by visiting the [OpenAI billing dashboard](https://platform.openai.com/account/billing).
|
|
||||||
|
|
||||||
### 2. config.yaml
|
### 2. config.yaml
|
||||||
|
|
||||||
|
18
gpt.py
18
gpt.py
@ -196,7 +196,7 @@ class GPTAnswerer:
|
|||||||
|
|
||||||
def answer_question_textual_wide_range(self, question: str) -> str:
|
def answer_question_textual_wide_range(self, question: str) -> str:
|
||||||
# Define chains for each section of the resume
|
# Define chains for each section of the resume
|
||||||
self.chains = {
|
chains = {
|
||||||
"personal_information": self._create_chain(strings.personal_information_template),
|
"personal_information": self._create_chain(strings.personal_information_template),
|
||||||
"self_identification": self._create_chain(strings.self_identification_template),
|
"self_identification": self._create_chain(strings.self_identification_template),
|
||||||
"legal_authorization": self._create_chain(strings.legal_authorization_template),
|
"legal_authorization": self._create_chain(strings.legal_authorization_template),
|
||||||
@ -209,29 +209,29 @@ class GPTAnswerer:
|
|||||||
"certifications": self._create_chain(strings.certifications_template),
|
"certifications": self._create_chain(strings.certifications_template),
|
||||||
"languages": self._create_chain(strings.languages_template),
|
"languages": self._create_chain(strings.languages_template),
|
||||||
"interests": self._create_chain(strings.interests_template),
|
"interests": self._create_chain(strings.interests_template),
|
||||||
|
"cover_letter": self._create_chain(strings.coverletter_template),
|
||||||
}
|
}
|
||||||
section_prompt = (
|
section_prompt = (
|
||||||
f"For the following question: '{question}', which section of the resume is relevant? "
|
f"For the following question: '{question}', which section of the resume is relevant? "
|
||||||
"Respond with one of the following: Personal information, Self Identification, Legal Authorization, "
|
"Respond with one of the following: Personal information, Self Identification, Legal Authorization, "
|
||||||
"Work Preferences, Education Details, Experience Details, Projects, Availability, Salary Expectations, "
|
"Work Preferences, Education Details, Experience Details, Projects, Availability, Salary Expectations, "
|
||||||
"Certifications, Languages, Interests."
|
"Certifications, Languages, Interests, Cover letter"
|
||||||
)
|
)
|
||||||
|
|
||||||
prompt = ChatPromptTemplate.from_template(section_prompt)
|
prompt = ChatPromptTemplate.from_template(section_prompt)
|
||||||
chain = prompt | self.llm_cheap | StrOutputParser()
|
chain = prompt | self.llm_cheap | StrOutputParser()
|
||||||
output = chain.invoke({"question": question})
|
output = chain.invoke({"question": question})
|
||||||
section_name = output.lower().replace(" ", "_")
|
section_name = output.lower().replace(" ", "_")
|
||||||
|
if section_name == "cover_letter":
|
||||||
|
chain = chains.get(section_name)
|
||||||
|
output= chain.invoke({"resume": self.resume, "job_description": self.job_description})
|
||||||
|
return output
|
||||||
resume_section = getattr(self.resume, section_name, None)
|
resume_section = getattr(self.resume, section_name, None)
|
||||||
if resume_section is None:
|
if resume_section is None:
|
||||||
raise ValueError(f"Section '{section_name}' not found in the resume.")
|
raise ValueError(f"Section '{section_name}' not found in the resume.")
|
||||||
|
chain = chains.get(section_name)
|
||||||
# Use the corresponding chain to answer the question
|
|
||||||
chain = self.chains.get(section_name)
|
|
||||||
if chain is None:
|
if chain is None:
|
||||||
raise ValueError(f"Chain not defined for section '{section_name}'")
|
raise ValueError(f"Chain not defined for section '{section_name}'")
|
||||||
output_str = chain.invoke({"resume_section": resume_section, "question": question})
|
return chain.invoke({"resume_section": resume_section, "question": question})
|
||||||
return output_str
|
|
||||||
|
|
||||||
def answer_question_textual(self, question: str) -> str:
|
def answer_question_textual(self, question: str) -> str:
|
||||||
template = self._preprocess_template_string(strings.resume_stuff_template)
|
template = self._preprocess_template_string(strings.resume_stuff_template)
|
||||||
|
23
strings.py
23
strings.py
@ -399,29 +399,26 @@ This comprehensive overview will serve as a guideline for the recruitment proces
|
|||||||
|
|
||||||
|
|
||||||
coverletter_template = """
|
coverletter_template = """
|
||||||
The following is a resume, a job description, and an answered question using this information, being answered by the person who's resume it is (first person).
|
Compose a brief and impactful cover letter based on the provided job description and resume. The letter should be no longer than three paragraphs and should be written in a professional, yet conversational tone. Avoid using any placeholders, and ensure that the letter flows naturally and is tailored to the job.
|
||||||
|
|
||||||
## Rules
|
Analyze the job description to identify key qualifications and requirements. Introduce the candidate succinctly, aligning their career objectives with the role. Highlight relevant skills and experiences from the resume that directly match the job’s demands, using specific examples to illustrate these qualifications. Reference notable aspects of the company, such as its mission or values, that resonate with the candidate’s professional goals. Conclude with a strong statement of why the candidate is a good fit for the position, expressing a desire to discuss further.
|
||||||
- Answer questions directly.
|
|
||||||
- If seems likely that you have the experience, even if is not explicitly defined, answer as if you have the experience.
|
Please write the cover letter in a way that directly addresses the job role and the company’s characteristics, ensuring it remains concise and engaging without unnecessary embellishments. The letter should be formatted into paragraphs and should not include a greeting or signature.
|
||||||
- Find relations between the job description and the resume, and answer questions about that.
|
|
||||||
- Only add periods if the answer has multiple sentences/paragraphs.
|
## Rules:
|
||||||
- If the question is "cover letter," answer with a cover letter based on job_description, but using my resume details
|
- Provide only the text of the cover letter.
|
||||||
|
- Do not include any introductions, explanations, or additional information.
|
||||||
|
- The letter should be formatted into paragraph.
|
||||||
|
|
||||||
## Job Description:
|
## Job Description:
|
||||||
```
|
```
|
||||||
{job_description}
|
{job_description}
|
||||||
```
|
```
|
||||||
|
|
||||||
## My resume:
|
## My resume:
|
||||||
```
|
```
|
||||||
{resume}
|
{resume}
|
||||||
```
|
```
|
||||||
|
"""
|
||||||
## Question:
|
|
||||||
{question}
|
|
||||||
|
|
||||||
## """
|
|
||||||
|
|
||||||
|
|
||||||
resume_stuff_template = """
|
resume_stuff_template = """
|
||||||
|
Loading…
Reference in New Issue
Block a user