WEBVTT

1
00:00:00.390 --> 00:00:02.590
Hi, and welcome to this AI in C#

2
00:00:02.590 --> 00:00:07.230
video on the Agent Framework Toolkit, which

3
00:00:07.230 --> 00:00:10.290
is a set of NuGet packages that I

4
00:00:10.290 --> 00:00:14.370
have made that makes Agent Framework easier to

5
00:00:14.370 --> 00:00:15.210
work with.

6
00:00:15.750 --> 00:00:18.170
Today, we're going to look at easier agents.

7
00:00:19.690 --> 00:00:23.750
So the packages are up on NuGet, they're

8
00:00:23.750 --> 00:00:28.490
free, MIT, and are just a wrapper on

9
00:00:28.490 --> 00:00:30.430
top of the Agent Framework.

10
00:00:31.090 --> 00:00:34.370
You can choose whatever provider you want, Anthropic,

11
00:00:34.590 --> 00:00:37.610
Google, XAI, OpenAI, and so on.

12
00:00:40.680 --> 00:00:43.400
Or you can go and get the source

13
00:00:43.400 --> 00:00:44.460
code if you wish to.

14
00:00:46.480 --> 00:00:48.780
But let's see it in action on why

15
00:00:48.780 --> 00:00:52.540
it's worth adding this NuGet package compared to

16
00:00:52.540 --> 00:00:55.720
just using Microsoft Agent Framework by itself.

17
00:00:57.700 --> 00:01:01.300
So, I made a new one here called

18
00:01:01.300 --> 00:01:03.900
easier agents in our sample repo.

19
00:01:04.860 --> 00:01:06.640
And the first thing you will see is

20
00:01:06.640 --> 00:01:09.180
that you only need one NuGet package, not

21
00:01:09.180 --> 00:01:09.520
two.

22
00:01:10.120 --> 00:01:13.560
So the Azure OpenAI will, behind the scenes,

23
00:01:14.300 --> 00:01:17.040
reference the Azure OpenAI NuGet package, so you

24
00:01:17.040 --> 00:01:18.680
don't need to reference it yourself.

25
00:01:19.500 --> 00:01:22.160
So with this one NuGet package, you get

26
00:01:22.160 --> 00:01:23.040
everything you need.

27
00:01:25.490 --> 00:01:29.490
And the best way to show what it

28
00:01:29.490 --> 00:01:32.630
helps with is to actually just show you

29
00:01:32.630 --> 00:01:36.310
what you would do before you had this

30
00:01:36.310 --> 00:01:37.190
package.

31
00:01:38.530 --> 00:01:41.390
So if you had a task of you

32
00:01:41.390 --> 00:01:43.970
needed to take some weather data from a

33
00:01:43.970 --> 00:01:47.350
tool and put it out as structured output,

34
00:01:47.950 --> 00:01:51.370
you needed to call middleware, and you should

35
00:01:51.370 --> 00:01:55.050
use ChatGPT-mini with low reasoning effort.

36
00:01:56.630 --> 00:01:58.590
If you need to do that, we can

37
00:01:58.590 --> 00:02:02.810
see the tool is simple, and the weather

38
00:02:02.810 --> 00:02:05.990
report is just a structured output object.

39
00:02:08.740 --> 00:02:10.340
But in order for us to do this,

40
00:02:10.740 --> 00:02:14.420
we would get some credentials, that's normal.

41
00:02:14.920 --> 00:02:17.320
We would need to new up the Azure

42
00:02:17.320 --> 00:02:18.560
OpenAI client.

43
00:02:19.360 --> 00:02:22.100
We would need to make our agents.

44
00:02:22.920 --> 00:02:26.720
And because we wanted low reasoning, we need

45
00:02:26.720 --> 00:02:29.520
to do this special thing about chat options

46
00:02:29.520 --> 00:02:32.700
inside the chat client agent options with the

47
00:02:32.700 --> 00:02:36.980
chat client completion options to set this one

48
00:02:36.980 --> 00:02:37.780
property.

