While they say time flies when you're having fun.
And that seems to be happening because we already have reached the last, last of the days of the first
week, day five and it's time to unveil our big project, which, as you know, is your own personal
career alter ego for your website.
Answering questions about your professional history.
And I want to say one more time that last time we talked about the different Agentic frameworks and
how there are simple ones and complex ones.
Everything we're doing this week is with no framework at all.
We are interacting directly with models, which is incredibly important because it gives you that foundational
knowledge about what's actually going on under the hood, so that when we start to build on all sorts
of clever frameworks that abstract us away, you have good insight into what's really going on behind
the scenes.
But that's the end of the intro.
It's now time to go straight to the lab, because for today, it's going to be a ton of coding.
Let's get to it.
And here we are back in cursor.
And we go back into the first week foundations.
And now we're on lab for the first big project.
Professionally.
You.
I'm calling it.
It's going to be your personal career alter ego, and it's going to include tool use.
As promised.
I know we covered it in the last lecture, but it's going to now make its appearance.
First, I want to introduce you to a nifty little tool called pushover, which people from my last course
will remember fondly.
It is a nice little tool, and I've had to.
I have to have my phone off silent because we're going to be using it.
So I do apologize if I get things like text messages and stuff, but but it's important, as you will
see.
Pushover is a cute tool that lets you send push notifications to your phone.
If you're used to using something like Twilio that lets you send text messages.
Twilio used to be very easy to use, but now there's so much regulation around SMS that it's actually
quite hard to get things together to send even yourself a text message.
Pushover is super simple, and it's free.
At least I think for the first month I'm now paying some tiny amount, but it's free for the first month,
so you've got plenty of time.
You simply go to pushover and it's super clear.
You set up an account on the top right, you get an API key and you actually get two.
You get like a user and a token, and you have to put that in your file so that it's going to be available
here.
And you also install an app on your phone called pushover, which I have sitting right there.
And the reason you do that, if I do run a few imports right here and now, I'm going to do the usual
load EMV, which is going to include my pushover user and token now, and I'm going to create the OpenAI
library.
All right.
So my pushover user is in that field.
My token is in that.
And this is the URL of the endpoint for sending push notification messages.
And so this function here push is all it takes.
Basically you're just you just do a request stop post to that URL to that endpoint.
And you pass in some data.
And that data has the user token.
The token token and the message itself that you want to push to your phone.
It's just the end of it.
Nothing.
I mean, this is this is how all things should be just super simple.
So I should be able to run this function here.
Hey.
And it should come up on my phone right now.
There you go.
I hope you heard that loud and clear.
I'll do it again.
There we go.
And I see.
Hey, twice.
And that is a cool way to be able to notify yourself of things through code without having to worry
about SMS regulations and things like that.
Okay, that's push over.
Please install it when when you have a moment because we're going to use it not just this time, but
we're going to use it in other projects as well.
It's a useful thing to be able to do.
Okay.
Now I'm going to introduce you to two innocent looking functions.
One of them is called record user details and the other is called record.
Unknown question.
And these are two tools that I'm going to want to equip our LM with so that it can do these things.
It's going to be able to record if a user wants to be in touch with us, and it's going to be able to
record if a user asks a question that it doesn't know how to answer.
And by record, what I mean is it's going to send a push notification to my phone so I know immediately
if someone does that.
And so it's going to say the that it's recording that someone, a person with this email and these notes
and it's going to return that the recorded.
So that's a useful thing to be able to do.
And if it gets a question it doesn't know it's going to push recording that a question was asked.
Why don't we make this a bit more descriptive that I couldn't answer.
Answer.
There we go.
So now it's nice and clear recording interest.
From there we go.
Okay, so the idea is we want to turn these into tools that are LM can use.
Now remember I told you that at the end of the day tool use is just JSON and if statements and that
is what you're going to see right now.
Here is some JSON.
There's quite long JSON.
It's quite there's quite verbose.
And one of the things that the agent frameworks do is they sort of do all of this for you automatically.
So you won't have to worry about this again, because a lot of this stuff is very boilerplate, a lot
of lot of standard JSON.
But this JSON right here record user details.
JSON is a blob of JSON that refers to this function.
It describes the capability of being able to call that function.
It gives it a name record user details.
It says why might you want to do that?
Use this tool to record that a user is interested in being in touch and provided an email address.
And then we specify the parameters.
There's one called email, one called name, one called notes.
Look here it is email name and notes.
And we give each one a description.
And we say that email is required and that there aren't additional properties.
So you may be wondering what this is about.
The thing to keep in mind is that this is the information that's going to be sent to OpenAI.
We're going to say to it, you have the ability to do this.
Tell me if you want me to run it for you, and I'll tell you the answer.
So that's that's what's going on here.
It's like a packaged way of describing what this function does in JSON format, so that the LLM can
decide in its response whether or not it wants to actually call this tool.
And then very similar for record unknown user question, we give it a name, the name of the function,
we give it a description.
And this is what the LLM will use to decide whether or not it's appropriate to use this tool.
And then we say that it has one property question which is a string, the question that couldn't be
answered.
And that is the end of that.
Let's run this and run this okay.
If I run everything, I didn't run the functions themselves.
It's always if you fail to run things, then you're going to get a name error later.
It's something to watch out for.
So always come back and make sure that you've run all of your cells.
Okay.
Final step for this is that we're going to put both of these blobs of JSON into a list of tools.
Type is function and the function is that function.
So now this blob of JSON is a big blob of JSON.
Let's have a look at it.
Print tools.
And you're going to see it's actually what happens if I just do it like this.
That might look better.
There we go.
It does look better.
This is what tools now is it is this big chunk of JSON boilerplate JSON, which describes the two functions
that we're providing with a name, a description, the parameters, and so on.
And this putting things in JSON is a language that llms are good at understanding because it's in lots
of their training data.
And so that's going to help us to be able to interact with OpenAI.