WEBVTT

00:00.440 --> 00:04.520
And here we are back in cursor and I've collapsed all the folders.

00:04.520 --> 00:09.880
But I'll go back into the foundations folder and to lab three.

00:10.360 --> 00:11.960
Lab three for week one.

00:11.960 --> 00:13.800
Day four, which is where we are.

00:14.440 --> 00:17.840
So this is where things get interesting.

00:18.400 --> 00:27.520
So I have a directory called me in in within foundations and within me I've put some files.

00:27.520 --> 00:29.400
One of them is called LinkedIn.

00:30.840 --> 00:37.080
And LinkedIn is uh I see it's not I don't think I can open it in here.

00:37.080 --> 00:39.600
I imagine this doesn't like being a PDF.

00:39.600 --> 00:40.080
Nope.

00:40.400 --> 00:42.960
So you you will have to take my word for it.

00:43.000 --> 00:48.640
What this is, is a PDF version of my LinkedIn profile.

00:48.640 --> 00:50.240
And you can just get that from within LinkedIn.

00:50.240 --> 00:56.320
You can go into LinkedIn and and click on on one of the dot dot dot ellipsis menus and download your

00:56.320 --> 00:57.400
profile as a PDF.

00:57.400 --> 00:58.480
And that's what I did.

00:58.560 --> 01:01.050
And I've put it right here as LinkedIn PDF.

01:01.570 --> 01:06.370
And I've also got a summary text which is just called summary txt.

01:06.610 --> 01:09.250
And it's just two sentences about me.

01:09.410 --> 01:11.690
And those two things are in me.

01:11.850 --> 01:17.010
And the to do for you as you do this lab is to replace these documents with something about you.

01:17.050 --> 01:22.690
The LinkedIn should be your LinkedIn PDF profile or a PDF of your resume or anything like that.

01:22.770 --> 01:27.690
The summary put some stuff about you and include some extra some fun stuff.

01:27.730 --> 01:35.170
A fun fact about you, something that you would like to people to know about you and all will become

01:35.170 --> 01:35.530
clear.

01:35.570 --> 01:38.050
Don't worry, it's not going to go anywhere without your control.

01:38.050 --> 01:40.890
But this will hopefully become clear very soon.

01:41.450 --> 01:42.210
All right.

01:42.370 --> 01:44.170
So if we go back to the lab.

01:44.530 --> 01:47.610
So as I said, we're not going to actually use tools just yet.

01:47.650 --> 01:48.890
Even though we've been talking about them.

01:48.930 --> 01:50.170
Tools is going to come tomorrow.

01:50.210 --> 01:52.290
We're going to lay the groundwork.

01:52.810 --> 01:53.330
Okay.

01:53.610 --> 01:59.340
So I'm now going to import a few packages load of you know well but an open eye, you know.

01:59.380 --> 02:06.580
Well, but PDF pypdf2 and gradio you might not know gradio prior students of mine will know well because

02:06.620 --> 02:08.540
you know that I am super.

02:08.540 --> 02:12.020
I adore Gradio, I am passionate about this, this this platform.

02:12.020 --> 02:17.700
I am a horrible front end engineer and gradio is something that can make beautiful front ends.

02:17.740 --> 02:19.660
Even for someone terrible like me.

02:19.700 --> 02:20.660
It's really great.

02:20.660 --> 02:24.900
It's a way to build data science user interfaces very easily indeed.

02:24.940 --> 02:27.620
We will do that, but I won't cover it in any detail.

02:28.180 --> 02:34.420
Pypdf2 is an example of a popular library for parsing PDF files, and if you want to know more about

02:34.420 --> 02:40.140
these, you can simply ask ChatGPT to write you a quick guide on them if you ever want to.

02:40.180 --> 02:45.940
To get the right kind of popular resource for doing something, you can just ask Claude or ChatGPT.

02:46.260 --> 02:46.940
If you want.

02:46.940 --> 02:47.620
You can, you can.

02:47.660 --> 02:50.500
The actual place they come from is called PyPI.

02:50.700 --> 02:52.980
And this is the the the package index.

02:52.980 --> 02:56.300
This is where open source Python packages live.

02:56.300 --> 03:01.590
And you can go there and search for different packages, look at their GitHub repos and find out more

03:01.590 --> 03:03.270
about them that way as well.

03:03.590 --> 03:03.950
All right.

03:03.950 --> 03:06.470
But I'm going to import these.

03:06.790 --> 03:09.670
And by the way I already set up here on the top right.