49
00:02:39.840 --> 00:02:42.980
We would set the tools as normal, but

50
00:02:42.980 --> 00:02:46.060
also because we want the function calling middleware,

51
00:02:46.060 --> 00:02:47.980
which is the code down here.

52
00:02:48.820 --> 00:02:51.100
We would need to do an as builder,

53
00:02:51.480 --> 00:02:54.580
use function calling middleware and build it.

54
00:02:55.080 --> 00:02:57.120
And we would end up with an AI

55
00:02:57.120 --> 00:03:00.040
agent, which is very bad for us when

56
00:03:00.040 --> 00:03:02.500
we need to do structured output, because an

57
00:03:02.500 --> 00:03:07.520
AI agent can't do run async with structured

58
00:03:07.520 --> 00:03:10.260
output like a chat client agent can do.

59
00:03:10.820 --> 00:03:13.440
So we would need to end up making

60
00:03:13.440 --> 00:03:15.340
some JSON serialisation options.

61
00:03:16.380 --> 00:03:19.720
We would need to, in our run async,

62
00:03:20.760 --> 00:03:23.500
put in yet another chat client agent options

63
00:03:23.500 --> 00:03:26.020
run here, in order to set the chat

64
00:03:26.020 --> 00:03:28.740
options, in order to set the response format

65
00:03:28.740 --> 00:03:32.540
to our weather report, which when we then

66
00:03:32.540 --> 00:03:35.540
get back, would need to deserialize with the

67
00:03:35.540 --> 00:03:39.680
serialisation options again, and finally have our output.

68
00:03:41.420 --> 00:03:45.120
So in total, we would need 84 lines

69
00:03:45.120 --> 00:03:48.440
of code, plus the tools and the objects.

70
00:03:50.120 --> 00:03:56.360
Let's see the exact same task in Agent

71
00:03:56.360 --> 00:03:57.160
Framework Toolkit.

72
00:03:58.000 --> 00:03:58.780
And here you have it.

73
00:03:59.900 --> 00:04:03.140
We do again get secrets, but instead of

74
00:04:03.140 --> 00:04:06.060
an Azure OpenAI client, we would make an

75
00:04:06.060 --> 00:04:09.480
Azure OpenAI agent factory, where we'll just give

76
00:04:09.480 --> 00:04:11.360
our endpoint and our API key.

77
00:04:13.190 --> 00:04:16.029
Then we'll use this agent to create an

78
00:04:16.029 --> 00:04:16.470
agent.

79
00:04:17.209 --> 00:04:20.850
We will take chat-gb5-mini, we'll just

80
00:04:20.850 --> 00:04:25.190
tell it slow, we'll tell the tools, and

81
00:04:25.190 --> 00:04:28.610
we'll put in the middleware directly here as

82
00:04:28.610 --> 00:04:29.190
an action.

83
00:04:32.780 --> 00:04:35.560
Then we'll get an Azure OpenAI agent, which

84
00:04:35.560 --> 00:04:38.480
is behind the scenes just a normal agent,

85
00:04:38.480 --> 00:04:40.000
so it's an inheritance.

86
00:04:41.540 --> 00:04:45.240
And that agent can do the wrong async,

87
00:04:45.640 --> 00:04:48.340
so we have the weather report directly out

88
00:04:48.340 --> 00:04:52.480
as a chat client agent response, despite we

89
00:04:52.480 --> 00:04:54.460
having the tool called middleware.

90
00:04:54.980 --> 00:04:57.400
And we would be done in 36 lines

91
00:04:57.400 --> 00:04:57.820
of code.

92
00:04:58.470 --> 00:05:01.720
So we'll have as many lines of code

93
00:05:01.720 --> 00:05:06.580
that are much easier to look at, and

94
00:05:06.580 --> 00:05:11.960
with the same features and functions, just easier,

95
00:05:12.520 --> 00:05:15.240
as the title of this video said.

96
00:05:16.720 --> 00:05:17.200
So we're done.

97
00:05:17.700 --> 00:05:18.580
See you on the next one.
