File size: 4,363 Bytes
19ed75c
 
 
 
 
 
 
 
 
 
 
 
ad15d6a
19ed75c
 
 
 
 
 
 
 
 
ad15d6a
19ed75c
 
 
 
 
 
 
 
ad15d6a
19ed75c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad15d6a
19ed75c
 
 
ad15d6a
 
19ed75c
 
 
 
ad15d6a
19ed75c
 
ad15d6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19ed75c
 
ad15d6a
 
19ed75c
ad15d6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19ed75c
 
 
 
ad15d6a
19ed75c
 
 
 
 
 
ad15d6a
19ed75c
 
 
 
ad15d6a
 
 
 
 
19ed75c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
 "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
}