WEBVTT

1
00:00:00.470 --> 00:00:03.230
In the last lecture, we saw the life

2
00:00:03.230 --> 00:00:04.410
of an LLM code.

3
00:00:05.230 --> 00:00:08.150
And I mentioned that there was some extras

4
00:00:08.150 --> 00:00:09.990
thing about this.

5
00:00:11.190 --> 00:00:14.150
So let's quickly go through how you can

6
00:00:14.150 --> 00:00:18.810
turn on to see these requests and responses

7
00:00:18.810 --> 00:00:19.710
live.

8
00:00:20.970 --> 00:00:23.370
So what you need to do is you

9
00:00:23.370 --> 00:00:27.750
need to make a custom client HTTP handler.

10
00:00:27.750 --> 00:00:32.330
So an HTTP handler that looks like this.

11
00:00:32.530 --> 00:00:34.090
And we'll go down and see this.

12
00:00:35.050 --> 00:00:37.130
And we would need to put that into

13
00:00:37.130 --> 00:00:41.450
an HTTP client so it can control all

14
00:00:41.450 --> 00:00:41.970
the handling.

15
00:00:42.390 --> 00:00:45.330
Normally, handling will just be send and receive.

16
00:00:45.770 --> 00:00:48.570
But we can actually go in and override

17
00:00:48.570 --> 00:00:50.650
what's going on in the send method.

18
00:00:52.990 --> 00:00:55.430
And when we do that, we need to

19
00:00:55.430 --> 00:00:57.590
put in the transport object here.

20
00:00:57.750 --> 00:01:00.710
Where we get a chat client pipeline where

21
00:01:00.710 --> 00:01:03.610
we can put in this special HTTP client

22
00:01:03.610 --> 00:01:04.570
that we control.

23
00:01:05.670 --> 00:01:08.790
So that is what happens before we make

24
00:01:08.790 --> 00:01:09.390
our call.

25
00:01:10.850 --> 00:01:13.710
And then we have our custom client handler.

26
00:01:14.150 --> 00:01:17.150
So it's just inheriting from the HTTP client

27
00:01:17.150 --> 00:01:17.430
handler.

28
00:01:17.870 --> 00:01:20.310
And we are able to override the send

29
00:01:20.310 --> 00:01:20.910
async.

30
00:01:20.910 --> 00:01:26.350
Meaning whenever behind the scenes in agent framework,

31
00:01:26.510 --> 00:01:29.530
there's an HTTP client that says send async.

32
00:01:30.490 --> 00:01:34.890
Send some post call or get call and

33
00:01:34.890 --> 00:01:35.190
so on.

34
00:01:35.490 --> 00:01:37.630
We can intersect it here.

35
00:01:38.490 --> 00:01:40.010
So if I set a breakpoint here.

36
00:01:41.070 --> 00:01:43.170
And this is, again, what is the weather

37
00:01:43.170 --> 00:01:43.950
like in Paris?

38
00:01:45.030 --> 00:01:49.630
So if we set a breakpoint here and

39
00:01:49.630 --> 00:01:50.510
let it run.

40
00:01:50.910 --> 00:01:51.810
To that.

41
00:01:56.070 --> 00:01:58.190
We end up hitting this.

42
00:01:58.470 --> 00:02:01.530
And if I press F5, we will end

43
00:02:01.530 --> 00:02:02.050
up here.

44
00:02:03.510 --> 00:02:07.870
Because now agent framework have taken this and

45
00:02:07.870 --> 00:02:10.810
deep down underneath run async, there's an HTTP

46
00:02:10.810 --> 00:02:14.190
client calling the LLM model.

47
00:02:15.290 --> 00:02:17.330
And in our case, we can see that

48
00:02:17.330 --> 00:02:18.410
request string.

49
00:02:19.570 --> 00:02:21.230
And the request URI.

50
00:02:22.110 --> 00:02:24.390
So this means this is what we are

51
00:02:24.390 --> 00:02:24.730
calling.

