WEBVTT

00:00:00.100 --> 00:00:04.080
So we got started with agent mode,
but of course,

00:00:04.140 --> 00:00:07.450
And the application we're building here
is, of course, not

00:00:07.480 --> 00:00:11.460
done. So, what I wanna do as a next step,
of course,

00:00:11.560 --> 00:00:15.470
is I wanna continue with my implementation
here and make sure that

00:00:15.520 --> 00:00:19.410
we use the OpenAI API to ask the AI,
using the

00:00:19.420 --> 00:00:22.980
GPT-5 model,
to generate a post optimized for X.

00:00:23.840 --> 00:00:27.800
So as I mentioned before,
whenever you send a new message here, it

00:00:27.860 --> 00:00:31.360
will always take the entire chat history
into account.

00:00:31.420 --> 00:00:35.240
So here I could say,
let's now proceed with the next step

00:00:35.300 --> 00:00:39.140
API to use the Markdown file content
and produce an X post, store that

00:00:39.240 --> 00:00:43.000
generated X post in outputs. Again,
you can use plan

00:00:43.060 --> 00:00:46.720
mode or agent mode, and I'll again

00:00:46.820 --> 00:00:49.820
use plan mode, and send this to the

00:00:49.880 --> 00:00:53.500
AI. So now again, it made a plan

00:00:53.560 --> 00:00:57.320
here. I can view it, and you

00:00:57.420 --> 00:01:01.310
see that it wants to include the OpenAI
package, which makes a lot of

00:01:01.340 --> 00:01:03.650
sense because I have not installed it yet.

00:01:03.680 --> 00:01:07.220
It wants to use an environment variable,
the OpenAI API key

00:01:07.260 --> 00:01:11.100
variable,
which also makes sense because we'll need

00:01:11.160 --> 00:01:15.060
with the API,
and then it plans to import the OpenAI

00:01:15.380 --> 00:01:18.840
library client, initialize it. It then

00:01:18.920 --> 00:01:22.540
creates the output directory
if it doesn't exist yet, and then we

00:01:22.580 --> 00:01:26.280
process each file
and I don't want to use the 4o model.

00:01:26.460 --> 00:01:30.340
I told it to use GPT-5 and it says
that it's not available yet, and

00:01:30.400 --> 00:01:34.120
that is a typical problem which you may
or may not face when you're

00:01:34.160 --> 00:01:38.040
following along. But of course,
AI often has the problem of having

00:01:38.050 --> 00:01:41.900
a knowledge cutoff date that's in the
past, and therefore not being aware of

00:01:42.000 --> 00:01:45.780
recent changes. And of course, there
is a GPT-5 model available when I'm

00:01:45.800 --> 00:01:49.540
recording this. So, I will remove
that note and edit this

00:01:49.620 --> 00:01:52.560
to use the GPT-5 model, which is

00:01:52.640 --> 00:01:56.560
available, to make sure
that this gets used.

00:01:56.580 --> 00:02:00.120
That is why you might wanna read those
plans.

00:02:01.400 --> 00:02:05.080
I'll also add another instruction here
and say, "Use common best

00:02:05.140 --> 00:02:09.080
practices and techniques for generating

00:02:10.620 --> 00:02:12.560
a prompt that yields a

00:02:14.100 --> 00:02:18.060
highly engaging X post," because

00:02:18.260 --> 00:02:22.140
I want the AI to also write the prompt for
the actual AI that will

00:02:22.180 --> 00:02:25.440
then use the input to generate the actual
X

00:02:25.480 --> 00:02:29.400
post. Again, here I want to use

00:02:29.420 --> 00:02:33.320
GPT-5, and I don't want it to split

00:02:33.380 --> 00:02:37.240
the prompt that my program will send to
OpenAI into a

00:02:37.300 --> 00:02:41.040
system and a user message,
because even though we could do that,

00:02:41.640 --> 00:02:45.560
"Write a single prompt that creates
that highly engaging X

00:02:45.580 --> 00:02:48.480
post" described above. Again,

00:02:48.540 --> 00:02:51.020
GPT-5,

00:02:53.460 --> 00:02:57.200
and then this looks good to me. So again,
we can click build.

00:02:57.300 --> 00:03:00.370
I don't have a build button here at the
point of time where I'm recording this,

00:03:00.580 --> 00:03:02.390
I do have one here, so I'll click that.

00:03:02.400 --> 00:03:05.820
And again, it'll switch to agent mode,
and it now created a to-do list for

00:03:05.860 --> 00:03:09.720
itself, the one you see here,
and it works through that step by

00:03:09.900 --> 00:03:13.620
step,
using the information it has in its plan

00:03:13.660 --> 00:03:17.430
context from this chat here. Now,
you can also

00:03:17.440 --> 00:03:20.860
send follow-up messages whilst it's
working.

00:03:20.880 --> 00:03:24.430
For example, if I don't want hashtags in

00:03:24.500 --> 00:03:27.520
the X posts, I might wanna send that extra

00:03:27.560 --> 00:03:31.440
information. Now,
if you hit enter whilst it's working,

00:03:31.520 --> 00:03:34.930
this will be queued
and it will then be sent at the first

00:03:35.020 --> 00:03:37.290
time where the work can be interrupted.

00:03:37.320 --> 00:03:41.080
It will then still continue with the other
tasks as well, but it will also

00:03:41.120 --> 00:03:44.180
consider that extra information you sent
to it.

00:03:44.240 --> 00:03:48.130
You can configure how the queued messages
will be used in

00:03:48.130 --> 00:03:51.850
the cursor settings, by the way.
So here it's

00:03:51.920 --> 00:03:55.590
already done and back in main.py,
I can therefore see that it's

00:03:55.640 --> 00:03:59.000
importing the OpenAI package.
I can also see that in

00:03:59.040 --> 00:04:02.960
pyproject.toml, which
is managing the dependencies in this

00:04:03.080 --> 00:04:06.780
UV managed Python project,
it added the OpenAI package, so

00:04:06.860 --> 00:04:10.820
that's good.
And then we got some code for initializing

00:04:10.940 --> 00:04:14.780
package with the OpenAI API key,
which it expects

00:04:14.820 --> 00:04:17.300
to be available in the environment.

00:04:17.320 --> 00:04:20.430
And then it goes ahead
and for each Markdown

00:04:20.579 --> 00:04:24.040
file, it uses the

00:04:24.080 --> 00:04:28.000
GPT-5 model as instructed
and sends a single user

00:04:28.040 --> 00:04:31.800
prompt as instructed,
where it tells it to create an engaging

00:04:31.860 --> 00:04:35.610
that does not include hashtags.
So that's looking good

00:04:35.640 --> 00:04:39.480
except for one thing.
I'm not happy with how

00:04:39.540 --> 00:04:43.450
it uses the OpenAI package.
I'll still accept everything here,

00:04:43.480 --> 00:04:47.120
but I wanna tweak that.
