Page 8: Using OpenAI API to write
Hello again :) It has been roughly a week since my last post and man, has it gotten real (fun).
Spent the last 6 days building out https://hirable.fyi/
What did I do in those days?
API: Write a resume based on user data
We want Hirable to create a resume draft for me based on my basic information. Let’s take this UserData
interface:
export interface UserData {
name: string;
professionTitle: string;
about: string;
experiences: UserWorkExperience[];
skills: UserSkill[];
education: UserEducation[];
hobbies: UserHobby[];
profilePicture?: string;
linkedInId?: string;
}
export interface UserHobby {
name: string;
description: string;
}
export interface UserSkill {
name: string;
level: number;
}
export interface UserWorkExperience {
jobTitle: string;
companyName: string;
startDate: string;
endDate: string;
location: string;
description: string;
}
export interface UserEducation {
schoolName: string;
degree: string;
startDate: string;
endDate: string;
location: string;
description: string;
}
Let’s build an API endpoint to OpenAI:
// server
const openAIResponse = await openai.createCompletion({
model: "text-davinci-003",
prompt: userDataPrompt(payload.data),
temperature: 0.5,
max_tokens: 3000,
});
const userDataPrompt = (userData: UserData) => {
const exp = userData.experiences
.filter(nonEmpty)
.map((exp) => jobExperiencePrompt(exp));
const edu = userData.education
.filter(nonEmpty)
.map((edu) => educationExperiencePrompt(edu));
const skills = userData.skills
.filter(nonEmpty)
.map((skill) => skillPrompt(skill));
const sections = {
info: userData.name && `My name is ${userData.name}.`,
profession:
userData.professionTitle && `I am a ${userData.professionTitle}.`,
about: userData.about && `${userData.about}.`,
experience: exp.length > 0 && exp.join(""),
education: edu.length > 0 && edu.join(""),
skills: skills.length > 0 && skills.join(""),
intro: `
Write an effective resume for me, highlighting my strengths and experience.
Please write in standard resume format with a confident and analytical tone.
`,
};
return Object.values(sections)
.filter((section) => section)
.join(" ");
};
Example response when I fed some seed data.
John Doe
Software Engineer
Summary
A highly experienced software engineer with 10 years of experience in developing, testing, and debugging software applications. Skilled in JavaScript, React, Node, and Python. Proven track record of successful development and implementation of software solutions for Google's search engine.
Experience
Software Engineer, Google, 2020-01-01 - 2020-01-01
• Developed, tested, and debugged software applications for Google's search engine
• Collaborated with other engineers to ensure the successful completion of projects
• Ensured that all software applications met industry standards and client requirements
Education
Harvard, 2020-01-01 - 2020-01-01
• Bachelor of Science in Computer Science
Skills
• JavaScript
• React
• Node
• Python
• Software Testing
• Debugging
Doesn’t look too bad! Let’s try doing some more stuff.
API: Rewrite based on tone
We have a good starting point for our resume. But let’s try to change something. Let’s change the tone. I added a few tones here:
Let’s try to feed the API with the original resume draft and ask it to rewrite to make me sound more X:
// server
const openAIResponse = await openai.createCompletion({
model: "text-davinci-003",
prompt: tonePrompt(payload.data),
temperature: 0.25,
max_tokens: 3000,
});
const tonePrompt = (data: { document: string; tone: Tone }) => {
const { document, tone } = data;
if (!document) throw new Error("Please provide a document to rewrite");
if (!tone) throw new Error("Please provide a tone to rewrite the document");
return `
${document}
--------------------
Rewrite the above text, keeping the format but change the tone to be more ${tone}.
`;
};
Response with tone = 'supportive'
John Doe
Software Engineer
Summary
I'm a highly experienced software engineer with a decade of experience in developing, testing, and debugging software applications. I'm proud to have developed successful software solutions for Google's search engine, and I'm skilled in JavaScript, React, Node, and Python. I'm committed to ensuring that all software applications meet industry standards and client requirements.
Experience
Software Engineer, Google, 2020-01-01 - 2020-01-01
• Developed, tested, and debugged software applications for Google's search engine
• Collaborated with other engineers to ensure projects were completed to the highest standard
• Ensured that all software applications met industry standards and client requirements
Education
Harvard, 2020-01-01 - 2020-01-01
• Earned a Bachelor of Science in Computer Science
Skills
• JavaScript
• React
• Node
• Python
• Software Testing
• Debugging
Notice the change in summary:
A highly experienced software engineer with 10 years of experience in developing, testing, and debugging software applications. Skilled in JavaScript, React, Node, and Python. Proven track record of successful development and implementation of software solutions for Google’s search engine.
to
I’m a highly experienced software engineer with a decade of experience in developing, testing, and debugging software applications. I’m proud to have developed successful software solutions for Google’s search engine, and I’m skilled in JavaScript, React, Node, and Python. I’m committed to ensuring that all software applications meet industry standards and client requirements.
Great! However, I see the usage of I
‘s in the summary, which I want to remove emphasis in the resume. Let’s try a different type of prompt below:
API: Rewrite based on action
There are some actions I would like the AI to do to my resume. From fixing spelling mistakes, reducing repetitive words, and replacing Me, My, and I.
Our prompt doesn't change much. It will look like this:
const actionPrompt = (data: { document: string; action: Action }) => {
const { document, action } = data;
if (!document) throw new Error("Please provide a document to rewrite");
if (!action)
throw new Error("Please provide an action to rewrite the document");
const { title, description } = formatActionDefinition(action);
if (!title || !description)
throw new Error("Action doesn't have a title or desc");
return `
${document}
--------------------
Rewrite the above text, but try to ${title}. ${description}. Please keep the format and all the sections.
`;
};
export const formatActionDefinition = (action: Action) => {
switch (action) {
case "reduceBuzzWords":
return {
title: "reduce buzz words",
description:
"Reduce the use of overused buzz words in your resume such as 'team player' or 'hard worker'.",
};
case "reducePassiveVoice":
return {
title: "reduce passive voice",
description:
"Passive voice is generally wordier and less direct than active voice. For example, 'A promotion was given to me after 3 months' is passive voice. 'I was given a promotion after 3 months' is active voice.",
};
case "reduceRepetitiveWords":
return {
title: "reduce repetitive words",
description: "Reduce the use of repetitive words in your resume.",
};
case "addActionWords":
return {
title: "add action words",
description:
"Action words such as 'created', 'managed', and 'led' can demonstrate your skills and experience in a more impactful way.",
};
case "removeMe":
return {
title: "remove Me, My and I",
description: 'You can remove pronouns such as "me", "my", and "I".',
};
case "highlightAchievements":
return {
title: "add achievements and metrics",
description:
"It is important to highlight your achievements more than your responsibilities. Add facts and numbers to your resume to demonstrate your impact, such as KPIs and revenue generated.",
};
...
Now our summary looks like this:
Experienced software engineer with over a decade of experience in creating, designing, and resolving software applications. Proud to have developed successful software solutions for Google’s search engine, well-versed in JavaScript, React, Node, and Python. Committed to ensuring that all software applications meet industry standards and customer requirements.
Noice!
Another very effective prompt is to add achievements and metrics
, returning
John Doe
Software Engineer
Summary
A highly motivated and experienced Software Engineer with 10 years of experience in developing and deploying software applications. Adept in leveraging the latest technologies to design, develop, and maintain software products. Possesses a Bachelor's degree in Computer Science from Harvard University and has intermediate level experience with JavaScript, React, Node, and Python. Demonstrated success in developing and deploying software applications that have increased user engagement by 20%, reduced development time by 30%, and improved customer satisfaction by 10%.
Experience
Software Engineer, Google
2020-01-01 – 2020-01-01
• Developed and maintained software applications for Google's search engine, resulting in a 20% increase in user engagement.
• Ensured the quality of the software by conducting rigorous tests and debugging, reducing development time by 30%.
• Optimized existing software applications by analyzing performance and making necessary improvements, resulting in a 10% improvement in customer satisfaction.
• Collaborated with other teams to identify and resolve software issues.
Education
Harvard University
2020-01-01 – 2020-01-01
Bachelor of Science in Computer Science
Skills
• JavaScript
• React
• Node
• Python
Next page we will explore how we use OpenAI API to analyze our resume. See ya!