WEBVTT

00:00.240 --> 00:01.560
Hi there Eden here.

00:01.560 --> 00:07.200
And in this video we're going to be integrating lengths tracing into our application.

00:07.200 --> 00:08.640
So we're going to configure lengths.

00:08.880 --> 00:13.400
And we're going to review all of the traces of the chains we invoked.

00:13.920 --> 00:15.320
So let's go to the code.

00:16.920 --> 00:17.640
Alrighty.

00:17.640 --> 00:22.200
So let me go now to my browser and let me search for Link Smith.

00:25.440 --> 00:29.960
And let me go now and click this link here and let me sign up.

00:29.960 --> 00:32.000
So I already have an account here.

00:32.000 --> 00:33.640
So I don't need to sign up.

00:34.120 --> 00:36.560
And you can simply sign up yourself.

00:36.560 --> 00:37.600
It's very, very easy.

00:37.840 --> 00:40.120
You might need to put some credit cards.

00:40.120 --> 00:45.800
However, you do get a very nice free tier, which is going to be more than enough for this course.

00:48.240 --> 00:52.440
So here in this dashboard we can see we have a button set up tracing.

00:52.440 --> 00:54.000
And let me go and click that.

00:55.200 --> 00:57.920
And the steps to do it are pretty straightforward.

00:57.920 --> 01:00.840
We first need to install link chain which we already have.

01:01.120 --> 01:02.840
We need to generate an API key.

01:02.840 --> 01:03.940
And this is the first step.

01:03.940 --> 01:06.700
We'll click this button later and we'll get API key.

01:07.020 --> 01:10.260
And then we need to set some environment variables.

01:10.260 --> 01:12.900
We need to set up the links with tracing to be true.

01:13.060 --> 01:20.100
And we have the link Smith underscore endpoint environment variable which the default points to the

01:20.140 --> 01:21.300
US endpoint.

01:21.300 --> 01:26.980
So if you're in the US like I am in this video then you do not need to set this environment variable.

01:27.020 --> 01:34.580
However, if you are outside the US then you need to set up this environment variable to point to the

01:34.620 --> 01:35.620
EU region.

01:35.620 --> 01:40.540
So it's going to be the same URL, but you're going to have this EU prefix in the beginning.

01:40.820 --> 01:45.820
Now if you're outside the US, it's very important for you to set up this environment variable.

01:45.860 --> 01:51.260
Because if you won't do it, you'll be getting an authentication error when trying to run the code.

01:51.300 --> 01:58.180
When link is going to try and trace your application, we need to supply the link Smith API key and

01:58.180 --> 02:01.060
we need to give it the Link Smith project.

02:01.060 --> 02:04.540
So the Link Smith project is a string that we're going to create.

02:04.540 --> 02:09.210
And that string is going to be the project, which is going to be holding all of our traces within the

02:09.210 --> 02:12.850
length of its platform, and we'll simply call that Hello World.

02:13.290 --> 02:19.330
And after we do that, all we need to do is to use the regular Lang chain objects and we will get out

02:19.370 --> 02:20.810
of the box tracing.

02:21.490 --> 02:24.250
So let's go and let's do all of those steps.

02:24.370 --> 02:27.010
So let me go now and click to generate an API key.

02:29.930 --> 02:31.130
Let me copy it.

02:31.130 --> 02:36.730
And now let me go back now to my env file with all of my environment variables.

02:36.730 --> 02:39.450
And here I'm going to fill up those values.

02:39.890 --> 02:43.450
And my links with tracing environment variables is going to be true.

02:43.610 --> 02:46.570
And notice I didn't write here any quotation marks.

02:46.570 --> 02:48.490
So it should work without them.

02:48.850 --> 02:54.170
I put my links with API key and don't worry, it's going to be revoked very, very soon after I finish

02:54.170 --> 02:54.810
this video.

02:55.050 --> 02:58.930
And now we have Link Smith's project, which is going to be Hello World.

02:59.250 --> 03:00.250
And that's it.

03:00.250 --> 03:02.530
This is the entire Link Smith integration.

03:02.730 --> 03:08.310
So now when we're going to go and run our chains we're going to automatically out of the box.

03:08.310 --> 03:09.110
Trace them.

03:09.910 --> 03:12.270
So let's go now to the main.py file.

03:12.470 --> 03:14.390
And now let me run it again.

03:18.110 --> 03:19.790
So it's running in debug.

03:19.790 --> 03:21.110
So let me continue the run.

03:21.390 --> 03:24.590
And after it finished running let's go now to length Smith.

03:24.630 --> 03:25.950
Let's refresh the page.

