Spaces:
Build error
Build error
| """ | |
| 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) | |