{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## [ChatGPT Prompt Engineering for Developers](https://learn.deeplearning.ai/chatgpt-prompt-eng/)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from auth import API_KEY\n", "import openai" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "openai.api_key = API_KEY" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "def get_completion(prompt, model='gpt-3.5-turbo'):\n", " messages = [{'role':'user', 'content': prompt}]\n", " response = openai.ChatCompletion.create(\n", " model=model,\n", " messages = messages,\n", " temperature = 0, # this is the degree of randomness of the model's output\n", " )\n", " return response.choices[0].message['content']" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "with open('cv.txt', 'rb') as txt_file:\n", " cv = txt_file.read()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "text = f\"\"\"{cv}\"\"\"" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "C.J. Duan is a Data Scientist with experience in media mix modeling, algorithmic trading, transportation scheduling, and Bayesian modeling, as well as a Ph.D in Industrial Management from Clemson University and publications in various journals and conference proceedings.\n" ] } ], "source": [ "prompt = f\"\"\"\n", "Summarize the candidate's experiences in the text delimited by triple backticks \\ \n", "into a single sentence using no more than 50 words.\n", "```{text}```\n", "\"\"\"\n", "response = get_completion(prompt)\n", "print(response)\n" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " 'first_name': 'C.J.',\n", " 'surname': 'DUAN'\n", "}\n" ] } ], "source": [ "prompt = f\"\"\"\n", "Find the candidate's name in the text delimited by triple backticks \\ \n", " and pit into a dictionary with keys including 'first_name', 'surname'.\n", "```{text}```\n", "\"\"\"\n", "response = get_completion(prompt)\n", "print(response)\n" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The ideal candidate for this job would be a Data Scientist with a Ph.D in Industrial Management and experience in Bayesian modeling, media mix modeling, algorithmic trading, transportation scheduling, and survival analysis. They should be proficient in Python, R, Pyro, PyTorch, and Stan. The candidate should have experience in completing freelance projects and working as a Chief Research Data Scientist. They should also have experience in teaching quantitative methods and have published research papers and conference proceedings. The candidate should have excellent communication skills and be able to work independently as well as in a team.\n" ] } ], "source": [ "prompt = f\"\"\"\n", "please write a job description based on the candidate's experiences in the text delimited by triple backticks \\ \n", "using no more than 100 words.\n", "```{text}```\n", "\"\"\"\n", "response = get_completion(prompt)\n", "print(response)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.10.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }