So we got started with agent mode, but of course,
And the application we're building here is, of course, not
done. So, what I wanna do as a next step, of course,
is I wanna continue with my implementation here and make sure that
we use the OpenAI API to ask the AI, using the
GPT-5 model, to generate a post optimized for X.
So as I mentioned before, whenever you send a new message here, it
will always take the entire chat history into account.
So here I could say, let's now proceed with the next step
API to use the Markdown file content and produce an X post, store that
generated X post in outputs. Again, you can use plan
mode or agent mode, and I'll again
use plan mode, and send this to the
AI. So now again, it made a plan
here. I can view it, and you
see that it wants to include the OpenAI package, which makes a lot of
sense because I have not installed it yet.
It wants to use an environment variable, the OpenAI API key
variable, which also makes sense because we'll need
with the API, and then it plans to import the OpenAI
library client, initialize it. It then
creates the output directory if it doesn't exist yet, and then we
process each file and I don't want to use the 4o model.
I told it to use GPT-5 and it says that it's not available yet, and
that is a typical problem which you may or may not face when you're
following along. But of course, AI often has the problem of having
a knowledge cutoff date that's in the past, and therefore not being aware of
recent changes. And of course, there is a GPT-5 model available when I'm
recording this. So, I will remove that note and edit this
to use the GPT-5 model, which is
available, to make sure that this gets used.
That is why you might wanna read those plans.
I'll also add another instruction here and say, "Use common best
practices and techniques for generating
a prompt that yields a
highly engaging X post," because
I want the AI to also write the prompt for the actual AI that will
then use the input to generate the actual X
post. Again, here I want to use
GPT-5, and I don't want it to split
the prompt that my program will send to OpenAI into a
system and a user message, because even though we could do that,
"Write a single prompt that creates that highly engaging X
post" described above. Again,
GPT-5,
and then this looks good to me. So again, we can click build.
I don't have a build button here at the point of time where I'm recording this,
I do have one here, so I'll click that.
And again, it'll switch to agent mode, and it now created a to-do list for
itself, the one you see here, and it works through that step by
step, using the information it has in its plan
context from this chat here. Now, you can also
send follow-up messages whilst it's working.
For example, if I don't want hashtags in
the X posts, I might wanna send that extra
information. Now, if you hit enter whilst it's working,
this will be queued and it will then be sent at the first
time where the work can be interrupted.
It will then still continue with the other tasks as well, but it will also
consider that extra information you sent to it.
You can configure how the queued messages will be used in
the cursor settings, by the way. So here it's
already done and back in main.py, I can therefore see that it's
importing the OpenAI package. I can also see that in
pyproject.toml, which is managing the dependencies in this
UV managed Python project, it added the OpenAI package, so
that's good. And then we got some code for initializing
package with the OpenAI API key, which it expects
to be available in the environment.
And then it goes ahead and for each Markdown
file, it uses the
GPT-5 model as instructed and sends a single user
prompt as instructed, where it tells it to create an engaging
that does not include hashtags. So that's looking good
except for one thing. I'm not happy with how
it uses the OpenAI package. I'll still accept everything here,
but I wanna tweak that.