So guys, we are going to continue the discussion with respect to Lange chain and hugging face integration.
Um, in this video I'm going to show you an end to end project with the help of hugging face endpoint.
Uh, if you remember, guys, uh, previously, uh, there was one amazing, um, end to end projects
that we had actually created.
Right?
And if I talk about that specific project, it was about text summarization, where we were specifically
using a YouTube URL or any website URL.
It was able to summarize the entire text and give it to us, right?
So I hope everybody remembers this.
If you don't remember it, don't worry.
I have copied the same content inside my ninth folder hugging face with lang chain in my app dot Pi.
Okay, so let me just go ahead and run this quickly and then we will see that how we can.
And over here you can see that I'm calling grok API key.
And the model that is specifically used is uh gamma seven B.
Right now instead of using gamma seven B, what I will do is that I will use my model from hugging face.
Right.
And that is also the same model that we used it over here, right, in which we discussed in our previous
video.
So let's first of all go this go and see this particular demo.
So I am in my ninth hugging face with Lang chain folder.
I will go ahead and right Streamlit run app dot pi okay so let's go ahead and see this.
So here you will be able to see that.
Fine.
Uh this is my entire model.
Or let me just copy this quickly and let me go back to my page over here.
I will try to load it.
Okay.
So here is my entire page here.
First of all, it is asking me for the grok API key.
So I will go ahead and take my grok API key which is present in my env file.
Sorry, grok API key, not a token, but grok API key is required.
So I will go back over here, copy and paste it and press enter.
Okay.
Then I will take this particular URL okay AI versus ML versus generative AI.
This is my video in my YouTube channel just to test it out.
And I'll paste this link over here and I'll say, hey, summarize the content from the YouTube or website.
And remember, right now we are using gamma two model from the um, from the API itself, from the grok
API.
And here you can see the entire output.
Similarly, if you go ahead and see, uh, any other website page, right.
Like let's say docs underscore dot dot dot lang chain.com.
If I'm giving this particular URL in my summarize URL.
And if I say to summarize the content from the YouTube or website, you'll be able to see that I'm able
to get the entire summary.
Okay, so this is perfectly fine till here.
I think you'll be able to get it right.
So all the information is there.
Now, instead of using this grok API and Google Gamma two model, I will try to use Huggingface endpoint
again.
It is completely for free.
Uh, with respect to some of the models that we have.
Okay.
So I will go over here, go back to my API.
I will just close this because I don't want it right now okay.
And let's see what all changes I will do over here.
First of all you you'll be seeing that this all will be same, right?
First of all, I will go ahead and change this API.
Right.
Instead of writing grok API key, I will say, hey, uh, hugging face API token.
Okay, I'll, I'll say provide my hugging face API token.
Okay.
And I will write HDF over here.
Okay.
So first thing is this then uh, you'll be able to see that I will also make sure that I will comment
out this particular code, because LM model I need to call with respect to that.
Now, if I really need to call the LM model from hugging face endpoint, I need to import this library
from long chain underscore hugging face so quickly I will go over here.
I will import it over here okay.
Once I import it uh, now it's time that I should be calling my hugging face API.
And let me just do one thing.
Let me also make sure to put this particular condition over here for my API, hf underscore API.
So I'll say if HF underscore API dot strip uh and here I'm using lm so lm now I have to create.
Right.
So I will go over here I have commented out this particular LM and instead of writing like this I will
go to my experiment page.
And you know that how I have called this.
Right.
So I will just copy this entire thing like Mistral seven B and all.
I will paste it over here.
That's it.
That is the change.
So simple right now.
Your task will be that whatever end to end projects we have created, right?
Just try to see whether we are having something or not related to this right now.
Inside this token, you will be able to see that I'm calling OS dot get env right h f underscore token
right.
So this particular token needs to be replaced with whatever token I am going to get.
So this is nothing, but it will be a hf API key, right?
Whatever token I will be getting from my website.
That's it.
Right?
This is so simple.
That's it.
Right.
And here you have actually done that change this entire model where you have calling this particular
LLM model from the API with the help of API itself.
So now let's go ahead and execute this.
I'll say Streamlit run App.py.
And now, finally, you can see that I've executed it.
Now let's do the same thing.
I will take this.
Now.
My LM model is completely changed.
Before that, I'll just go ahead and put my hugging face API token.
It is present over here in my env file.
And here I will go back.
I will paste it over here.
Okay, now let's try the same YouTube URL.
The content will be different when compared to Google Gamma two.
Because Google Gamma two is a much better model.
It is a huge 9 billion parameters, right?
And this is just a smaller model that we have.
But it is also a very good model.
So here you can see in this video Kushner discusses the differences.
It says Kushner okay.
Whenever I say crush it assumes crush okay.
And all the information is there with respect to the summary, the same thing.
What I will do, I will also do it for this particular website.
And here easily you could see that okay, so beautifully we are able to do all these things right now.
I'll go ahead and summarize the content.
Any page.
You should be able to summarize it in a much more easy way.
Right.
So again this model somewhat time it is taking.
But now you can see this entire information.
Right.
right?
So yeah, this was it from my side.
This was with respect to Lang Chen and Huggingface.
I hope you like this particular video.
And now one of the tasks that I really want to give, go ahead and explore other projects and try to
integrate with Huggingface endpoint with using any models that you really want.
Okay.
See what kind of issues you face and then you can probably proceed ahead with that.
So yes, this was it from my side.
I hope you liked this particular video.
I will see you all in the next video.
Thank you.
Take care.
Bye bye.