Open RudyVane opened 1 year ago
To prompt ChatGPT to compare two JSON files containing skills (one from a job offer and another from a user's skill matrix) and generate a list of matching skills, a list of missing skills, and calculate the matching percentage, you can use the following instruction:
import openai
def compare_skills(job_offer_skills, user_skills): prompt = f"Compare the skills from the job offer and user's skill matrix:\n\nJob Offer Skills:\n{job_offer_skills}\n\nUser Skills:\n{user_skills}\n\nOutput the list of matching skills, list of missing skills, and the matching percentage as JSON."
# Set up OpenAI API credentials
openai.api_key = 'YOUR_API_KEY'
# Generate the response from ChatGPT
response = openai.Completion.create(
engine='davinci-codex', # Or any other suitable engine
prompt=prompt,
max_tokens=200,
temperature=0.6,
n=1,
stop=None,
temperature=0.6
)
# Extract the comparison results from the response
comparison_results = response.choices[0].text.strip()
# Save the comparison results as JSON file
with open('comparison_results.json', 'w') as file:
file.write(comparison_results)
job_offer_skills = "Skills from job offer in JSON format" user_skills = "Skills from user's skill matrix in JSON format" compare_skills(job_offer_skills, user_skills) In the above code snippet, the compare_skills() function takes two JSON files, one containing the skills from a job offer and another containing the skills from the user's skill matrix. It prompts ChatGPT to compare the two sets of skills and generate a list of matching skills, a list of missing skills, and the matching percentage. The prompt includes the job offer skills and user skills in JSON format, and instructs ChatGPT to output the comparison results as JSON. After receiving the response from ChatGPT, the comparison results are saved in a JSON file named "comparison_results.json". You need to replace 'YOUR_API_KEY' with your actual OpenAI API key.
Please note that this code is a simplified implementation, and you may need to modify it according to your specific needs or adjust the parameters for generating responses from ChatGPT.
Deliver prompt to chatGPT to compare both files and calculate matching percentage