03:09.670 --> 03:14.230
I had uh, made sure that my virtual environment was set.

03:14.870 --> 03:16.430
It's taking a bit of time there.

03:16.430 --> 03:22.950
I guess it's a gradio that needs to load in a bunch of things, and it's done 14 seconds to to do all

03:22.990 --> 03:23.870
of those imports.

03:23.910 --> 03:25.190
I guess a lot was happening.

03:25.470 --> 03:25.910
All right.

03:25.910 --> 03:31.790
So now we load our env and we initialize the OpenAI client library.

03:32.190 --> 03:32.950
So look at this.

03:32.950 --> 03:40.230
I now simply create a PDF reader and I point it at the my LinkedIn PDF.

03:40.590 --> 03:44.310
And I read in the pages calling page extract text.

03:44.310 --> 03:46.710
And I just bring it all together.

03:46.990 --> 03:48.870
And that's as simple as that.

03:48.870 --> 03:55.590
So so now this LinkedIn variable, let's just print that LinkedIn variable so we can we can see it print

03:55.720 --> 04:01.840
LinkedIn and you'll see a whole bunch of stuff about me, and the output is truncated.

04:01.840 --> 04:03.200
So you're only seeing a little bit about me.

04:03.200 --> 04:06.240
But but there's there's more than you would need to know right there.

04:06.240 --> 04:09.680
But since you're surely already connected with me on LinkedIn, you know all this already.

04:10.000 --> 04:16.400
Um, then, uh, here I am going to load in the summary text about me.

04:16.600 --> 04:20.720
This is needed for PC users sometimes, and if you're not from.

04:20.720 --> 04:23.240
Yeah, I'm sure you are familiar with this, but it's covered in the guide.

04:23.240 --> 04:25.480
And then I'll set a variable called name to my name.

04:25.480 --> 04:27.120
And you should set that to be your name.

04:27.680 --> 04:28.480
All right.

04:28.520 --> 04:32.760
And now so one thing we didn't talk about before is system prompts and user prompts.

04:32.760 --> 04:34.280
And they are fairly commonplace now.

04:34.280 --> 04:40.120
So you probably know that we've always been just prompting with a single user prompt up to now.

04:40.120 --> 04:43.240
But you can actually specify two different prompts.

04:43.240 --> 04:50.600
The system prompt is intended to be more the overall instructions that sets the context for the task

04:50.600 --> 04:56.330
at hand, and the format and the way it should be responded to, and then the user prompt is the actual

04:56.330 --> 04:58.130
question coming from the user.

04:58.130 --> 05:02.530
And in this case, it will be handy for us to separate out these these two concerns.

05:02.690 --> 05:07.650
So for the system prompt I'm saying you are acting as name.

05:07.650 --> 05:10.130
So this will be me and it will be you.

05:10.410 --> 05:15.810
You're answering questions on that person's website, particularly questions related to their career,

05:15.850 --> 05:17.810
background, skills and experience.

05:18.050 --> 05:23.890
Your responsibility is to represent for interactions on the website as faithfully as possible.

05:24.330 --> 05:27.610
You're given a summary of the background in LinkedIn profile, blah blah blah blah blah.

05:28.090 --> 05:29.570
It be professional and engaging.

05:29.570 --> 05:33.010
So this is about setting the tone, which is a good thing to do in a system prompt.

05:33.010 --> 05:36.810
And then if you don't know the answer, say so is very good.

05:36.850 --> 05:39.250
Prompting context to give.

05:39.770 --> 05:40.410
Okay.

05:40.690 --> 05:45.050
So then I'm adding in the summary using that summary variable.

05:45.050 --> 05:47.490
And I'm also putting in the LinkedIn profile.

05:47.490 --> 05:51.370
And I'm using markdown tags to kind of show this as sort of headings.

05:51.930 --> 05:56.410
And then I end with with this context, please chat with the user.

05:56.450 --> 06:00.970
Always staying in character as as you.

06:01.570 --> 06:02.050
All right.

06:02.090 --> 06:02.970
Now the plot thickens.

06:02.970 --> 06:03.450
Now you know what?

06:03.450 --> 06:04.890
I'm the game I'm playing here.

06:04.890 --> 06:05.890
You know what we're doing.

06:06.010 --> 06:08.890
Let's run that and let's just print that.

06:08.890 --> 06:12.090
So we see what system prompt actually looks like.

06:13.010 --> 06:13.810
And here we go.

06:13.850 --> 06:17.330
You can see it's just true to form exactly as we were expecting.

