WEBVTT

00:00.520 --> 00:02.040
Continuing with our business project.

00:02.040 --> 00:08.400
So this is a look at a Google Sheet I've set up to represent my stock portfolio.

00:08.680 --> 00:12.840
Uh, and the idea is that and I will of course share this sheet.

00:12.840 --> 00:16.160
You can recreate it if you wish, or you can just use one that's set up.

00:16.680 --> 00:21.440
It's going to be set up with, uh, it's got a bunch of stock tickers.

00:21.440 --> 00:22.280
Here they are.

00:22.320 --> 00:24.400
These are in fact in my portfolio.

00:24.440 --> 00:30.120
They are tickers that represent what's called ETFs, or they are sort of investments in a group of different

00:30.160 --> 00:30.920
shares.

00:31.120 --> 00:39.320
And each one of them, I've got some quantity of them and they represent some of them are 100% equities.

00:39.320 --> 00:41.160
They are all all stocks.

00:41.320 --> 00:49.120
Some of them are all bonds, all fixed income products, and some of them are a blend between the two.

00:49.160 --> 00:56.480
And this column C and D represents how much is is stocks, how much is equity and how much is fixed

00:56.480 --> 00:57.160
income.

00:57.360 --> 00:58.760
And that is the breakdown.

00:58.760 --> 01:04.520
And it's common particularly with retirement accounts, but with longer term savings and with many portfolios

01:04.520 --> 01:08.630
that you have this breakdown between between equity and fixed income.

01:08.630 --> 01:10.910
And it's common that you might want to rebalance it.

01:10.950 --> 01:16.750
And in fact, pay people to do this for you to take some cut of your money in return for rebalancing

01:16.750 --> 01:17.710
your portfolio.

01:17.710 --> 01:22.590
But there's no need, because an agent can do it for you, and it can do it for free.

01:22.910 --> 01:27.950
And so that's that's what we are building today, our own financial planner that is able to rebalance

01:27.950 --> 01:33.910
the portfolio by making trades to to set your your balance of equity and fixed income to what you want

01:33.950 --> 01:36.990
or really to do any kind of rebalancing that you might wish.

01:37.310 --> 01:37.990
All right.

01:37.990 --> 01:42.710
So in this spreadsheet, there are a few sets of things that we're going to want our agents to fill

01:42.710 --> 01:43.110
in.

01:43.110 --> 01:45.630
And one of them is this column here price.

01:45.790 --> 01:51.270
And price represents the current value of this equity in the market.

01:51.270 --> 01:53.670
And we've already seen an agent fill in this column.

01:53.670 --> 01:54.390
You know it.

01:54.510 --> 01:56.070
And we'll be able to do that again.

01:56.430 --> 01:58.110
But this one is the new column.

01:58.110 --> 02:02.950
This is for the agent to fill in to say how many shares should we have?

02:03.150 --> 02:09.460
How much quantity of these different tickers after I've made some trades to rebalance the portfolio

02:09.460 --> 02:13.060
and it will fill in this column as it makes its decisions.

02:13.060 --> 02:18.260
And when it does that, there's going to be a new total value coming up, and we will find out what

02:18.260 --> 02:23.500
kind of proportion between equity and fixed income does it get at the end of it.

02:23.500 --> 02:29.020
And of course, you can add in other kinds of of metrics like whether it's, it's global or, or national

02:29.020 --> 02:33.020
investments and so on, should you wish to rebalance in different ways.

02:33.460 --> 02:33.900
Okay.

02:33.940 --> 02:35.900
So that's the spreadsheet setup.

02:35.940 --> 02:37.580
Obviously the price is all blank here.

02:37.580 --> 02:41.060
But if I put in a price like 100 then it fills in the value.

02:41.060 --> 02:47.980
And if I put in a new quantity after rebalancing of three, then the total value goes in there and the

02:47.980 --> 02:48.980
other things fill in.

02:48.980 --> 02:51.020
But we're going to leave it blank for now.

02:51.340 --> 02:58.300
This this is a spreadsheet that we are going to be equipping our agent with and it will operate on this.

02:58.300 --> 02:59.540
Let's go and do that.

02:59.580 --> 03:00.020
Okay.

03:00.060 --> 03:02.180
So we go back to Nw10.

03:02.340 --> 03:03.260
Here it is.

03:03.300 --> 03:09.100
We are going to add in an agent and let's take a look at it.

03:09.100 --> 03:10.980
There it is okay.

03:11.180 --> 03:13.420
We've got lots to do with this AI agent.

03:13.580 --> 03:15.060
We're going to give it a chat model.

03:15.060 --> 03:16.500
We're going to I'm going to use OpenAI.

03:16.540 --> 03:19.220
You can use whatever chat model you wish.

03:19.700 --> 03:24.980
And we are going to choose I'm going to choose GPT 4.1.

03:25.260 --> 03:31.140
Now the reason for that is that I want to I want it to be a really smart model that does it well, uh,

03:31.180 --> 03:33.980
you can choose what you want to to, to use.

03:34.060 --> 03:37.500
It costs a few cents a pop with GPT 4.1.

03:37.500 --> 03:40.700
And of course, it's a fraction of that with GPT four one mini.

03:40.700 --> 03:42.540
And you should go with whatever you're comfortable with.

03:42.660 --> 03:49.820
I do find that the latest models like GPT 5.2 for me right now actually doesn't perform as well because

03:49.860 --> 03:53.380
it does too much reasoning and it takes too long.

03:53.620 --> 03:59.380
And the outcomes for me are better just using GPT 4.1, which for this kind of thing is one of my favorites.

03:59.820 --> 04:04.420
Okay, so I'm selecting GPT 4.1, but of course you can do anything over open router.

04:04.420 --> 04:05.700
You could be using Gemini.

04:05.940 --> 04:08.860
Use whatever you want to okay.

04:08.900 --> 04:12.660
And and back we go here I'll press that tidy up button to make it a bit cleaner.

04:12.940 --> 04:16.500
And we will we will then keep going with some tools okay.

04:16.610 --> 04:17.570
and we're skipping memory.

04:17.570 --> 04:21.050
We don't need memory for this because it's just on a form submission.

04:21.050 --> 04:23.410
There's no chat history to have to remember.

04:23.610 --> 04:28.530
We go straight to tool and we're going to go to sheets, of course, Google Sheets tool.

04:28.530 --> 04:30.890
It's already set up with the right credentials.

04:30.890 --> 04:32.090
We know we can connect.

04:32.090 --> 04:32.890
Fine.

04:32.930 --> 04:34.330
We're doing a sheet with a document.

04:34.330 --> 04:35.890
We want to get rows.

04:35.930 --> 04:40.210
This is going to be the way that we fetch the contents of our portfolio.

04:40.610 --> 04:44.610
The documents we're going to get is going to be uh, from from a list.

04:44.610 --> 04:47.130
And we're going to choose the, the portfolio.

04:47.450 --> 04:49.970
And the sheet is also going to be from a list.

04:49.970 --> 04:52.530
We're going to choose the sheet number one.

04:52.690 --> 04:53.610
I'll do that now.

04:53.650 --> 04:55.770
So I chose portfolio from the list here.

04:55.770 --> 04:59.410
And I'm now choosing the sheet is sheet one right here.

04:59.730 --> 05:01.570
And I'm not going to set any filters.

05:01.570 --> 05:04.730
I want it to be able to to retrieve the whole thing.

05:05.010 --> 05:05.610
Okay.

05:05.730 --> 05:08.610
So that has set up our Google Sheets access.

05:08.650 --> 05:10.130
Let's press the clean button.

05:10.330 --> 05:14.050
And now we will give this a try and see what happens.

05:14.050 --> 05:16.530
And hopefully you're expecting something to go wrong.

05:16.570 --> 05:20.920
Let's see okay I'm now going to press Execute Workflow and bam.

05:21.200 --> 05:22.560
Up pops this window.

05:22.760 --> 05:24.160
It's it's a form.

05:24.160 --> 05:26.040
And it says portfolio Rebalancer.

05:26.040 --> 05:28.200
It's the very form that we just described.

05:28.440 --> 05:31.040
And it has the one question that is the field we put in there.

05:31.040 --> 05:32.960
How would you like to rebalance your portfolio?

05:33.160 --> 05:36.080
And the default answer is 60 over 40.

05:36.320 --> 05:37.760
And I'm going to press submit.

05:37.960 --> 05:46.160
And pressing submit is basically sending an HTTP request which Nen has configured as a webhook.

05:46.320 --> 05:50.480
And it is expecting this to come through and bam it has come through.

05:50.480 --> 05:56.000
And if I click back here, you'll see that the workflow has run and it says there's a problem just as

05:56.000 --> 05:57.880
we're expecting or are you expecting?

05:57.880 --> 05:58.760
I hope you're expecting.

05:58.760 --> 06:00.600
So now let's go in and fix that problem.

06:00.600 --> 06:04.200
And so you'll see the error message tells us no prompt specified.

06:04.200 --> 06:06.200
And you'll recognize that because we've had it before.

06:06.400 --> 06:13.280
And if you open up AI agent we'll see more details that it was trying to bring in Jason chat input.

06:13.320 --> 06:17.160
It thinks it's connected to a chat trigger node and it's not.

06:17.200 --> 06:19.240
It's connected to something very different.

06:19.240 --> 06:24.120
So the first thing that we need to do is to change this from saying the source for the prompt is a chat

06:24.120 --> 06:25.230
trigger node to say.

06:25.270 --> 06:25.830
Define.

06:25.830 --> 06:31.230
Below we want to tell it how to look in the inputs and choose what should be the prompt to the LM.

06:31.390 --> 06:32.910
And this is the input.

06:33.150 --> 06:36.270
This is the webhook that got called as a little side note.

06:36.310 --> 06:39.510
Notice that it is of course an array of items.

06:39.550 --> 06:44.310
And that's as I explained, that really what gets moved between these nodes are these arrays of items.

06:44.310 --> 06:45.390
But there's only one.

06:45.390 --> 06:47.390
It's the submission of our web form.

06:47.390 --> 06:51.390
And it only has this one question how would you like to rebalance your portfolio?

06:51.510 --> 06:53.030
And it's this stuff here.

06:53.030 --> 06:55.390
This is what we want to be sent to the LM.

06:55.550 --> 06:57.950
So let's drag and drop that in there.

06:57.990 --> 06:58.710
Let go.

06:58.910 --> 07:03.230
And you'll see that it's put in there the right JSON to use JSON.

07:03.230 --> 07:04.470
And then it's selected.

07:04.470 --> 07:06.710
How would you like to rebalance your portfolio.

07:06.910 --> 07:09.030
And so that's that's working nicely.

07:09.030 --> 07:13.550
That's going to take this contents here and make it the prompt to the LM.

07:13.590 --> 07:17.470
So I'm going back here to the canvas I'm pressing Execute Workflow.

07:17.510 --> 07:20.910
Up comes this pop up and I'm going to submit it.

07:21.270 --> 07:28.230
So this time it will hopefully be sending this exact instruction to the agent when when this goes through.

07:28.470 --> 07:32.030
and what I think we'll find is something a bit curious happens, because we've not done a very good

07:32.030 --> 07:35.550
job of telling the agent what we want it to do.

07:35.750 --> 07:40.870
We've just said ensure the portfolio is 60% equity and 40% fixed income, but we haven't told it that

07:40.870 --> 07:42.830
that portfolio is in this Google sheet.

07:42.830 --> 07:45.070
We haven't really given it good directions.

07:45.390 --> 07:47.430
This used to be what they would call prompt engineering.

07:47.430 --> 07:49.430
We've not done a good job of prompt engineering.

07:49.470 --> 07:55.630
The new expression is context engineering, which is the way to best position your whole agentic workflow

07:55.630 --> 07:58.950
to to equip your agent with the best possible information.

07:58.950 --> 08:01.110
And we've not done a good job of any of that.

08:01.110 --> 08:05.350
So let's see what it says back now that it's just successfully run, let's see what happened.

08:05.350 --> 08:07.750
And you can see that what's happened is in the output.

08:07.790 --> 08:12.870
It said to ensure a portfolio is allocated 60% equity and 40% follow these instructions.

08:12.870 --> 08:16.430
And it's given us some sort of bland, generic content about what to do.

08:16.590 --> 08:20.950
It never used the tool because it didn't know that that tool was going to tell it our portfolio.

08:21.310 --> 08:22.630
So it didn't do any of that.

08:22.630 --> 08:25.830
It just kind of gave us back some, some random instructions.

08:25.830 --> 08:30.190
We need to improve the prompt so that it knows what it has to do, and we also need to give it a few

08:30.190 --> 08:31.470
more tools so it can do it.

08:31.510 --> 08:33.230
And that's what we will come to next.
