Spaces:
Sleeping
Sleeping
File size: 1,341 Bytes
0c94c61 22be37d 98eaa40 22be37d 98eaa40 22be37d 98eaa40 0c94c61 98eaa40 22be37d 0c94c61 98eaa40 0c94c61 22be37d 98eaa40 22be37d 98eaa40 0c94c61 98eaa40 |
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 |
"""
Main Backend Handling Function
"""
from utils.prompts import (
basic_details_extraction_prompt,
general_skils_extraction_prompt,
specific_skills_comparison_prompt,
)
from utils.gpt import gpt_response
prompt_mapping = {
"basic": basic_details_extraction_prompt,
"general": general_skils_extraction_prompt,
"specific": specific_skills_comparison_prompt,
}
def produce_report(
cv_contents: str, job_post_contents: str, PROMPT_TO_USE: str, API_KEY: str
) -> str:
"""Process CV contents, using Cohere"""
# The KEY ARGUMENT here is PROMPT_TO_USE, which controls the prompt to use
# First, get the prompt from the prompt dict
prompt = prompt_mapping.get(PROMPT_TO_USE)
# Now, populate with the contents of the CV and job posting
prompt = prompt.replace("<cv>", cv_contents).replace(
"<job-posting>", job_post_contents
)
response = gpt_response(
prompt=prompt,
api_key=API_KEY,
)
return response
if __name__ == "__main__":
with open("sample_data/meta_job.txt", "r") as file:
post_contents = file.read()
with open("sample_data/example_cv.txt", "r") as file:
cv_contents = file.read()
COHERE_API_KEY = ""
output = produce_report(post_contents, cv_contents, "specific", COHERE_API_KEY)
print(output)
|