06:17.810 --> 06:19.050
And it will have within it.

06:19.090 --> 06:28.090
Of course the stuff about me and the LinkedIn URL, LinkedIn PDF contents and so on and hopefully yours

06:28.090 --> 06:29.170
will have yours.

06:29.210 --> 06:31.130
And you should put in some print statements to check it.

06:31.170 --> 06:34.090
Make sure you're very comfortable with everything happening so far.

06:34.850 --> 06:41.370
So we're about to use Gradio to bring up a user interface that will allow us to chat based on an LLM

06:41.370 --> 06:43.570
that's armed with this system prompt.

06:43.770 --> 06:49.370
And the way you work with Gradio is you need to write a function which will be like a callback function

06:49.370 --> 06:54.460
that Gradio will call back to when it needs to to do some processing, when when a user has typed something

06:54.460 --> 06:54.900
in.

06:54.900 --> 07:00.500
And the style of this particular callback function is a style where you write a function called chat,

07:00.540 --> 07:07.100
which takes a message that the user is typing in, a message being sent, and the history of all prior

07:07.100 --> 07:10.340
messages, which comes in OpenAI's format.

07:10.620 --> 07:18.860
And what we need to do is call an LLM and return the the next the response from the LLM to go in the

07:18.860 --> 07:19.380
chat.

07:19.660 --> 07:23.620
So I'll let you look through this to convince yourself that what I'm doing is the right thing.

07:23.620 --> 07:28.580
But basically I build an OpenAI style list of dictionaries.

07:28.580 --> 07:33.660
I begin with the system prompt role system content and the system prompt.

07:33.660 --> 07:40.660
I add in the history from Gradio, and then I bung in this muses message that's just come in right now.

07:41.100 --> 07:51.310
I then call OpenAI Dot create for GPT four mini with exactly these messages, and I return the response

07:51.350 --> 07:53.950
choices zero message content.

07:54.150 --> 07:57.830
So this should all be stuff that's fairly familiar to you.

07:57.830 --> 08:00.590
And then using Gradio is beautifully simple.

08:00.750 --> 08:01.550
You just call.

08:01.550 --> 08:02.790
In this case we want a chat.

08:02.790 --> 08:04.750
And so you can call chat interface.

08:04.750 --> 08:08.910
We tell it the function that we've written so it knows it can call this as the callback.

08:09.190 --> 08:11.070
And we ask it to launch.

08:11.510 --> 08:14.990
And when I run that I get an interface like this.

08:15.350 --> 08:17.750
And I can say hi there.

08:18.710 --> 08:19.830
Hello, welcome to my website.

08:19.830 --> 08:21.070
How can I assist you?

08:21.070 --> 08:27.030
And so I can say something like, what is your greatest accomplishment?

08:27.870 --> 08:29.150
And we'll see what it says.

08:29.750 --> 08:36.310
I consider my greatest accomplishment to be the co-founding of Nebula, where we're leveraging generative

08:36.310 --> 08:40.470
AI and proprietary Llms to transform how people source and engage talent.

08:40.590 --> 08:41.670
Fantastic.

08:41.950 --> 08:45.070
And and it's also talking about the company I founded as well.

08:45.350 --> 08:49.120
So it's a very legit, very good answer.

08:49.120 --> 08:51.400
I think it's probably true, which is always a good thing.

08:51.600 --> 08:54.880
And so very nicely handled, let's say.

08:55.040 --> 09:03.160
What is a challenge that you encountered and needed to overcome?

09:03.440 --> 09:07.840
It's a hard kind of professional question that you might be asked in an interview.

09:08.480 --> 09:09.200
Okay.

09:09.400 --> 09:13.200
One of the significant challenges I faced during my transition from a successful career at JP Morgan

09:13.200 --> 09:16.440
to starting my own company, until this is all very true.

09:16.480 --> 09:19.360
I don't know how he got that from my from my LinkedIn profile.

09:19.360 --> 09:21.280
I guess it must be somewhere or something.

09:21.280 --> 09:23.120
That's that's kind of implied within it.

09:23.120 --> 09:25.640
But I mean, it happens to be spot on.

09:25.840 --> 09:28.160
So this is a very good answer.

09:28.160 --> 09:35.880
And so wonderfully, in the space of just a few minutes, we've built a chat interface and we've used

09:35.880 --> 09:42.920
resources to arm it with information about me so that it's able to act as me and be like a professional

09:42.960 --> 09:48.080
avatar, an alter ego for me in answering questions about my career.