03:31.470 --> 03:34.590
And we can see now our new project hello world.

03:34.590 --> 03:37.150
And here we have a runnable sequence run.

03:37.470 --> 03:41.190
And here we can see our execution of what we ran.

03:41.390 --> 03:44.030
We can see this is a runnable sequence.

03:44.510 --> 03:48.430
We can see here our call to chat Olama to Jama three.

03:48.550 --> 03:51.590
Here we can see this is the input as a human message.

03:51.710 --> 03:54.910
And the output we got is as an AI message.

03:55.270 --> 03:57.910
And on the right side we can see the start time.

03:57.910 --> 03:58.830
End time.

03:58.830 --> 04:03.870
How much did it take to get the first token which is very important for some application.

04:04.190 --> 04:10.970
The status, whether this request was a success or not, and the total amount of tokens that were used

04:10.970 --> 04:11.770
in this chain.

04:12.010 --> 04:17.890
And if we want, we can totally customize this and add here tags so we'll be able to filter it later.

04:18.370 --> 04:18.890
Alrighty.

04:18.890 --> 04:21.850
So now I want to focus on this thing over here.

04:21.850 --> 04:24.850
And here we can see the link chain objects.

04:24.970 --> 04:30.330
Now this runnable sequence over here is comprised of first using the prompt template.

04:30.330 --> 04:38.650
So to format the string and then to take the output of the prompt value and to plug it in to chat and

04:38.650 --> 04:39.210
send it.

04:39.370 --> 04:40.890
So this is what we see right here.

04:41.450 --> 04:41.930
All right.

04:41.930 --> 04:46.850
So let's go back to the code and let's go and use GPT five here.

04:47.010 --> 04:52.010
So let me comment out this line here and let me uncomment the line from before.

04:59.050 --> 04:59.570
All right.

04:59.570 --> 05:01.450
Let me go and run this again.

05:02.530 --> 05:05.610
This time let me simply run the Python file.

05:06.890 --> 05:10.010
Now this is going to take longer because we're using GPT five.

05:10.250 --> 05:12.830
So let me go now and fast forward it.

05:14.350 --> 05:16.070
We can see we got a result.

05:16.070 --> 05:19.070
So let's go now to let me refresh it.

05:19.750 --> 05:21.870
And now we can see our second run.

05:21.910 --> 05:24.270
This time it took 16 seconds here.

05:24.910 --> 05:29.030
And you can see on the left side that we use GPT five here.

05:34.550 --> 05:35.670
All right let me go.

05:35.670 --> 05:39.590
Now back to the previous view of all of the traces.

05:40.750 --> 05:43.590
And in this view we can see all of the traces.

05:43.590 --> 05:47.190
And we can filter for only calls for all the runs.

05:47.190 --> 05:48.870
We can filter here by tag.

05:49.230 --> 05:55.430
We get here some stats like error rates like the median tokens like the P90 and P50.

05:55.670 --> 06:02.270
And I genuinely think that Smith is one of the best, if not the best trading platform from LM based

06:02.270 --> 06:07.550
applications, and we are really going to see the value of it in future videos where we're going to

06:07.550 --> 06:13.710
be implementing agents, where it's going to be super convenient and super natural to check out our

06:13.870 --> 06:15.180
agent execution.

06:15.540 --> 06:21.380
Alrighty, so the traces I showed you in the video, I'm also going to link them in the videos resources.

06:21.500 --> 06:23.460
And yes, you can share traces.

06:23.460 --> 06:26.700
You can make them public and get a shareable link.

06:26.860 --> 06:28.340
So that's what I'm going to do.

06:28.540 --> 06:32.300
And let's go now to the code and let's go and commit everything.

06:32.300 --> 06:35.980
And I will show you where you can find everything we did now in this section.

06:36.340 --> 06:36.820
All right.

06:36.820 --> 06:37.780
So let me go.

06:37.780 --> 06:41.980
And right in the terminal git status to see all the files that we changed.

06:47.500 --> 06:49.780
And let me add main.py file.

06:50.180 --> 06:52.220
Let me go and create a new commit.

06:52.220 --> 06:54.780
And let me call it hello World Chain.

06:55.100 --> 06:57.500
And I'm going to push it to the repo.

06:59.140 --> 07:01.500
Now let me go to the repository.

07:03.500 --> 07:07.300
And here let's take a look at the branched projects that shallow worked.

07:07.340 --> 07:08.660
Let's go to the commits.

07:08.900 --> 07:12.740
And here we have the commit of everything we just wrote.

07:14.380 --> 07:17.180
We'll also be sharing a direct link to this in the videos.

07:17.180 --> 07:17.980
Resources.
