So far, we have only asked our agents
about generic things, historic things, like what is
the capital of France, and so on.
But what if we need up-to-date
news?
What if we need today's date, and such
things?
Well, without doing anything, we can't really do
such things.
So we can, for example, say, what is
today's date?
It will come back and say it's October
4th, 2023.
Sometimes it will say different things, depending on
what we do, but it will roughly be,
in this case, it's at some completely other
date, but it will roughly be around its
cut-off date, meaning when it was finished
training, and in this case, OpenAI put it
into production.
But without anything like this, we can't really
do anything.
And in the same manner, if I say,
what is the latest space news?
I do that, it will come back about
something about Artemis 3 returning humans next year,
which is apparently 2025, which we are already
past, and not even Artemis 2 have been
launched yet.
So this has absolutely nothing to do with
reality, and that's because it doesn't know it.
It cannot predict the future, like you and
me can't predict the future, and its current
date is in the past.
So what we need to do is we
need to fix this with a few things.
The first thing we can do is we
can easily fix today's date.
That's just to give it a couple of
tools.
So let's give it a function factory of
two small tools I put down here, which
is just today's date in UTC and my
time zone, so it knows how to convert
in UTC.
So we can say get UTC here, and
we can put in one more tool, function
factory.create.getTimeZoneInfo. We do that.
We will see now that if we ask
what is today's date, it is now able
to come back, and as you can see,
AI is always eager, so it tells, oh,
look how much I know about today's date
is, but that's okay.
We can always prompt the engineer to only
just give the date if we wanted to,
but we still can't say what is the
latest space news because it still doesn't know,
and sometimes it actually realises I don't have
access.
Sometimes it will give some values back from
October 23.
Sometimes it will just make stuff up because
it doesn't know.
In this case, it was honest in saying
I don't know.
So what we have available is a tool
that Microsoft Agent Framework passes along.
It's called Web Search, and you know it
from ChatGPT.
If we give it as a tool, so
it's a tool we don't need to create
ourselves behind the scenes if we look at
it, it's just web underscore search as a
name, which is the common name for it.
It will, however, not help.
What is today's new space news?
So it comes back.
It still talks about things that happened right
now.
It is like two, three years ago.
So the reason why this doesn't work is
because we're using a chat client.
Back in the hello world, I talked about
there was two different clients we could use,
and we wanted to use chat client because
it's most compatible.
But if we want to use special tools
like web search here and also a tool
called Code Interpreter, which we'll cover in the
next lecture, we need to have the responses
client.
The responses client is a more modern thing
from OpenAI, but it is sort of finished,
sort of not finished.
According to the NuGet package, it's still in
preview while OpenAI claims that it's finished.
The reason I don't use it day to
day is I find it more buggy.
It sometimes can answer back without any content
I've seen, so it's more experimental in my
book.
But if we need these more fancy tools
and stuff, we need to use it.
And we need to put these pragmas around
them, so we are telling the system we
are okay with using experimental features.
But if we do this, we actually get
news.
List the top one space news item.
And I know that, yeah, it's the medical
emergency that's happening today on January 8th, 2026,
where one of the crew members that were
about to do a spacewalk has become ill.
We also see that it comes from Indian
TV news.
This is just random in this case.
But the way web searches work is, of
course, a little like you going to Google.
But since Microsoft and OpenAI are working together,
this actually comes from Bing.com.
So it would be the same as if
you put in this in Bing.com.
It would give back a few answers, and
it will go in and use that from
the system, give it to you as input,
and then summarise it like a normal AI
would do.
So I think it gets like 10 different
things, but we just asked for the top
one, and that's the reason why it only
shows one.
This, however, comes at some quite of cost.
Not that up-to-date information is not
valuable, but we need to pay a little
extra for this.
So list, top one, space, news in space.
If we do this again, we will see
that our response here is 7,102 input
tokens, where a lot of them comes from.
If we look inside these messages and content,
we can see it came from a web
search call response item.
So the tool has been called.
It was called up in the cloud and
came back with the data.
So we wouldn't be able to see it
as a middleware tool.
They don't work with that, but we are
paying extra tokens because it made the web
search, and it put all the search result
into our input.
Another thing as well is that we also
pay for each call.
So web searches are premium on top of
tokens where you actually pay $10 per 1
,000 of these calls.
For this, calling one here and there right
now doesn't cost a lot, but of course
if you make a chatbot that can search
the news and stuff, you might easily spend
a lot of money on that.
So just be aware of this.
Of course, there are an extra cost involved,
all depending on if you're using Azure OpenAI
or OpenAI.
These are the OpenAI costs.
But we are not limited to just its
cutoff date or anything, so we can make
our own simple things to get the date
right, and to get news items and stuff,
we can get this as well.