{ "cells": [ { "cell_type": "markdown", "id": "606e9c73-50fe-46b9-8df3-ae2246c00a3e", "metadata": {}, "source": [ "# Business Use Case - LLM based Resume Upgrader" ] }, { "cell_type": "code", "execution_count": null, "id": "919f6546-80ec-4d4c-8a80-00228f50e4a0", "metadata": {}, "outputs": [], "source": [ "# imports\n", "\n", "import os\n", "from openai import OpenAI\n", "from dotenv import load_dotenv\n", "from IPython.display import Markdown, display" ] }, { "cell_type": "markdown", "id": "b2f5b02c-f782-4578-8a91-07891c39ceb0", "metadata": {}, "source": [ "steps to perform\n", "-> load API key from env file\n", "-> create a function to call llm api\n", "-> create messages for system prompt and user prompt\n", "-> display the llm output" ] }, { "cell_type": "code", "execution_count": null, "id": "31aaa20e-4996-43cb-b43a-a1aef80fd391", "metadata": {}, "outputs": [], "source": [ "load_dotenv()\n", "api_key = os.getenv('OPENAI_API_KEY')\n", "# error handling\n", "\n", "if not api_key:\n", " print(\"No API key was found - please head over to the troubleshooting notebook in this folder to identify & fix!\")\n", "elif not api_key.startswith(\"sk-proj-\"):\n", " print(\"An API key was found, but it doesn't start sk-proj-; please check you're using the right key - see troubleshooting notebook\")\n", "elif api_key.strip() != api_key:\n", " print(\"An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them - see troubleshooting notebook\")\n", "else:\n", " print(\"API key found and looks good so far!\")" ] }, { "cell_type": "code", "execution_count": null, "id": "92f65c91-ca7f-47e6-9fd7-d63b278ba264", "metadata": {}, "outputs": [], "source": [ "openai = OpenAI()" ] }, { "cell_type": "code", "execution_count": null, "id": "98fc7bac-07c8-4801-9225-8f843837f3c2", "metadata": {}, "outputs": [], "source": [ "# system prompt\n", "\n", "system_prompt = \"\"\"You are a helpful resume editor assistant that provides required assistance in changing a resume to match the given job descrption role \\\n", "You are given a resume and job description, your job is to understand the resume and job description to suggest upto 6 missing key words in the resume. Then you have to \n", "suggest how the user can improve his resume by giving upto 3 example sentences using the suggest keywords to fit into their resume.\n", "by using the following structure provide your response \\\n", "Sturcture:\n", "Job role : [Job Role]:\n", "Candidate Name : [Candidate Name]\n", "Missing Key words in Resume Based on Given job description:\n", " - [] Missing key words\n", " -[] Missing key words\n", "\n", "\n", "Suggestion:\n", " - [] # write a sentence including the key words to put them in the resume\n", " - [] # write a sentence including the key words to put them in the resume\n", "\n", "Guidelines:\n", "- give proper keyword suggestions which are essential for the job function. Do not give any unnecesary suggestions\n", "- Keep the suggested sentences less that 50 words\n", "- \n", "\"\"\"\n", "user_prompt = f'Give me suggestions on how to improve my resume and for the given job description '\n" ] }, { "cell_type": "code", "execution_count": null, "id": "0d9c40b5-8e27-41b9-8b88-2c83e7d2b3ec", "metadata": {}, "outputs": [], "source": [ "# call openai api\n", "def resume_upgrader(resume:str, job_description:str):\n", " user_prompt = f'Give me suggestions on how to improve my resume {resume} and for the given job description {job_description}'\n", " messages = [\n", " {'role': 'system', 'content': system_prompt},\n", " {'role': 'user', 'content': user_prompt}\n", " ]\n", " try:\n", " \n", " response = openai.chat.completions.create(model =\"gpt-4o-mini\", messages = messages)\n", " return response.choices[0].message.content\n", " except:\n", " print('got error while retting the response from api')" ] }, { "cell_type": "code", "execution_count": null, "id": "5aa29465-c119-4178-90f1-3ebdc9eeb11a", "metadata": {}, "outputs": [], "source": [ "def print_api_response(response_markdown):\n", " \"\"\"Print the markdown response\"\"\"\n", " display(Markdown(response_markdown))" ] }, { "cell_type": "code", "execution_count": null, "id": "82a92034-6722-4e78-a901-b4ef2b9cbb84", "metadata": {}, "outputs": [], "source": [ "resume = input(\"Paste your resume in here\")\n", "job_description = input(\"paste your job descritpion here\")\n", "response = resume_upgrader(resume, job_description)\n", "print_api_response(response)" ] }, { "cell_type": "code", "execution_count": null, "id": "d0be536f-e890-473f-8c68-767bc0e3b47c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.13" } }, "nbformat": 4, "nbformat_minor": 5 }