Hi, and welcome to this AI in C#
video on the Agent Framework Toolkit, which
is a set of NuGet packages that I
have made that makes Agent Framework easier to
work with.
Today, we're going to look at easier agents.
So the packages are up on NuGet, they're
free, MIT, and are just a wrapper on
top of the Agent Framework.
You can choose whatever provider you want, Anthropic,
Google, XAI, OpenAI, and so on.
Or you can go and get the source
code if you wish to.
But let's see it in action on why
it's worth adding this NuGet package compared to
just using Microsoft Agent Framework by itself.
So, I made a new one here called
easier agents in our sample repo.
And the first thing you will see is
that you only need one NuGet package, not
two.
So the Azure OpenAI will, behind the scenes,
reference the Azure OpenAI NuGet package, so you
don't need to reference it yourself.
So with this one NuGet package, you get
everything you need.
And the best way to show what it
helps with is to actually just show you
what you would do before you had this
package.
So if you had a task of you
needed to take some weather data from a
tool and put it out as structured output,
you needed to call middleware, and you should
use ChatGPT-mini with low reasoning effort.
If you need to do that, we can
see the tool is simple, and the weather
report is just a structured output object.
But in order for us to do this,
we would get some credentials, that's normal.
We would need to new up the Azure
OpenAI client.
We would need to make our agents.
And because we wanted low reasoning, we need
to do this special thing about chat options
inside the chat client agent options with the
chat client completion options to set this one
property.
We would set the tools as normal, but
also because we want the function calling middleware,
which is the code down here.
We would need to do an as builder,
use function calling middleware and build it.
And we would end up with an AI
agent, which is very bad for us when
we need to do structured output, because an
AI agent can't do run async with structured
output like a chat client agent can do.
So we would need to end up making
some JSON serialisation options.
We would need to, in our run async,
put in yet another chat client agent options
run here, in order to set the chat
options, in order to set the response format
to our weather report, which when we then
get back, would need to deserialize with the
serialisation options again, and finally have our output.
So in total, we would need 84 lines
of code, plus the tools and the objects.
Let's see the exact same task in Agent
Framework Toolkit.
And here you have it.
We do again get secrets, but instead of
an Azure OpenAI client, we would make an
Azure OpenAI agent factory, where we'll just give
our endpoint and our API key.
Then we'll use this agent to create an
agent.
We will take chat-gb5-mini, we'll just
tell it slow, we'll tell the tools, and
we'll put in the middleware directly here as
an action.
Then we'll get an Azure OpenAI agent, which
is behind the scenes just a normal agent,
so it's an inheritance.
And that agent can do the wrong async,
so we have the weather report directly out
as a chat client agent response, despite we
having the tool called middleware.
And we would be done in 36 lines
of code.
So we'll have as many lines of code
that are much easier to look at, and
with the same features and functions, just easier,
as the title of this video said.
So we're done.
See you on the next one.