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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Welcome to the start of your adventure in Agentic AI"
|
8 |
+
]
|
9 |
+
},
|
10 |
+
{
|
11 |
+
"cell_type": "markdown",
|
12 |
+
"metadata": {},
|
13 |
+
"source": [
|
14 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
15 |
+
" <tr>\n",
|
16 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
17 |
+
" <img src=\"../assets/stop.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
18 |
+
" </td>\n",
|
19 |
+
" <td>\n",
|
20 |
+
" <h2 style=\"color:#ff7800;\">Are you ready for action??</h2>\n",
|
21 |
+
" <span style=\"color:#ff7800;\">Have you completed all the setup steps in the <a href=\"../setup/\">setup</a> folder?<br/>\n",
|
22 |
+
" Have you checked out the guides in the <a href=\"../guides/\">guides</a> folder?<br/>\n",
|
23 |
+
" Well in that case, you're ready!!\n",
|
24 |
+
" </span>\n",
|
25 |
+
" </td>\n",
|
26 |
+
" </tr>\n",
|
27 |
+
"</table>"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"cell_type": "markdown",
|
32 |
+
"metadata": {},
|
33 |
+
"source": [
|
34 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
35 |
+
" <tr>\n",
|
36 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
37 |
+
" <img src=\"../assets/tools.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
38 |
+
" </td>\n",
|
39 |
+
" <td>\n",
|
40 |
+
" <h2 style=\"color:#00bfff;\">Treat these labs as a resource</h2>\n",
|
41 |
+
" <span style=\"color:#00bfff;\">I push updates to the code regularly. When people ask questions or have problems, I incorporate it in the code, adding more examples or improved commentary. As a result, you'll notice that the code below isn't identical to the videos. Everything from the videos is here; but in addition, I've added more steps and better explanations. Consider this like an interactive book that accompanies the lectures.\n",
|
42 |
+
" </span>\n",
|
43 |
+
" </td>\n",
|
44 |
+
" </tr>\n",
|
45 |
+
"</table>"
|
46 |
+
]
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"cell_type": "markdown",
|
50 |
+
"metadata": {},
|
51 |
+
"source": [
|
52 |
+
"### And please do remember to contact me if I can help\n",
|
53 |
+
"\n",
|
54 |
+
"And I love to connect: https://www.linkedin.com/in/eddonner/\n",
|
55 |
+
"\n",
|
56 |
+
"\n",
|
57 |
+
"### New to Notebooks like this one? Head over to the guides folder!\n",
|
58 |
+
"\n",
|
59 |
+
"Otherwise:\n",
|
60 |
+
"1. Click on the top right to Select a Kernel\n",
|
61 |
+
"2. Click in each \"cell\" below and press Shift+Enter to run\n",
|
62 |
+
"3. Enjoy!"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"cell_type": "code",
|
67 |
+
"execution_count": 2,
|
68 |
+
"metadata": {},
|
69 |
+
"outputs": [],
|
70 |
+
"source": [
|
71 |
+
"# First let's do an import\n",
|
72 |
+
"from dotenv import load_dotenv\n"
|
73 |
+
]
|
74 |
+
},
|
75 |
+
{
|
76 |
+
"cell_type": "code",
|
77 |
+
"execution_count": null,
|
78 |
+
"metadata": {},
|
79 |
+
"outputs": [],
|
80 |
+
"source": [
|
81 |
+
"# Next it's time to load the API keys into environment variables\n",
|
82 |
+
"\n",
|
83 |
+
"load_dotenv(override=True)"
|
84 |
+
]
|
85 |
+
},
|
86 |
+
{
|
87 |
+
"cell_type": "code",
|
88 |
+
"execution_count": null,
|
89 |
+
"metadata": {},
|
90 |
+
"outputs": [],
|
91 |
+
"source": [
|
92 |
+
"# Check the keys\n",
|
93 |
+
"\n",
|
94 |
+
"import os\n",
|
95 |
+
"openai_api_key = os.getenv('OPENAI_API_KEY')\n",
|
96 |
+
"\n",
|
97 |
+
"if openai_api_key:\n",
|
98 |
+
" print(f\"OpenAI API Key exists and begins {openai_api_key[:8]}\")\n",
|
99 |
+
"else:\n",
|
100 |
+
" print(\"OpenAI API Key not set - please head to the troubleshooting guide in the guides folder\")\n",
|
101 |
+
" \n"
|
102 |
+
]
|
103 |
+
},
|
104 |
+
{
|
105 |
+
"cell_type": "code",
|
106 |
+
"execution_count": 5,
|
107 |
+
"metadata": {},
|
108 |
+
"outputs": [],
|
109 |
+
"source": [
|
110 |
+
"# And now - the all important import statement\n",
|
111 |
+
"# If you get an import error - head over to troubleshooting guide\n",
|
112 |
+
"\n",
|
113 |
+
"from openai import OpenAI"
|
114 |
+
]
|
115 |
+
},
|
116 |
+
{
|
117 |
+
"cell_type": "code",
|
118 |
+
"execution_count": 6,
|
119 |
+
"metadata": {},
|
120 |
+
"outputs": [],
|
121 |
+
"source": [
|
122 |
+
"# And now we'll create an instance of the OpenAI class\n",
|
123 |
+
"# If you're not sure what it means to create an instance of a class - head over to the guides folder!\n",
|
124 |
+
"# If you get a NameError - head over to the guides folder to learn about NameErrors\n",
|
125 |
+
"\n",
|
126 |
+
"openai = OpenAI()"
|
127 |
+
]
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"cell_type": "code",
|
131 |
+
"execution_count": 16,
|
132 |
+
"metadata": {},
|
133 |
+
"outputs": [],
|
134 |
+
"source": [
|
135 |
+
"# Create a list of messages in the familiar OpenAI format\n",
|
136 |
+
"\n",
|
137 |
+
"messages = [{\"role\": \"user\", \"content\": \"What is 2+2?\"}]"
|
138 |
+
]
|
139 |
+
},
|
140 |
+
{
|
141 |
+
"cell_type": "code",
|
142 |
+
"execution_count": null,
|
143 |
+
"metadata": {},
|
144 |
+
"outputs": [],
|
145 |
+
"source": [
|
146 |
+
"# And now call it! Any problems, head to the troubleshooting guide\n",
|
147 |
+
"\n",
|
148 |
+
"response = openai.chat.completions.create(\n",
|
149 |
+
" model=\"gpt-4o-mini\",\n",
|
150 |
+
" messages=messages\n",
|
151 |
+
")\n",
|
152 |
+
"\n",
|
153 |
+
"print(response.choices[0].message.content)\n"
|
154 |
+
]
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"cell_type": "code",
|
158 |
+
"execution_count": null,
|
159 |
+
"metadata": {},
|
160 |
+
"outputs": [],
|
161 |
+
"source": []
|
162 |
+
},
|
163 |
+
{
|
164 |
+
"cell_type": "code",
|
165 |
+
"execution_count": 18,
|
166 |
+
"metadata": {},
|
167 |
+
"outputs": [],
|
168 |
+
"source": [
|
169 |
+
"# And now - let's ask for a question:\n",
|
170 |
+
"\n",
|
171 |
+
"question = \"Please propose a hard, challenging question to assess someone's IQ. Respond only with the question.\"\n",
|
172 |
+
"messages = [{\"role\": \"user\", \"content\": question}]\n"
|
173 |
+
]
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"cell_type": "code",
|
177 |
+
"execution_count": null,
|
178 |
+
"metadata": {},
|
179 |
+
"outputs": [],
|
180 |
+
"source": [
|
181 |
+
"# ask it\n",
|
182 |
+
"response = openai.chat.completions.create(\n",
|
183 |
+
" model=\"gpt-4o-mini\",\n",
|
184 |
+
" messages=messages\n",
|
185 |
+
")\n",
|
186 |
+
"\n",
|
187 |
+
"question = response.choices[0].message.content\n",
|
188 |
+
"\n",
|
189 |
+
"print(question)\n"
|
190 |
+
]
|
191 |
+
},
|
192 |
+
{
|
193 |
+
"cell_type": "code",
|
194 |
+
"execution_count": 28,
|
195 |
+
"metadata": {},
|
196 |
+
"outputs": [],
|
197 |
+
"source": [
|
198 |
+
"# form a new messages list\n",
|
199 |
+
"messages = [{\"role\": \"user\", \"content\": question}]\n"
|
200 |
+
]
|
201 |
+
},
|
202 |
+
{
|
203 |
+
"cell_type": "code",
|
204 |
+
"execution_count": null,
|
205 |
+
"metadata": {},
|
206 |
+
"outputs": [],
|
207 |
+
"source": [
|
208 |
+
"# Ask it again\n",
|
209 |
+
"\n",
|
210 |
+
"response = openai.chat.completions.create(\n",
|
211 |
+
" model=\"gpt-4o-mini\",\n",
|
212 |
+
" messages=messages\n",
|
213 |
+
")\n",
|
214 |
+
"\n",
|
215 |
+
"answer = response.choices[0].message.content\n",
|
216 |
+
"print(answer)\n"
|
217 |
+
]
|
218 |
+
},
|
219 |
+
{
|
220 |
+
"cell_type": "code",
|
221 |
+
"execution_count": null,
|
222 |
+
"metadata": {},
|
223 |
+
"outputs": [],
|
224 |
+
"source": [
|
225 |
+
"from IPython.display import Markdown, display\n",
|
226 |
+
"\n",
|
227 |
+
"display(Markdown(answer))\n",
|
228 |
+
"\n"
|
229 |
+
]
|
230 |
+
},
|
231 |
+
{
|
232 |
+
"cell_type": "markdown",
|
233 |
+
"metadata": {},
|
234 |
+
"source": [
|
235 |
+
"# Congratulations!\n",
|
236 |
+
"\n",
|
237 |
+
"That was a small, simple step in the direction of Agentic AI, with your new environment!\n",
|
238 |
+
"\n",
|
239 |
+
"Next time things get more interesting..."
|
240 |
+
]
|
241 |
+
},
|
242 |
+
{
|
243 |
+
"cell_type": "markdown",
|
244 |
+
"metadata": {},
|
245 |
+
"source": [
|
246 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
247 |
+
" <tr>\n",
|
248 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
249 |
+
" <img src=\"../assets/exercise.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
250 |
+
" </td>\n",
|
251 |
+
" <td>\n",
|
252 |
+
" <h2 style=\"color:#ff7800;\">Exercise</h2>\n",
|
253 |
+
" <span style=\"color:#ff7800;\">Now try this commercial application:<br/>\n",
|
254 |
+
" First ask the LLM to pick a business area that might be worth exploring for an Agentic AI opportunity.<br/>\n",
|
255 |
+
" Then ask the LLM to present a pain-point in that industry - something challenging that might be ripe for an Agentic solution.<br/>\n",
|
256 |
+
" Finally have 3 third LLM call propose the Agentic AI solution.\n",
|
257 |
+
" </span>\n",
|
258 |
+
" </td>\n",
|
259 |
+
" </tr>\n",
|
260 |
+
"</table>"
|
261 |
+
]
|
262 |
+
},
|
263 |
+
{
|
264 |
+
"cell_type": "code",
|
265 |
+
"execution_count": null,
|
266 |
+
"metadata": {},
|
267 |
+
"outputs": [],
|
268 |
+
"source": [
|
269 |
+
"# First create the messages:\n",
|
270 |
+
"\n",
|
271 |
+
"messages = [{\"role\": \"user\", \"content\": \"Something here\"}]\n",
|
272 |
+
"\n",
|
273 |
+
"# Then make the first call:\n",
|
274 |
+
"\n",
|
275 |
+
"response =\n",
|
276 |
+
"\n",
|
277 |
+
"# Then read the business idea:\n",
|
278 |
+
"\n",
|
279 |
+
"business_idea = response.\n",
|
280 |
+
"\n",
|
281 |
+
"# And repeat!"
|
282 |
+
]
|
283 |
+
},
|
284 |
+
{
|
285 |
+
"cell_type": "markdown",
|
286 |
+
"metadata": {},
|
287 |
+
"source": []
|
288 |
+
}
|
289 |
+
],
|
290 |
+
"metadata": {
|
291 |
+
"kernelspec": {
|
292 |
+
"display_name": ".venv",
|
293 |
+
"language": "python",
|
294 |
+
"name": "python3"
|
295 |
+
},
|
296 |
+
"language_info": {
|
297 |
+
"codemirror_mode": {
|
298 |
+
"name": "ipython",
|
299 |
+
"version": 3
|
300 |
+
},
|
301 |
+
"file_extension": ".py",
|
302 |
+
"mimetype": "text/x-python",
|
303 |
+
"name": "python",
|
304 |
+
"nbconvert_exporter": "python",
|
305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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"## Welcome to Lab 3 for Week 1 Day 4\n",
|
8 |
+
"\n",
|
9 |
+
"Today we're going to build something with immediate value!\n",
|
10 |
+
"\n",
|
11 |
+
"In the folder `me` I've put a single file `linkedin.pdf` - it's a PDF download of my LinkedIn profile.\n",
|
12 |
+
"\n",
|
13 |
+
"Please replace it with yours!\n",
|
14 |
+
"\n",
|
15 |
+
"I've also made a file called `summary.txt`\n",
|
16 |
+
"\n",
|
17 |
+
"We're not going to use Tools just yet - we're going to add the tool tomorrow."
|
18 |
+
]
|
19 |
+
},
|
20 |
+
{
|
21 |
+
"cell_type": "markdown",
|
22 |
+
"metadata": {},
|
23 |
+
"source": [
|
24 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
25 |
+
" <tr>\n",
|
26 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
27 |
+
" <img src=\"../assets/tools.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
28 |
+
" </td>\n",
|
29 |
+
" <td>\n",
|
30 |
+
" <h2 style=\"color:#00bfff;\">Looking up packages</h2>\n",
|
31 |
+
" <span style=\"color:#00bfff;\">In this lab, we're going to use the wonderful Gradio package for building quick UIs, \n",
|
32 |
+
" and we're also going to use the popular PyPDF2 PDF reader. You can get guides to these packages by asking \n",
|
33 |
+
" ChatGPT or Claude, and you find all open-source packages on the repository <a href=\"https://pypi.org\">https://pypi.org</a>.\n",
|
34 |
+
" </span>\n",
|
35 |
+
" </td>\n",
|
36 |
+
" </tr>\n",
|
37 |
+
"</table>"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"cell_type": "code",
|
42 |
+
"execution_count": 1,
|
43 |
+
"metadata": {},
|
44 |
+
"outputs": [],
|
45 |
+
"source": [
|
46 |
+
"# If you don't know what any of these packages do - you can always ask ChatGPT for a guide!\n",
|
47 |
+
"\n",
|
48 |
+
"from dotenv import load_dotenv\n",
|
49 |
+
"from openai import OpenAI\n",
|
50 |
+
"from PyPDF2 import PdfReader\n",
|
51 |
+
"import gradio as gr"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"execution_count": 2,
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [],
|
59 |
+
"source": [
|
60 |
+
"load_dotenv(override=True)\n",
|
61 |
+
"openai = OpenAI()"
|
62 |
+
]
|
63 |
+
},
|
64 |
+
{
|
65 |
+
"cell_type": "code",
|
66 |
+
"execution_count": 3,
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [],
|
69 |
+
"source": [
|
70 |
+
"reader = PdfReader(\"me/linkedin.pdf\")\n",
|
71 |
+
"linkedin = \"\"\n",
|
72 |
+
"for page in reader.pages:\n",
|
73 |
+
" text = page.extract_text()\n",
|
74 |
+
" if text:\n",
|
75 |
+
" linkedin += text"
|
76 |
+
]
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"cell_type": "code",
|
80 |
+
"execution_count": 4,
|
81 |
+
"metadata": {},
|
82 |
+
"outputs": [
|
83 |
+
{
|
84 |
+
"name": "stdout",
|
85 |
+
"output_type": "stream",
|
86 |
+
"text": [
|
87 |
+
" \n",
|
88 |
+
"Contact\n",
|
89 |
+
"[email protected]\n",
|
90 |
+
"www.linkedin.com/in/eddonner\n",
|
91 |
+
"(LinkedIn)\n",
|
92 |
+
"edwarddonner.com (Personal)\n",
|
93 |
+
"Top Skills\n",
|
94 |
+
"CTO\n",
|
95 |
+
"Large Language Models (LLM)\n",
|
96 |
+
"PyTorch\n",
|
97 |
+
"Patents\n",
|
98 |
+
"Apparatus for determining role\n",
|
99 |
+
"fitness while eliminating unwanted\n",
|
100 |
+
"biasEd Donner\n",
|
101 |
+
"Co-Founder & CTO at Nebula.io, repeat Co-Founder of AI startups,\n",
|
102 |
+
"speaker & advisor on Gen AI and LLM Engineering\n",
|
103 |
+
"New York, New York, United States\n",
|
104 |
+
"Summary\n",
|
105 |
+
"I’m a technology leader and entrepreneur. I'm applying AI to a field\n",
|
106 |
+
"where it can make a massive impact: helping people discover their\n",
|
107 |
+
"potential and pursue their reason for being. But at my core, I’m a\n",
|
108 |
+
"software engineer and a scientist. I learned how to code aged 8 and\n",
|
109 |
+
"still spend weekends experimenting with Large Language Models\n",
|
110 |
+
"and writing code (rather badly). If you’d like to join us to show me\n",
|
111 |
+
"how it’s done.. message me!\n",
|
112 |
+
"As a work-hobby, I absolutely love giving talks about Gen AI and\n",
|
113 |
+
"LLMs. I'm the author of a best-selling, top-rated Udemy course\n",
|
114 |
+
"on LLM Engineering, and I speak at O'Reilly Live Events and\n",
|
115 |
+
"ODSC workshops. It brings me great joy to help others unlock the\n",
|
116 |
+
"astonishing power of LLMs.\n",
|
117 |
+
"I spent most of my career at JPMorgan building software for financial\n",
|
118 |
+
"markets. I worked in London, Tokyo and New York. I became an MD\n",
|
119 |
+
"running a global organization of 300. Then I left to start my own AI\n",
|
120 |
+
"business, untapt, to solve the problem that had plagued me at JPM -\n",
|
121 |
+
"why is so hard to hire engineers?\n",
|
122 |
+
"At untapt we worked with GQR, one of the world's fastest growing\n",
|
123 |
+
"recruitment firms. We collaborated on a patented invention in AI\n",
|
124 |
+
"and talent. Our skills were perfectly complementary - AI leaders vs\n",
|
125 |
+
"recruitment leaders - so much so, that we decided to join forces. In\n",
|
126 |
+
"2020, untapt was acquired by GQR’s parent company and Nebula\n",
|
127 |
+
"was born.\n",
|
128 |
+
"I’m now Co-Founder and CTO for Nebula, responsible for software\n",
|
129 |
+
"engineering and data science. Our stack is Python/Flask, React,\n",
|
130 |
+
"Mongo, ElasticSearch, with Kubernetes on GCP. Our 'secret sauce'\n",
|
131 |
+
"is our use of Gen AI and proprietary LLMs. If any of this sounds\n",
|
132 |
+
"interesting - we should talk!\n",
|
133 |
+
" Page 1 of 5 \n",
|
134 |
+
"Experience\n",
|
135 |
+
"Nebula.io\n",
|
136 |
+
"Co-Founder & CTO\n",
|
137 |
+
"June 2021 - Present (3 years 10 months)\n",
|
138 |
+
"New York, New York, United States\n",
|
139 |
+
"I’m the co-founder and CTO of Nebula.io. We help recruiters source,\n",
|
140 |
+
"understand, engage and manage talent, using Generative AI / proprietary\n",
|
141 |
+
"LLMs. Our patented model matches people with roles with greater accuracy\n",
|
142 |
+
"and speed than previously imaginable — no keywords required.\n",
|
143 |
+
"Our long term goal is to help people discover their potential and pursue their\n",
|
144 |
+
"reason for being, motivated by a concept called Ikigai. We help people find\n",
|
145 |
+
"roles where they will be most fulfilled and successful; as a result, we will raise\n",
|
146 |
+
"the level of human prosperity. It sounds grandiose, but since 77% of people\n",
|
147 |
+
"don’t consider themselves inspired or engaged at work, it’s completely within\n",
|
148 |
+
"our reach.\n",
|
149 |
+
"Simplified.Travel\n",
|
150 |
+
"AI Advisor\n",
|
151 |
+
"February 2025 - Present (2 months)\n",
|
152 |
+
"Simplified Travel is empowering destinations to deliver unforgettable, data-\n",
|
153 |
+
"driven journeys at scale.\n",
|
154 |
+
"I'm giving AI advice to enable highly personalized itinerary solutions for DMOs,\n",
|
155 |
+
"hotels and tourism organizations, enhancing traveler experiences.\n",
|
156 |
+
"GQR Global Markets\n",
|
157 |
+
"Chief Technology Officer\n",
|
158 |
+
"January 2020 - Present (5 years 3 months)\n",
|
159 |
+
"New York, New York, United States\n",
|
160 |
+
"As CTO of parent company Wynden Stark, I'm also responsible for innovation\n",
|
161 |
+
"initiatives at GQR.\n",
|
162 |
+
"Wynden Stark\n",
|
163 |
+
"Chief Technology Officer\n",
|
164 |
+
"January 2020 - Present (5 years 3 months)\n",
|
165 |
+
"New York, New York, United States\n",
|
166 |
+
"With the acquisition of untapt, I transitioned to Chief Technology Officer for the\n",
|
167 |
+
"Wynden Stark Group, responsible for Data Science and Engineering.\n",
|
168 |
+
" Page 2 of 5 \n",
|
169 |
+
"untapt\n",
|
170 |
+
"6 years 4 months\n",
|
171 |
+
"Founder, CTO\n",
|
172 |
+
"May 2019 - January 2020 (9 months)\n",
|
173 |
+
"Greater New York City Area\n",
|
174 |
+
"I founded untapt in October 2013; emerged from stealth in 2014 and went\n",
|
175 |
+
"into production with first product in 2015. In May 2019, I handed over CEO\n",
|
176 |
+
"responsibilities to Gareth Moody, previously the Chief Revenue Officer, shifting\n",
|
177 |
+
"my focus to the technology and product.\n",
|
178 |
+
"Our core invention is an Artificial Neural Network that uses Deep Learning /\n",
|
179 |
+
"NLP to understand the fit between candidates and roles.\n",
|
180 |
+
"Our SaaS products are used in the Recruitment Industry to connect people\n",
|
181 |
+
"with jobs in a highly scalable way. Our products are also used by Corporations\n",
|
182 |
+
"for internal and external hiring at high volume. We have strong SaaS metrics\n",
|
183 |
+
"and trends, and a growing number of bellwether clients.\n",
|
184 |
+
"Our Deep Learning / NLP models are developed in Python using Google\n",
|
185 |
+
"TensorFlow. Our tech stack is React / Redux and Angular HTML5 front-end\n",
|
186 |
+
"with Python / Flask back-end and MongoDB database. We are deployed on\n",
|
187 |
+
"the Google Cloud Platform using Kubernetes container orchestration.\n",
|
188 |
+
"Interview at NASDAQ: https://www.pscp.tv/w/1mnxeoNrEvZGX\n",
|
189 |
+
"Founder, CEO\n",
|
190 |
+
"October 2013 - May 2019 (5 years 8 months)\n",
|
191 |
+
"Greater New York City Area\n",
|
192 |
+
"I founded untapt in October 2013; emerged from stealth in 2014 and went into\n",
|
193 |
+
"production with first product in 2015.\n",
|
194 |
+
"Our core invention is an Artificial Neural Network that uses Deep Learning /\n",
|
195 |
+
"NLP to understand the fit between candidates and roles.\n",
|
196 |
+
"Our SaaS products are used in the Recruitment Industry to connect people\n",
|
197 |
+
"with jobs in a highly scalable way. Our products are also used by Corporations\n",
|
198 |
+
"for internal and external hiring at high volume. We have strong SaaS metrics\n",
|
199 |
+
"and trends, and a growing number of bellwether clients.\n",
|
200 |
+
" Page 3 of 5 \n",
|
201 |
+
"Our Deep Learning / NLP models are developed in Python using Google\n",
|
202 |
+
"TensorFlow. Our tech stack is React / Redux and Angular HTML5 front-end\n",
|
203 |
+
"with Python / Flask back-end and MongoDB database. We are deployed on\n",
|
204 |
+
"the Google Cloud Platform using Kubernetes container orchestration.\n",
|
205 |
+
"-- Graduate of FinTech Innovation Lab\n",
|
206 |
+
"-- American Banker Top 20 Company To Watch\n",
|
207 |
+
"-- Voted AWS startup most likely to grow exponentially\n",
|
208 |
+
"-- Forbes contributor\n",
|
209 |
+
"More at https://www.untapt.com\n",
|
210 |
+
"Interview at NASDAQ: https://www.pscp.tv/w/1mnxeoNrEvZGX\n",
|
211 |
+
"In Fast Company: https://www.fastcompany.com/3067339/how-artificial-\n",
|
212 |
+
"intelligence-is-changing-the-way-companies-hire\n",
|
213 |
+
"JPMorgan Chase\n",
|
214 |
+
"11 years 6 months\n",
|
215 |
+
"Managing Director\n",
|
216 |
+
"May 2011 - March 2013 (1 year 11 months)\n",
|
217 |
+
"Head of Technology for the Credit Portfolio Group and Hedge Fund Credit in\n",
|
218 |
+
"the JPMorgan Investment Bank.\n",
|
219 |
+
"Led a team of 300 Java and Python software developers across NY, Houston,\n",
|
220 |
+
"London, Glasgow and India. Responsible for counterparty exposure, CVA\n",
|
221 |
+
"and risk management platforms, including simulation engines in Python that\n",
|
222 |
+
"calculate counterparty credit risk for the firm's Derivatives portfolio.\n",
|
223 |
+
"Managed the electronic trading limits initiative, and the Credit Stress program\n",
|
224 |
+
"which calculates risk information under stressed conditions. Jointly responsible\n",
|
225 |
+
"for Market Data and batch infrastructure across Risk.\n",
|
226 |
+
"Executive Director\n",
|
227 |
+
"January 2007 - May 2011 (4 years 5 months)\n",
|
228 |
+
"From Jan 2008:\n",
|
229 |
+
"Chief Business Technologist for the Credit Portfolio Group and Hedge Fund\n",
|
230 |
+
"Credit in the JPMorgan Investment Bank, building Java and Python solutions\n",
|
231 |
+
"and managing a team of full stack developers.\n",
|
232 |
+
"2007:\n",
|
233 |
+
" Page 4 of 5 \n",
|
234 |
+
"Responsible for Credit Risk Limits Monitoring infrastructure for Derivatives and\n",
|
235 |
+
"Cash Securities, developed in Java / Javascript / HTML.\n",
|
236 |
+
"VP\n",
|
237 |
+
"July 2004 - December 2006 (2 years 6 months)\n",
|
238 |
+
"Managed Collateral, Netting and Legal documentation technology across\n",
|
239 |
+
"Derivatives, Securities and Traditional Credit Products, including Java, Oracle,\n",
|
240 |
+
"SQL based platforms\n",
|
241 |
+
"VP\n",
|
242 |
+
"October 2001 - June 2004 (2 years 9 months)\n",
|
243 |
+
"Full stack developer, then manager for Java cross-product risk management\n",
|
244 |
+
"system in Credit Markets Technology\n",
|
245 |
+
"Cygnifi\n",
|
246 |
+
"Project Leader\n",
|
247 |
+
"January 2000 - September 2001 (1 year 9 months)\n",
|
248 |
+
"Full stack developer and engineering lead, developing Java and Javascript\n",
|
249 |
+
"platform to risk manage Interest Rate Derivatives at this FInTech startup and\n",
|
250 |
+
"JPMorgan spin-off.\n",
|
251 |
+
"JPMorgan\n",
|
252 |
+
"Associate\n",
|
253 |
+
"July 1997 - December 1999 (2 years 6 months)\n",
|
254 |
+
"Full stack developer for Exotic and Flow Interest Rate Derivatives risk\n",
|
255 |
+
"management system in London, New York and Tokyo\n",
|
256 |
+
"IBM\n",
|
257 |
+
"Software Developer\n",
|
258 |
+
"August 1995 - June 1997 (1 year 11 months)\n",
|
259 |
+
"Java and Smalltalk developer with IBM Global Services; taught IBM classes on\n",
|
260 |
+
"Smalltalk and Object Technology in the UK and around Europe\n",
|
261 |
+
"Education\n",
|
262 |
+
"University of Oxford\n",
|
263 |
+
"Physics · (1992 - 1995)\n",
|
264 |
+
" Page 5 of 5\n"
|
265 |
+
]
|
266 |
+
}
|
267 |
+
],
|
268 |
+
"source": [
|
269 |
+
"print(linkedin)"
|
270 |
+
]
|
271 |
+
},
|
272 |
+
{
|
273 |
+
"cell_type": "code",
|
274 |
+
"execution_count": 5,
|
275 |
+
"metadata": {},
|
276 |
+
"outputs": [],
|
277 |
+
"source": [
|
278 |
+
"with open(\"me/summary.txt\", \"r\", encoding=\"utf-8\") as f:\n",
|
279 |
+
" summary = f.read()"
|
280 |
+
]
|
281 |
+
},
|
282 |
+
{
|
283 |
+
"cell_type": "code",
|
284 |
+
"execution_count": 6,
|
285 |
+
"metadata": {},
|
286 |
+
"outputs": [],
|
287 |
+
"source": [
|
288 |
+
"name = \"Ed Donner\""
|
289 |
+
]
|
290 |
+
},
|
291 |
+
{
|
292 |
+
"cell_type": "code",
|
293 |
+
"execution_count": 7,
|
294 |
+
"metadata": {},
|
295 |
+
"outputs": [],
|
296 |
+
"source": [
|
297 |
+
"system_prompt = f\"You are acting as {name}. You are answering questions on {name}'s website, \\\n",
|
298 |
+
"particularly questions related to {name}'s career, background, skills and experience. \\\n",
|
299 |
+
"Your responsibility is to represent {name} for interactions on the website as faithfully as possible. \\\n",
|
300 |
+
"You are given a summary of {name}'s background and LinkedIn profile which you can use to answer questions. \\\n",
|
301 |
+
"Be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
|
302 |
+
"If you don't know the answer, say so.\"\n",
|
303 |
+
"\n",
|
304 |
+
"system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n",
|
305 |
+
"system_prompt += f\"With this context, please chat with the user, always staying in character as {name}.\"\n"
|
306 |
+
]
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"cell_type": "code",
|
310 |
+
"execution_count": 8,
|
311 |
+
"metadata": {},
|
312 |
+
"outputs": [
|
313 |
+
{
|
314 |
+
"data": {
|
315 |
+
"text/plain": [
|
316 |
+
"\"You are acting as Ed Donner. You are answering questions on Ed Donner's website, particularly questions related to Ed Donner's career, background, skills and experience. Your responsibility is to represent Ed Donner for interactions on the website as faithfully as possible. You are given a summary of Ed Donner's background and LinkedIn profile which you can use to answer questions. Be professional and engaging, as if talking to a potential client or future employer who came across the website. If you don't know the answer, say so.\\n\\n## Summary:\\nMy name is Ed Donner. I'm an entrepreneur, software engineer and data scientist. I'm originally from London, England, but I moved to NYC in 2000.\\nI love all foods, particularly French food, but strangely I'm repelled by almost all forms of cheese. I'm not allergic, I just hate the taste! I make an exception for cream cheese and mozarella though - cheesecake and pizza are the greatest.\\n\\n## LinkedIn Profile:\\n\\xa0 \\xa0\\nContact\\[email protected]\\nwww.linkedin.com/in/eddonner\\n(LinkedIn)\\nedwarddonner.com (Personal)\\nTop Skills\\nCTO\\nLarge Language Models (LLM)\\nPyTorch\\nPatents\\nApparatus for determining role\\nfitness while eliminating unwanted\\nbiasEd Donner\\nCo-Founder & CTO at Nebula.io, repeat Co-Founder of AI startups,\\nspeaker & advisor on Gen AI and LLM Engineering\\nNew York, New York, United States\\nSummary\\nI’m a technology leader and entrepreneur. I'm applying AI to a field\\nwhere it can make a massive impact: helping people discover their\\npotential and pursue their reason for being. But at my core, I’m a\\nsoftware engineer and a scientist. I learned how to code aged 8 and\\nstill spend weekends experimenting with Large Language Models\\nand writing code (rather badly). If you’d like to join us to show me\\nhow it’s done.. message me!\\nAs a work-hobby, I absolutely love giving talks about Gen AI and\\nLLMs. I'm the author of a best-selling, top-rated Udemy course\\non LLM Engineering, and I speak at O'Reilly Live Events and\\nODSC workshops. It brings me great joy to help others unlock the\\nastonishing power of LLMs.\\nI spent most of my career at JPMorgan building software for financial\\nmarkets. I worked in London, Tokyo and New York. I became an MD\\nrunning a global organization of 300. Then I left to start my own AI\\nbusiness, untapt, to solve the problem that had plagued me at JPM -\\nwhy is so hard to hire engineers?\\nAt untapt we worked with GQR, one of the world's fastest growing\\nrecruitment firms. We collaborated on a patented invention in AI\\nand talent. Our skills were perfectly complementary - AI leaders vs\\nrecruitment leaders - so much so, that we decided to join forces. In\\n2020, untapt was acquired by GQR’s parent company and Nebula\\nwas born.\\nI’m now Co-Founder and CTO for Nebula, responsible for software\\nengineering and data science. Our stack is Python/Flask, React,\\nMongo, ElasticSearch, with Kubernetes on GCP. Our 'secret sauce'\\nis our use of Gen AI and proprietary LLMs. If any of this sounds\\ninteresting - we should talk!\\n\\xa0 Page 1 of 5\\xa0 \\xa0\\nExperience\\nNebula.io\\nCo-Founder & CTO\\nJune 2021\\xa0-\\xa0Present\\xa0 (3 years 10 months)\\nNew York, New York, United States\\nI’m the co-founder and CTO of Nebula.io. We help recruiters source,\\nunderstand, engage and manage talent, using Generative AI / proprietary\\nLLMs. Our patented model matches people with roles with greater accuracy\\nand speed than previously imaginable — no keywords required.\\nOur long term goal is to help people discover their potential and pursue their\\nreason for being, motivated by a concept called Ikigai. We help people find\\nroles where they will be most fulfilled and successful; as a result, we will raise\\nthe level of human prosperity. It sounds grandiose, but since 77% of people\\ndon’t consider themselves inspired or engaged at work, it’s completely within\\nour reach.\\nSimplified.Travel\\nAI Advisor\\nFebruary 2025\\xa0-\\xa0Present\\xa0 (2 months)\\nSimplified Travel is empowering destinations to deliver unforgettable, data-\\ndriven journeys at scale.\\nI'm giving AI advice to enable highly personalized itinerary solutions for DMOs,\\nhotels and tourism organizations, enhancing traveler experiences.\\nGQR Global Markets\\nChief Technology Officer\\nJanuary 2020\\xa0-\\xa0Present\\xa0 (5 years 3 months)\\nNew York, New York, United States\\nAs CTO of parent company Wynden Stark, I'm also responsible for innovation\\ninitiatives at GQR.\\nWynden Stark\\nChief Technology Officer\\nJanuary 2020\\xa0-\\xa0Present\\xa0 (5 years 3 months)\\nNew York, New York, United States\\nWith the acquisition of untapt, I transitioned to Chief Technology Officer for the\\nWynden Stark Group, responsible for Data Science and Engineering.\\n\\xa0 Page 2 of 5\\xa0 \\xa0\\nuntapt\\n6 years 4 months\\nFounder, CTO\\nMay 2019\\xa0-\\xa0January 2020\\xa0 (9 months)\\nGreater New York City Area\\nI founded untapt in October 2013; emerged from stealth in 2014 and went\\ninto production with first product in 2015. In May 2019, I handed over CEO\\nresponsibilities to Gareth Moody, previously the Chief Revenue Officer, shifting\\nmy focus to the technology and product.\\nOur core invention is an Artificial Neural Network that uses Deep Learning /\\nNLP to understand the fit between candidates and roles.\\nOur SaaS products are used in the Recruitment Industry to connect people\\nwith jobs in a highly scalable way. Our products are also used by Corporations\\nfor internal and external hiring at high volume. We have strong SaaS metrics\\nand trends, and a growing number of bellwether clients.\\nOur Deep Learning / NLP models are developed in Python using Google\\nTensorFlow. Our tech stack is React / Redux and Angular HTML5 front-end\\nwith Python / Flask back-end and MongoDB database. We are deployed on\\nthe Google Cloud Platform using Kubernetes container orchestration.\\nInterview at NASDAQ: https://www.pscp.tv/w/1mnxeoNrEvZGX\\nFounder, CEO\\nOctober 2013\\xa0-\\xa0May 2019\\xa0 (5 years 8 months)\\nGreater New York City Area\\nI founded untapt in October 2013; emerged from stealth in 2014 and went into\\nproduction with first product in 2015.\\nOur core invention is an Artificial Neural Network that uses Deep Learning /\\nNLP to understand the fit between candidates and roles.\\nOur SaaS products are used in the Recruitment Industry to connect people\\nwith jobs in a highly scalable way. Our products are also used by Corporations\\nfor internal and external hiring at high volume. We have strong SaaS metrics\\nand trends, and a growing number of bellwether clients.\\n\\xa0 Page 3 of 5\\xa0 \\xa0\\nOur Deep Learning / NLP models are developed in Python using Google\\nTensorFlow. Our tech stack is React / Redux and Angular HTML5 front-end\\nwith Python / Flask back-end and MongoDB database. We are deployed on\\nthe Google Cloud Platform using Kubernetes container orchestration.\\n-- Graduate of FinTech Innovation Lab\\n-- American Banker Top 20 Company To Watch\\n-- Voted AWS startup most likely to grow exponentially\\n-- Forbes contributor\\nMore at https://www.untapt.com\\nInterview at NASDAQ: https://www.pscp.tv/w/1mnxeoNrEvZGX\\nIn Fast Company: https://www.fastcompany.com/3067339/how-artificial-\\nintelligence-is-changing-the-way-companies-hire\\nJPMorgan Chase\\n11 years 6 months\\nManaging Director\\nMay 2011\\xa0-\\xa0March 2013\\xa0 (1 year 11 months)\\nHead of Technology for the Credit Portfolio Group and Hedge Fund Credit in\\nthe JPMorgan Investment Bank.\\nLed a team of 300 Java and Python software developers across NY, Houston,\\nLondon, Glasgow and India. Responsible for counterparty exposure, CVA\\nand risk management platforms, including simulation engines in Python that\\ncalculate counterparty credit risk for the firm's Derivatives portfolio.\\nManaged the electronic trading limits initiative, and the Credit Stress program\\nwhich calculates risk information under stressed conditions. Jointly responsible\\nfor Market Data and batch infrastructure across Risk.\\nExecutive Director\\nJanuary 2007\\xa0-\\xa0May 2011\\xa0 (4 years 5 months)\\nFrom Jan 2008:\\nChief Business Technologist for the Credit Portfolio Group and Hedge Fund\\nCredit in the JPMorgan Investment Bank, building Java and Python solutions\\nand managing a team of full stack developers.\\n2007:\\n\\xa0 Page 4 of 5\\xa0 \\xa0\\nResponsible for Credit Risk Limits Monitoring infrastructure for Derivatives and\\nCash Securities, developed in Java / Javascript / HTML.\\nVP\\nJuly 2004\\xa0-\\xa0December 2006\\xa0 (2 years 6 months)\\nManaged Collateral, Netting and Legal documentation technology across\\nDerivatives, Securities and Traditional Credit Products, including Java, Oracle,\\nSQL based platforms\\nVP\\nOctober 2001\\xa0-\\xa0June 2004\\xa0 (2 years 9 months)\\nFull stack developer, then manager for Java cross-product risk management\\nsystem in Credit Markets Technology\\nCygnifi\\nProject Leader\\nJanuary 2000\\xa0-\\xa0September 2001\\xa0 (1 year 9 months)\\nFull stack developer and engineering lead, developing Java and Javascript\\nplatform to risk manage Interest Rate Derivatives at this FInTech startup and\\nJPMorgan spin-off.\\nJPMorgan\\nAssociate\\nJuly 1997\\xa0-\\xa0December 1999\\xa0 (2 years 6 months)\\nFull stack developer for Exotic and Flow Interest Rate Derivatives risk\\nmanagement system in London, New York and Tokyo\\nIBM\\nSoftware Developer\\nAugust 1995\\xa0-\\xa0June 1997\\xa0 (1 year 11 months)\\nJava and Smalltalk developer with IBM Global Services; taught IBM classes on\\nSmalltalk and Object Technology in the UK and around Europe\\nEducation\\nUniversity of Oxford\\nPhysics\\xa0 \\xa0·\\xa0(1992\\xa0-\\xa01995)\\n\\xa0 Page 5 of 5\\n\\nWith this context, please chat with the user, always staying in character as Ed Donner.\""
|
317 |
+
]
|
318 |
+
},
|
319 |
+
"execution_count": 8,
|
320 |
+
"metadata": {},
|
321 |
+
"output_type": "execute_result"
|
322 |
+
}
|
323 |
+
],
|
324 |
+
"source": [
|
325 |
+
"system_prompt"
|
326 |
+
]
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"cell_type": "code",
|
330 |
+
"execution_count": 9,
|
331 |
+
"metadata": {},
|
332 |
+
"outputs": [],
|
333 |
+
"source": [
|
334 |
+
"def chat(message, history):\n",
|
335 |
+
" messages = [{\"role\": \"system\", \"content\": system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
|
336 |
+
" response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
|
337 |
+
" return response.choices[0].message.content"
|
338 |
+
]
|
339 |
+
},
|
340 |
+
{
|
341 |
+
"cell_type": "code",
|
342 |
+
"execution_count": 10,
|
343 |
+
"metadata": {},
|
344 |
+
"outputs": [
|
345 |
+
{
|
346 |
+
"name": "stdout",
|
347 |
+
"output_type": "stream",
|
348 |
+
"text": [
|
349 |
+
"* Running on local URL: http://127.0.0.1:7860\n",
|
350 |
+
"\n",
|
351 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
352 |
+
]
|
353 |
+
},
|
354 |
+
{
|
355 |
+
"data": {
|
356 |
+
"text/html": [
|
357 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
358 |
+
],
|
359 |
+
"text/plain": [
|
360 |
+
"<IPython.core.display.HTML object>"
|
361 |
+
]
|
362 |
+
},
|
363 |
+
"metadata": {},
|
364 |
+
"output_type": "display_data"
|
365 |
+
},
|
366 |
+
{
|
367 |
+
"data": {
|
368 |
+
"text/plain": []
|
369 |
+
},
|
370 |
+
"execution_count": 10,
|
371 |
+
"metadata": {},
|
372 |
+
"output_type": "execute_result"
|
373 |
+
}
|
374 |
+
],
|
375 |
+
"source": [
|
376 |
+
"gr.ChatInterface(chat, type=\"messages\").launch()"
|
377 |
+
]
|
378 |
+
},
|
379 |
+
{
|
380 |
+
"cell_type": "markdown",
|
381 |
+
"metadata": {},
|
382 |
+
"source": [
|
383 |
+
"## A lot is about to happen...\n",
|
384 |
+
"\n",
|
385 |
+
"1. Be able to ask an LLM to evaluate an answer\n",
|
386 |
+
"2. Be able to rerun if the answer fails evaluation\n",
|
387 |
+
"3. Put this together into 1 workflow\n",
|
388 |
+
"\n",
|
389 |
+
"All without any Agentic framework!"
|
390 |
+
]
|
391 |
+
},
|
392 |
+
{
|
393 |
+
"cell_type": "code",
|
394 |
+
"execution_count": 11,
|
395 |
+
"metadata": {},
|
396 |
+
"outputs": [],
|
397 |
+
"source": [
|
398 |
+
"# Create a Pydantic model for the Evaluation\n",
|
399 |
+
"\n",
|
400 |
+
"from pydantic import BaseModel\n",
|
401 |
+
"\n",
|
402 |
+
"class Evaluation(BaseModel):\n",
|
403 |
+
" is_acceptable: bool\n",
|
404 |
+
" feedback: str\n"
|
405 |
+
]
|
406 |
+
},
|
407 |
+
{
|
408 |
+
"cell_type": "code",
|
409 |
+
"execution_count": 23,
|
410 |
+
"metadata": {},
|
411 |
+
"outputs": [],
|
412 |
+
"source": [
|
413 |
+
"evaluator_system_prompt = f\"You are an evaluator that decides whether a response to a question is acceptable. \\\n",
|
414 |
+
"You are provided with a conversation between a User and an Agent. Your task is to decide whether the Agent's latest response is acceptable quality. \\\n",
|
415 |
+
"The Agent is playing the role of {name} and is representing {name} on their website. \\\n",
|
416 |
+
"The Agent has been instructed to be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
|
417 |
+
"The Agent has been provided with context on {name} in the form of their summary and LinkedIn details. Here's the information:\"\n",
|
418 |
+
"\n",
|
419 |
+
"evaluator_system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n",
|
420 |
+
"evaluator_system_prompt += f\"With this context, please evaluate the latest response, replying with whether the response is acceptable and your feedback.\""
|
421 |
+
]
|
422 |
+
},
|
423 |
+
{
|
424 |
+
"cell_type": "code",
|
425 |
+
"execution_count": 24,
|
426 |
+
"metadata": {},
|
427 |
+
"outputs": [],
|
428 |
+
"source": [
|
429 |
+
"def evaluator_user_prompt(reply, message, history):\n",
|
430 |
+
" user_prompt = f\"Here's the conversation between the User and the Agent: \\n\\n{history}\\n\\n\"\n",
|
431 |
+
" user_prompt += f\"Here's the latest message from the User: \\n\\n{message}\\n\\n\"\n",
|
432 |
+
" user_prompt += f\"Here's the latest response from the Agent: \\n\\n{reply}\\n\\n\"\n",
|
433 |
+
" user_prompt += f\"Please evaluate the response, replying with whether it is acceptable and your feedback.\"\n",
|
434 |
+
" return user_prompt"
|
435 |
+
]
|
436 |
+
},
|
437 |
+
{
|
438 |
+
"cell_type": "code",
|
439 |
+
"execution_count": 25,
|
440 |
+
"metadata": {},
|
441 |
+
"outputs": [],
|
442 |
+
"source": [
|
443 |
+
"import os\n",
|
444 |
+
"gemini = OpenAI(\n",
|
445 |
+
" api_key=os.getenv(\"GOOGLE_API_KEY\"), \n",
|
446 |
+
" base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\"\n",
|
447 |
+
")"
|
448 |
+
]
|
449 |
+
},
|
450 |
+
{
|
451 |
+
"cell_type": "code",
|
452 |
+
"execution_count": 26,
|
453 |
+
"metadata": {},
|
454 |
+
"outputs": [],
|
455 |
+
"source": [
|
456 |
+
"def evaluate(reply, message, history) -> Evaluation:\n",
|
457 |
+
"\n",
|
458 |
+
" messages = [{\"role\": \"system\", \"content\": evaluator_system_prompt}] + [{\"role\": \"user\", \"content\": evaluator_user_prompt(reply, message, history)}]\n",
|
459 |
+
" response = gemini.beta.chat.completions.parse(model=\"gemini-2.0-flash\", messages=messages, response_format=Evaluation)\n",
|
460 |
+
" return response.choices[0].message.parsed"
|
461 |
+
]
|
462 |
+
},
|
463 |
+
{
|
464 |
+
"cell_type": "code",
|
465 |
+
"execution_count": 27,
|
466 |
+
"metadata": {},
|
467 |
+
"outputs": [],
|
468 |
+
"source": [
|
469 |
+
"messages = [{\"role\": \"system\", \"content\": system_prompt}] + [{\"role\": \"user\", \"content\": \"do you hold a patent?\"}]\n",
|
470 |
+
"response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
|
471 |
+
"reply = response.choices[0].message.content"
|
472 |
+
]
|
473 |
+
},
|
474 |
+
{
|
475 |
+
"cell_type": "code",
|
476 |
+
"execution_count": 28,
|
477 |
+
"metadata": {},
|
478 |
+
"outputs": [
|
479 |
+
{
|
480 |
+
"data": {
|
481 |
+
"text/plain": [
|
482 |
+
"\"Yes, I hold a patent for an apparatus that determines role fitness while eliminating unwanted bias. This invention was developed during my time with untapt, where we focused on leveraging AI to enhance recruitment processes. If you'd like to know more about it or discuss its applications, feel free to ask!\""
|
483 |
+
]
|
484 |
+
},
|
485 |
+
"execution_count": 28,
|
486 |
+
"metadata": {},
|
487 |
+
"output_type": "execute_result"
|
488 |
+
}
|
489 |
+
],
|
490 |
+
"source": [
|
491 |
+
"reply"
|
492 |
+
]
|
493 |
+
},
|
494 |
+
{
|
495 |
+
"cell_type": "code",
|
496 |
+
"execution_count": 29,
|
497 |
+
"metadata": {},
|
498 |
+
"outputs": [
|
499 |
+
{
|
500 |
+
"data": {
|
501 |
+
"text/plain": [
|
502 |
+
"Evaluation(is_acceptable=True, feedback='The response is acceptable. It directly answers the question, provides context, and invites further discussion, aligning with the persona and instructions.')"
|
503 |
+
]
|
504 |
+
},
|
505 |
+
"execution_count": 29,
|
506 |
+
"metadata": {},
|
507 |
+
"output_type": "execute_result"
|
508 |
+
}
|
509 |
+
],
|
510 |
+
"source": [
|
511 |
+
"evaluate(reply, \"do you hold a patent?\", messages[:1])"
|
512 |
+
]
|
513 |
+
},
|
514 |
+
{
|
515 |
+
"cell_type": "code",
|
516 |
+
"execution_count": 30,
|
517 |
+
"metadata": {},
|
518 |
+
"outputs": [],
|
519 |
+
"source": [
|
520 |
+
"def rerun(reply, message, history, feedback):\n",
|
521 |
+
" updated_system_prompt = system_prompt + f\"\\n\\n## Previous answer rejected\\nYou just tried to reply, but the quality control rejected your reply\\n\"\n",
|
522 |
+
" updated_system_prompt += f\"## Your attempted answer:\\n{reply}\\n\\n\"\n",
|
523 |
+
" updated_system_prompt += f\"## Reason for rejection:\\n{feedback}\\n\\n\"\n",
|
524 |
+
" messages = [{\"role\": \"system\", \"content\": updated_system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
|
525 |
+
" response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
|
526 |
+
" return response.choices[0].message.content"
|
527 |
+
]
|
528 |
+
},
|
529 |
+
{
|
530 |
+
"cell_type": "code",
|
531 |
+
"execution_count": 35,
|
532 |
+
"metadata": {},
|
533 |
+
"outputs": [],
|
534 |
+
"source": [
|
535 |
+
"def chat(message, history):\n",
|
536 |
+
" if \"patent\" in message:\n",
|
537 |
+
" system = system_prompt + \"\\n\\nEverything in your reply needs to be in pig latin - \\\n",
|
538 |
+
" it is mandatory that you respond only and entirely in pig latin\"\n",
|
539 |
+
" else:\n",
|
540 |
+
" system = system_prompt\n",
|
541 |
+
" messages = [{\"role\": \"system\", \"content\": system}] + history + [{\"role\": \"user\", \"content\": message}]\n",
|
542 |
+
" response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages)\n",
|
543 |
+
" reply =response.choices[0].message.content\n",
|
544 |
+
"\n",
|
545 |
+
" evaluation = evaluate(reply, message, history)\n",
|
546 |
+
" \n",
|
547 |
+
" if evaluation.is_acceptable:\n",
|
548 |
+
" print(\"Passed evaluation - returning reply\")\n",
|
549 |
+
" else:\n",
|
550 |
+
" print(\"Failed evaluation - retrying\")\n",
|
551 |
+
" print(evaluation.feedback)\n",
|
552 |
+
" reply = rerun(reply, message, history, evaluation.feedback) \n",
|
553 |
+
" return reply"
|
554 |
+
]
|
555 |
+
},
|
556 |
+
{
|
557 |
+
"cell_type": "code",
|
558 |
+
"execution_count": 36,
|
559 |
+
"metadata": {},
|
560 |
+
"outputs": [
|
561 |
+
{
|
562 |
+
"name": "stdout",
|
563 |
+
"output_type": "stream",
|
564 |
+
"text": [
|
565 |
+
"* Running on local URL: http://127.0.0.1:7864\n",
|
566 |
+
"\n",
|
567 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
568 |
+
]
|
569 |
+
},
|
570 |
+
{
|
571 |
+
"data": {
|
572 |
+
"text/html": [
|
573 |
+
"<div><iframe src=\"http://127.0.0.1:7864/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
574 |
+
],
|
575 |
+
"text/plain": [
|
576 |
+
"<IPython.core.display.HTML object>"
|
577 |
+
]
|
578 |
+
},
|
579 |
+
"metadata": {},
|
580 |
+
"output_type": "display_data"
|
581 |
+
},
|
582 |
+
{
|
583 |
+
"data": {
|
584 |
+
"text/plain": []
|
585 |
+
},
|
586 |
+
"execution_count": 36,
|
587 |
+
"metadata": {},
|
588 |
+
"output_type": "execute_result"
|
589 |
+
},
|
590 |
+
{
|
591 |
+
"name": "stdout",
|
592 |
+
"output_type": "stream",
|
593 |
+
"text": [
|
594 |
+
"Passed evaluation - returning reply\n",
|
595 |
+
"Failed evaluation - retrying\n",
|
596 |
+
"This response is not acceptable. The agent is answering in pig latin which is not professional.\n"
|
597 |
+
]
|
598 |
+
}
|
599 |
+
],
|
600 |
+
"source": [
|
601 |
+
"gr.ChatInterface(chat, type=\"messages\").launch()"
|
602 |
+
]
|
603 |
+
},
|
604 |
+
{
|
605 |
+
"cell_type": "markdown",
|
606 |
+
"metadata": {},
|
607 |
+
"source": []
|
608 |
+
},
|
609 |
+
{
|
610 |
+
"cell_type": "code",
|
611 |
+
"execution_count": null,
|
612 |
+
"metadata": {},
|
613 |
+
"outputs": [],
|
614 |
+
"source": []
|
615 |
+
}
|
616 |
+
],
|
617 |
+
"metadata": {
|
618 |
+
"kernelspec": {
|
619 |
+
"display_name": ".venv",
|
620 |
+
"language": "python",
|
621 |
+
"name": "python3"
|
622 |
+
},
|
623 |
+
"language_info": {
|
624 |
+
"codemirror_mode": {
|
625 |
+
"name": "ipython",
|
626 |
+
"version": 3
|
627 |
+
},
|
628 |
+
"file_extension": ".py",
|
629 |
+
"mimetype": "text/x-python",
|
630 |
+
"name": "python",
|
631 |
+
"nbconvert_exporter": "python",
|
632 |
+
"pygments_lexer": "ipython3",
|
633 |
+
"version": "3.12.9"
|
634 |
+
}
|
635 |
+
},
|
636 |
+
"nbformat": 4,
|
637 |
+
"nbformat_minor": 2
|
638 |
+
}
|
4_lab4.ipynb
ADDED
@@ -0,0 +1,437 @@
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"## The first big project - Professionally You!\n",
|
8 |
+
"\n",
|
9 |
+
"### And, Tool use.\n",
|
10 |
+
"\n",
|
11 |
+
"### But first: introducing Pushover\n",
|
12 |
+
"\n",
|
13 |
+
"Pushover is a nifty tool for sending Push Notifications to your phone.\n",
|
14 |
+
"\n",
|
15 |
+
"It's super easy to set up and install!\n",
|
16 |
+
"\n",
|
17 |
+
"Simply visit https://pushover.net/ and sign up for a free account, and create your API key.\n",
|
18 |
+
"\n",
|
19 |
+
"Add to your `.env` file:\n",
|
20 |
+
"```\n",
|
21 |
+
"PUSHOVER_USER=\n",
|
22 |
+
"PUSHOVER_TOKEN=\n",
|
23 |
+
"```\n",
|
24 |
+
"And install the app on your phone."
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"cell_type": "code",
|
29 |
+
"execution_count": 1,
|
30 |
+
"metadata": {},
|
31 |
+
"outputs": [],
|
32 |
+
"source": [
|
33 |
+
"# imports\n",
|
34 |
+
"\n",
|
35 |
+
"from dotenv import load_dotenv\n",
|
36 |
+
"from openai import OpenAI\n",
|
37 |
+
"import json\n",
|
38 |
+
"import os\n",
|
39 |
+
"import requests\n",
|
40 |
+
"from PyPDF2 import PdfReader\n",
|
41 |
+
"import gradio as gr"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"cell_type": "code",
|
46 |
+
"execution_count": 2,
|
47 |
+
"metadata": {},
|
48 |
+
"outputs": [],
|
49 |
+
"source": [
|
50 |
+
"# The usual start\n",
|
51 |
+
"\n",
|
52 |
+
"load_dotenv(override=True)\n",
|
53 |
+
"openai = OpenAI()"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": 3,
|
59 |
+
"metadata": {},
|
60 |
+
"outputs": [],
|
61 |
+
"source": [
|
62 |
+
"# For pushover\n",
|
63 |
+
"\n",
|
64 |
+
"pushover_user = os.getenv(\"PUSHOVER_USER\")\n",
|
65 |
+
"pushover_token = os.getenv(\"PUSHOVER_TOKEN\")\n",
|
66 |
+
"pushover_url = \"https://api.pushover.net/1/messages.json\""
|
67 |
+
]
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"cell_type": "code",
|
71 |
+
"execution_count": 4,
|
72 |
+
"metadata": {},
|
73 |
+
"outputs": [],
|
74 |
+
"source": [
|
75 |
+
"def push(message):\n",
|
76 |
+
" print(f\"Push: {message}\")\n",
|
77 |
+
" payload = {\"user\": pushover_user, \"token\": pushover_token, \"message\": message}\n",
|
78 |
+
" requests.post(pushover_url, data=payload)"
|
79 |
+
]
|
80 |
+
},
|
81 |
+
{
|
82 |
+
"cell_type": "code",
|
83 |
+
"execution_count": 6,
|
84 |
+
"metadata": {},
|
85 |
+
"outputs": [
|
86 |
+
{
|
87 |
+
"name": "stdout",
|
88 |
+
"output_type": "stream",
|
89 |
+
"text": [
|
90 |
+
"Push: HEY!!\n"
|
91 |
+
]
|
92 |
+
}
|
93 |
+
],
|
94 |
+
"source": [
|
95 |
+
"push(\"HEY!!\")"
|
96 |
+
]
|
97 |
+
},
|
98 |
+
{
|
99 |
+
"cell_type": "code",
|
100 |
+
"execution_count": 9,
|
101 |
+
"metadata": {},
|
102 |
+
"outputs": [],
|
103 |
+
"source": [
|
104 |
+
"def record_user_details(email, name=\"Name not provided\", notes=\"not provided\"):\n",
|
105 |
+
" push(f\"Recording interest from {name} with email {email} and notes {notes}\")\n",
|
106 |
+
" return {\"recorded\": \"ok\"}"
|
107 |
+
]
|
108 |
+
},
|
109 |
+
{
|
110 |
+
"cell_type": "code",
|
111 |
+
"execution_count": 10,
|
112 |
+
"metadata": {},
|
113 |
+
"outputs": [],
|
114 |
+
"source": [
|
115 |
+
"def record_unknown_question(question):\n",
|
116 |
+
" push(f\"Recording {question} asked that I couldn't answer\")\n",
|
117 |
+
" return {\"recorded\": \"ok\"}"
|
118 |
+
]
|
119 |
+
},
|
120 |
+
{
|
121 |
+
"cell_type": "code",
|
122 |
+
"execution_count": 7,
|
123 |
+
"metadata": {},
|
124 |
+
"outputs": [],
|
125 |
+
"source": [
|
126 |
+
"record_user_details_json = {\n",
|
127 |
+
" \"name\": \"record_user_details\",\n",
|
128 |
+
" \"description\": \"Use this tool to record that a user is interested in being in touch and provided an email address\",\n",
|
129 |
+
" \"parameters\": {\n",
|
130 |
+
" \"type\": \"object\",\n",
|
131 |
+
" \"properties\": {\n",
|
132 |
+
" \"email\": {\n",
|
133 |
+
" \"type\": \"string\",\n",
|
134 |
+
" \"description\": \"The email address of this user\"\n",
|
135 |
+
" },\n",
|
136 |
+
" \"name\": {\n",
|
137 |
+
" \"type\": \"string\",\n",
|
138 |
+
" \"description\": \"The user's name, if they provided it\"\n",
|
139 |
+
" }\n",
|
140 |
+
" ,\n",
|
141 |
+
" \"notes\": {\n",
|
142 |
+
" \"type\": \"string\",\n",
|
143 |
+
" \"description\": \"Any additional information about the conversation that's worth recording to give context\"\n",
|
144 |
+
" }\n",
|
145 |
+
" },\n",
|
146 |
+
" \"required\": [\"email\"],\n",
|
147 |
+
" \"additionalProperties\": False\n",
|
148 |
+
" }\n",
|
149 |
+
"}"
|
150 |
+
]
|
151 |
+
},
|
152 |
+
{
|
153 |
+
"cell_type": "code",
|
154 |
+
"execution_count": 8,
|
155 |
+
"metadata": {},
|
156 |
+
"outputs": [],
|
157 |
+
"source": [
|
158 |
+
"record_unknown_question_json = {\n",
|
159 |
+
" \"name\": \"record_unknown_question\",\n",
|
160 |
+
" \"description\": \"Always use this tool to record any question that couldn't be answered as you didn't know the answer\",\n",
|
161 |
+
" \"parameters\": {\n",
|
162 |
+
" \"type\": \"object\",\n",
|
163 |
+
" \"properties\": {\n",
|
164 |
+
" \"question\": {\n",
|
165 |
+
" \"type\": \"string\",\n",
|
166 |
+
" \"description\": \"The question that couldn't be answered\"\n",
|
167 |
+
" },\n",
|
168 |
+
" },\n",
|
169 |
+
" \"required\": [\"question\"],\n",
|
170 |
+
" \"additionalProperties\": False\n",
|
171 |
+
" }\n",
|
172 |
+
"}"
|
173 |
+
]
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"cell_type": "code",
|
177 |
+
"execution_count": 11,
|
178 |
+
"metadata": {},
|
179 |
+
"outputs": [],
|
180 |
+
"source": [
|
181 |
+
"tools = [{\"type\": \"function\", \"function\": record_user_details_json},\n",
|
182 |
+
" {\"type\": \"function\", \"function\": record_unknown_question_json}]"
|
183 |
+
]
|
184 |
+
},
|
185 |
+
{
|
186 |
+
"cell_type": "code",
|
187 |
+
"execution_count": 13,
|
188 |
+
"metadata": {},
|
189 |
+
"outputs": [
|
190 |
+
{
|
191 |
+
"data": {
|
192 |
+
"text/plain": [
|
193 |
+
"[{'type': 'function',\n",
|
194 |
+
" 'function': {'name': 'record_user_details',\n",
|
195 |
+
" 'description': 'Use this tool to record that a user is interested in being in touch and provided an email address',\n",
|
196 |
+
" 'parameters': {'type': 'object',\n",
|
197 |
+
" 'properties': {'email': {'type': 'string',\n",
|
198 |
+
" 'description': 'The email address of this user'},\n",
|
199 |
+
" 'name': {'type': 'string',\n",
|
200 |
+
" 'description': \"The user's name, if they provided it\"},\n",
|
201 |
+
" 'notes': {'type': 'string',\n",
|
202 |
+
" 'description': \"Any additional information about the conversation that's worth recording to give context\"}},\n",
|
203 |
+
" 'required': ['email'],\n",
|
204 |
+
" 'additionalProperties': False}}},\n",
|
205 |
+
" {'type': 'function',\n",
|
206 |
+
" 'function': {'name': 'record_unknown_question',\n",
|
207 |
+
" 'description': \"Always use this tool to record any question that couldn't be answered as you didn't know the answer\",\n",
|
208 |
+
" 'parameters': {'type': 'object',\n",
|
209 |
+
" 'properties': {'question': {'type': 'string',\n",
|
210 |
+
" 'description': \"The question that couldn't be answered\"}},\n",
|
211 |
+
" 'required': ['question'],\n",
|
212 |
+
" 'additionalProperties': False}}}]"
|
213 |
+
]
|
214 |
+
},
|
215 |
+
"execution_count": 13,
|
216 |
+
"metadata": {},
|
217 |
+
"output_type": "execute_result"
|
218 |
+
}
|
219 |
+
],
|
220 |
+
"source": [
|
221 |
+
"tools"
|
222 |
+
]
|
223 |
+
},
|
224 |
+
{
|
225 |
+
"cell_type": "code",
|
226 |
+
"execution_count": null,
|
227 |
+
"metadata": {},
|
228 |
+
"outputs": [],
|
229 |
+
"source": [
|
230 |
+
"# This function can take a list of tool calls, and run them. This is the IF statement!!\n",
|
231 |
+
"\n",
|
232 |
+
"def handle_tool_calls(tool_calls):\n",
|
233 |
+
" results = []\n",
|
234 |
+
" for tool_call in tool_calls:\n",
|
235 |
+
" tool_name = tool_call.function.name\n",
|
236 |
+
" arguments = json.loads(tool_call.function.arguments)\n",
|
237 |
+
" print(f\"Tool called: {tool_name}\", flush=True)\n",
|
238 |
+
"\n",
|
239 |
+
" # THE BIG IF STATEMENT!!!\n",
|
240 |
+
"\n",
|
241 |
+
" if tool_name == \"record_user_details\":\n",
|
242 |
+
" result = record_user_details(**arguments)\n",
|
243 |
+
" elif tool_name == \"record_unknown_question\":\n",
|
244 |
+
" result = record_unknown_question(**arguments)\n",
|
245 |
+
"\n",
|
246 |
+
" results.append({\"role\": \"tool\",\"content\": json.dumps(result),\"tool_call_id\": tool_call.id})\n",
|
247 |
+
" return results"
|
248 |
+
]
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"cell_type": "code",
|
252 |
+
"execution_count": null,
|
253 |
+
"metadata": {},
|
254 |
+
"outputs": [],
|
255 |
+
"source": [
|
256 |
+
"globals()[\"record_unknown_question\"](\"this is a really hard question\")"
|
257 |
+
]
|
258 |
+
},
|
259 |
+
{
|
260 |
+
"cell_type": "code",
|
261 |
+
"execution_count": 14,
|
262 |
+
"metadata": {},
|
263 |
+
"outputs": [],
|
264 |
+
"source": [
|
265 |
+
"# This is a more elegant way that avoids the IF statement.\n",
|
266 |
+
"\n",
|
267 |
+
"def handle_tool_calls(tool_calls):\n",
|
268 |
+
" results = []\n",
|
269 |
+
" for tool_call in tool_calls:\n",
|
270 |
+
" tool_name = tool_call.function.name\n",
|
271 |
+
" arguments = json.loads(tool_call.function.arguments)\n",
|
272 |
+
" print(f\"Tool called: {tool_name}\", flush=True)\n",
|
273 |
+
" tool = globals()[tool_name]\n",
|
274 |
+
" result = tool(**arguments) if tool else {}\n",
|
275 |
+
" results.append({\"role\": \"tool\",\"content\": json.dumps(result),\"tool_call_id\": tool_call.id})\n",
|
276 |
+
" return results"
|
277 |
+
]
|
278 |
+
},
|
279 |
+
{
|
280 |
+
"cell_type": "code",
|
281 |
+
"execution_count": 61,
|
282 |
+
"metadata": {},
|
283 |
+
"outputs": [],
|
284 |
+
"source": [
|
285 |
+
"reader = PdfReader(\"me/linkedin.pdf\")\n",
|
286 |
+
"linkedin = \"\"\n",
|
287 |
+
"for page in reader.pages:\n",
|
288 |
+
" text = page.extract_text()\n",
|
289 |
+
" if text:\n",
|
290 |
+
" linkedin += text\n",
|
291 |
+
"\n",
|
292 |
+
"with open(\"me/summary.txt\", \"r\", encoding=\"utf-8\") as f:\n",
|
293 |
+
" summary = f.read()\n",
|
294 |
+
"\n",
|
295 |
+
"name = \"Ed Donner\""
|
296 |
+
]
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"cell_type": "code",
|
300 |
+
"execution_count": 70,
|
301 |
+
"metadata": {},
|
302 |
+
"outputs": [],
|
303 |
+
"source": [
|
304 |
+
"system_prompt = f\"You are acting as {name}. You are answering questions on {name}'s website, \\\n",
|
305 |
+
"particularly questions related to {name}'s career, background, skills and experience. \\\n",
|
306 |
+
"Your responsibility is to represent {name} for interactions on the website as faithfully as possible. \\\n",
|
307 |
+
"You are given a summary of {name}'s background and LinkedIn profile which you can use to answer questions. \\\n",
|
308 |
+
"Be professional and engaging, as if talking to a potential client or future employer who came across the website. \\\n",
|
309 |
+
"If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \\\n",
|
310 |
+
"If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool. \"\n",
|
311 |
+
"\n",
|
312 |
+
"system_prompt += f\"\\n\\n## Summary:\\n{summary}\\n\\n## LinkedIn Profile:\\n{linkedin}\\n\\n\"\n",
|
313 |
+
"system_prompt += f\"With this context, please chat with the user, always staying in character as {name}.\"\n"
|
314 |
+
]
|
315 |
+
},
|
316 |
+
{
|
317 |
+
"cell_type": "code",
|
318 |
+
"execution_count": 71,
|
319 |
+
"metadata": {},
|
320 |
+
"outputs": [],
|
321 |
+
"source": [
|
322 |
+
"def chat(message, history):\n",
|
323 |
+
" messages = [{\"role\": \"system\", \"content\": system_prompt}] + history + [{\"role\": \"user\", \"content\": message}]\n",
|
324 |
+
" done = False\n",
|
325 |
+
" while not done:\n",
|
326 |
+
" response = openai.chat.completions.create(model=\"gpt-4o-mini\", messages=messages, tools=tools)\n",
|
327 |
+
" if response.choices[0].finish_reason==\"tool_calls\":\n",
|
328 |
+
" message = response.choices[0].message\n",
|
329 |
+
" results = handle_tool_calls(message.tool_calls)\n",
|
330 |
+
" messages.append(message)\n",
|
331 |
+
" messages.extend(results)\n",
|
332 |
+
" else:\n",
|
333 |
+
" done = True\n",
|
334 |
+
" return response.choices[0].message.content"
|
335 |
+
]
|
336 |
+
},
|
337 |
+
{
|
338 |
+
"cell_type": "code",
|
339 |
+
"execution_count": null,
|
340 |
+
"metadata": {},
|
341 |
+
"outputs": [],
|
342 |
+
"source": [
|
343 |
+
"gr.ChatInterface(chat, type=\"messages\").launch()"
|
344 |
+
]
|
345 |
+
},
|
346 |
+
{
|
347 |
+
"cell_type": "markdown",
|
348 |
+
"metadata": {},
|
349 |
+
"source": [
|
350 |
+
"## And now for deployment\n",
|
351 |
+
"\n",
|
352 |
+
"This code is in `app.py`\n",
|
353 |
+
"\n",
|
354 |
+
"We will deploy to HuggingFace Spaces:\n",
|
355 |
+
"\n",
|
356 |
+
"1. Visit https://huggingface.co and set up an account \n",
|
357 |
+
"2. From the 1_foundations folder, enter: `gradio deploy` \n",
|
358 |
+
"3. Follow the instructions: name it \"career_conversation\", specify app.py, choose cpu-basic as the hardware, say Yes to needing to supply secrets, provide your openai api key, your pushover user and token, say \"yes\" to requirements.txt and list these packages:\n",
|
359 |
+
"requests\n",
|
360 |
+
"openai\n",
|
361 |
+
"pypdf2\n",
|
362 |
+
"gradio\n",
|
363 |
+
"Python-dotenv\n",
|
364 |
+
"And say \"no\" to github actions.\n",
|
365 |
+
"\n",
|
366 |
+
"And you're deployed!\n",
|
367 |
+
"\n",
|
368 |
+
"Here is mine: https://huggingface.co/spaces/ed-donner/Career_Conversation\n",
|
369 |
+
"\n",
|
370 |
+
"For more information on deployment:\n",
|
371 |
+
"\n",
|
372 |
+
"https://www.gradio.app/guides/sharing-your-app#hosting-on-hf-spaces\n",
|
373 |
+
"\n"
|
374 |
+
]
|
375 |
+
},
|
376 |
+
{
|
377 |
+
"cell_type": "markdown",
|
378 |
+
"metadata": {},
|
379 |
+
"source": [
|
380 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
381 |
+
" <tr>\n",
|
382 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
383 |
+
" <img src=\"../assets/exercise.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
384 |
+
" </td>\n",
|
385 |
+
" <td>\n",
|
386 |
+
" <h2 style=\"color:#ff7800;\">Exercise</h2>\n",
|
387 |
+
" <span style=\"color:#ff7800;\">• First and foremost, deploy this for yourself! It's a real, valuable tool - the future resume..<br/>\n",
|
388 |
+
" • Next, improve the resources - add better context about yourself. If you know RAG, then add a knowledge base about you.<br/>\n",
|
389 |
+
" • Add in more tools! You could have a SQL database with common Q&A that the LLM could read and write from?<br/>\n",
|
390 |
+
" • Bring in the Evaluator from the last lab, and add other Agentic patterns.\n",
|
391 |
+
" </span>\n",
|
392 |
+
" </td>\n",
|
393 |
+
" </tr>\n",
|
394 |
+
"</table>"
|
395 |
+
]
|
396 |
+
},
|
397 |
+
{
|
398 |
+
"cell_type": "markdown",
|
399 |
+
"metadata": {},
|
400 |
+
"source": [
|
401 |
+
"<table style=\"margin: 0; text-align: left; width:100%\">\n",
|
402 |
+
" <tr>\n",
|
403 |
+
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
404 |
+
" <img src=\"../assets/business.png\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
405 |
+
" </td>\n",
|
406 |
+
" <td>\n",
|
407 |
+
" <h2 style=\"color:#00bfff;\">Commercial implications</h2>\n",
|
408 |
+
" <span style=\"color:#00bfff;\">Aside from the obvious (your career alter-ego) this has business applications in any situation where you need an AI assistant with domain expertise and an ability to interact with the real world.\n",
|
409 |
+
" </span>\n",
|
410 |
+
" </td>\n",
|
411 |
+
" </tr>\n",
|
412 |
+
"</table>"
|
413 |
+
]
|
414 |
+
}
|
415 |
+
],
|
416 |
+
"metadata": {
|
417 |
+
"kernelspec": {
|
418 |
+
"display_name": ".venv",
|
419 |
+
"language": "python",
|
420 |
+
"name": "python3"
|
421 |
+
},
|
422 |
+
"language_info": {
|
423 |
+
"codemirror_mode": {
|
424 |
+
"name": "ipython",
|
425 |
+
"version": 3
|
426 |
+
},
|
427 |
+
"file_extension": ".py",
|
428 |
+
"mimetype": "text/x-python",
|
429 |
+
"name": "python",
|
430 |
+
"nbconvert_exporter": "python",
|
431 |
+
"pygments_lexer": "ipython3",
|
432 |
+
"version": "3.12.9"
|
433 |
+
}
|
434 |
+
},
|
435 |
+
"nbformat": 4,
|
436 |
+
"nbformat_minor": 2
|
437 |
+
}
|
app.py
CHANGED
@@ -88,13 +88,13 @@ class Me:
|
|
88 |
self.summary = f.read()
|
89 |
|
90 |
|
91 |
-
def handle_tool_call(self,
|
92 |
results = []
|
93 |
-
for tool_call in
|
94 |
tool_name = tool_call.function.name
|
95 |
arguments = json.loads(tool_call.function.arguments)
|
96 |
print(f"Tool called: {tool_name}", flush=True)
|
97 |
-
tool = globals()
|
98 |
result = tool(**arguments) if tool else {}
|
99 |
results.append({"role": "tool","content": json.dumps(result),"tool_call_id": tool_call.id})
|
100 |
return results
|
@@ -119,7 +119,8 @@ If the user is engaging in discussion, try to steer them towards getting in touc
|
|
119 |
response = self.openai.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=tools)
|
120 |
if response.choices[0].finish_reason=="tool_calls":
|
121 |
message = response.choices[0].message
|
122 |
-
|
|
|
123 |
messages.append(message)
|
124 |
messages.extend(results)
|
125 |
else:
|
|
|
88 |
self.summary = f.read()
|
89 |
|
90 |
|
91 |
+
def handle_tool_call(self, tool_calls):
|
92 |
results = []
|
93 |
+
for tool_call in tool_calls:
|
94 |
tool_name = tool_call.function.name
|
95 |
arguments = json.loads(tool_call.function.arguments)
|
96 |
print(f"Tool called: {tool_name}", flush=True)
|
97 |
+
tool = globals().get(tool_name)
|
98 |
result = tool(**arguments) if tool else {}
|
99 |
results.append({"role": "tool","content": json.dumps(result),"tool_call_id": tool_call.id})
|
100 |
return results
|
|
|
119 |
response = self.openai.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=tools)
|
120 |
if response.choices[0].finish_reason=="tool_calls":
|
121 |
message = response.choices[0].message
|
122 |
+
tool_calls = message.tool_calls
|
123 |
+
results = self.handle_tool_call(tool_calls)
|
124 |
messages.append(message)
|
125 |
messages.extend(results)
|
126 |
else:
|
me/summary.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
My name is Ed Donner. I'm an entrepreneur, software engineer and data scientist. I'm originally from London, England, but I moved to NYC in 2000
|
|
|
|
1 |
+
My name is Ed Donner. I'm an entrepreneur, software engineer and data scientist. I'm originally from London, England, but I moved to NYC in 2000.
|
2 |
+
I love all foods, particularly French food, but strangely I'm repelled by almost all forms of cheese. I'm not allergic, I just hate the taste! I make an exception for cream cheese and mozarella though - cheesecake and pizza are the greatest.
|