52
00:02:25.970 --> 00:02:27.590
And here is the request string.

53
00:02:28.150 --> 00:02:30.190
And it's a long string as we saw.

54
00:02:38.570 --> 00:02:41.970
And because it's long out here, it looks

55
00:02:41.970 --> 00:02:43.510
like it's not as long as it was

56
00:02:43.510 --> 00:02:43.930
before.

57
00:02:43.930 --> 00:02:46.210
But it's exactly the same data with the

58
00:02:46.210 --> 00:02:50.930
messages, the model, the response format, and the

59
00:02:50.930 --> 00:02:51.310
tools.

60
00:02:55.610 --> 00:02:57.010
So we get that.

61
00:02:58.490 --> 00:03:02.490
And I'm just making it pretty, JSON serialising

62
00:03:02.490 --> 00:03:02.770
it.

63
00:03:03.610 --> 00:03:05.490
And then we actually do the send.

64
00:03:05.990 --> 00:03:08.710
So here we can control what's going on.

65
00:03:08.730 --> 00:03:09.850
So we send the request.

66
00:03:13.390 --> 00:03:16.130
And we should get a response back once

67
00:03:16.130 --> 00:03:18.950
it's thought about it.

68
00:03:19.250 --> 00:03:21.150
And we got a status 200.

69
00:03:21.390 --> 00:03:21.810
OK.

70
00:03:22.410 --> 00:03:25.170
And we can get the response, which was

71
00:03:25.170 --> 00:03:26.250
also what you saw.

72
00:03:26.730 --> 00:03:31.370
Again, in a little less pretty way of

73
00:03:31.370 --> 00:03:32.450
looking at it.

74
00:03:32.790 --> 00:03:35.610
But we can see that our city equals

75
00:03:35.610 --> 00:03:37.170
Paris is here and so on.

76
00:03:39.110 --> 00:03:42.550
And we can also make that pretty and

77
00:03:42.550 --> 00:03:43.950
let it run.

78
00:03:44.130 --> 00:03:47.950
Because now the second call comes along where

79
00:03:47.950 --> 00:03:50.550
we need to actually use the tool.

80
00:03:51.870 --> 00:03:54.690
And if I just let it run, we

81
00:03:54.690 --> 00:03:57.590
can see in the console what happens.

82
00:03:58.250 --> 00:03:59.850
So we call it the first time.

83
00:04:03.670 --> 00:04:06.490
Let me press the right buttons here.

84
00:04:09.850 --> 00:04:10.930
There we go.

85
00:04:11.490 --> 00:04:16.350
So we saw the call that we saw

86
00:04:16.350 --> 00:04:17.209
in the previous video.

87
00:04:17.310 --> 00:04:18.950
We see the raw response back.

88
00:04:20.250 --> 00:04:22.030
We see the second call.

89
00:04:23.890 --> 00:04:25.770
And the raw response back.

90
00:04:28.710 --> 00:04:33.030
So that is how everything works behind the

91
00:04:33.030 --> 00:04:33.370
scenes.

92
00:04:33.370 --> 00:04:38.150
So I use this quite often when I

93
00:04:38.150 --> 00:04:40.290
need to do some very advanced stuff.

94
00:04:40.390 --> 00:04:41.490
And I can't make it work.

95
00:04:41.570 --> 00:04:43.590
So I can go in and see, OK,

96
00:04:43.970 --> 00:04:47.870
have it actually sent this special extra parameter

97
00:04:47.870 --> 00:04:50.430
I wanted to do or not.

98
00:04:50.950 --> 00:04:54.070
So for very nerdy stuff, it's really, really

99
00:04:54.070 --> 00:04:56.350
interesting that you can do this.

100
00:04:57.910 --> 00:05:01.410
And you can even go in and on

101
00:05:01.410 --> 00:05:06.690
the fly change the requests so you can

102
00:05:06.690 --> 00:05:08.910
do some very, very advanced stuff.

103
00:05:09.130 --> 00:05:11.270
But that's beyond the scope of this.
