LangChain Agents: Simply Explained!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to have a closer look at langtune agents and understand what agents are all about first we're going to dive into what an agent is and understand how agents work under the hood of link chain then we're going to have a look at what we can do with agents that we couldn't do before and some of the future indications for businesses that are already investing in technology data and analytics and finally I'm going to show you how to get started building your own custom agents I'm going to have gbt4 access data from an external API and you can use this example as inspiration for building other types of Agents in order to understand what a lang chain agent is and what we can do with an agent let's have a look at an example suppose you're building a chat bot for an e-commerce business this could really be any type of b2c business but e-commerce is easy to understand right now businesses around the world are already using GPT 3.5 and gpt4 to build chatbots we know that gbt4 has great general knowledge but it's severely lacking when it comes to your own data gbt4 does know anything about your products for instance we have seen in earlier videos how we can solve this using Lang chain and Vector storage we slice and dice the product data and put that into a database like Pine Kona redis and then we have the language model access that data so now the chat model knows about your products which is better than before but it's still not good enough because what does a chatbot really need to know in order to give the customers a good customer experience the chatbot needs to know stuff about the customer if this chatbot is on a web page it needs to know the context of the visit and this could be information like is this a new potential customer or an existing customer or what is the browsing history of this visitor what products do we recommend based on purchase history or browsing history all this information needs to be made available to the chatbot at runtime and this is information that will help a language model with the customer interaction and ultimately help the business convert the customers and generate more sales this information can be made available to the chatbot for the language model through microservices by letting the language model access these resources of computation and information through apis in Lang chain connectors to apis and computational resources are called tools and agents are what we get when we combine a language model with one or more tools by combining a language model with a set of tools we are empowering the language model to solve specific problems much in the same way that a regular person would use tools like python Excel or data tables with information to solve a specific task in the last video we saw an example of a link chain agent when we communicated with the sapier natural language action API in order to send out personalized emails based on product reviews if you've played around with the CPI example or any other agent one thing you might have noticed is the way an agent is going about solving a specific task it continuously Loops through steps of action observation and thought and this is the way that the type of agent that we used in the Savior example is built the logic behind the agent comes from the react framework which essentially means that we enable the language model to take actions in the form of text and verbally reason about those actions in an interleaved manner the actions lead to feedback in the form of observations and the so-called reasoning traces affect the internal state of the model to support future actions and future reasoning the react framework is what powers a zero shot react description agent and the react doc store agent in link chain and if you take a look at the base agent class you can see how this framework is being implemented if you are interested in learning more about the react framework I suggest that you take a look at the paper I'll put a link to that below as well as the accompanying blog post by the Google brain researchers behind the paper so let's zoom out for a moment to understand why Lane chain agents are such a big deal we can list out the different channels a business users to communicate with their customers or potential customers and we have five main channels so the five main ways businesses communicate online with the customers are through paid and social media their web page chats email and SMS the online customer experience is primarily created in those channels and is controlled by text images and video the text part can be generated by language models and businesses already working on using chat gbt for this the images in the video will also be created by Ai and companies are now working on using mid-journey stable diffusion and control net for this let's forget about the images and video part for now we'll get back to that in later videos and just focus on the language modeling we talked about before that the language models don't know enough about the customers in order to create a good customer experience in order to create a good custom experience the language models need to access customer data both the raw customer data and the processed customer data that comes out of analytical services so we need to get the language model access to churn and retention scores to segmentation models to product recommendations and to customer Journey Analytics unfortunately companies have been developing these services for five to ten years now and these analytical Services can now serve as tools for language models so we get to connect the old world of analytics which is not really old with the new world of AI using Lang chain and agents so now let me show you how easy it is to get started building custom agents that allows us to do stuff like this I'm going to take a python function that can extract any type of data from the Shopify API and turn that function into a tool and then I'm going to create an agent out of this tool and gpt4 and this agent allows us to have a language model interact with the Shopify API in order to write the code for this example we're going to need the Shopify API python Library we need Lang chain openai pandas and Dot dnv access tokens are put in an environment file and I'm going to put a link to a notebook with the code below this video the first thing we're going to do we're going to load the needed libraries I'm going to load the environment variables and here we have the python function that will extract the data from the Shopify API it takes an object name as input that could be customers orders and products and it extracts 250 items I've already covered how you get the access token to extract the data from Shopify in an earlier video I'll put a link to that video below this one and let me just show you how it works I'm going to extract some customer orders using the order object and I could do the same thing for customer or product or anything that the rest API allows me to retrieve and our goal is now to check this function and turn it into a tool that we can use to create an agent and to do that I'm going to import structured tool from language and I'm also going to import chat of May I and instantiate gpt4 now I'm going to take the kit data function I'm going to wrap it in a function that takes a string as an input and returns a string I call this function get Shopify insight and then I use structure tool to create a tool out of this python function and this tool can now count the number of items returned as a string for each of the Shopify objects you're trying to extract and we can call this tool with any of the objects in the same way we can call a function so we can call it with order or customer product and it will return the number of items the string and now we have everything we need to define the agent and the language model in this case gpt4 will seek to infer what it needs to do with the tool from the signature of the function so we're going to Define an agent Chain by initializing the agent with the tools in this case just one tool the chat model and the agent type and now we can ask gbt4 to count the number of orders customers products or whatever in the Shopify store and again we see the react framework behind the agent the agent takes an action there's an observation and a thought after the observation and we see that it actually counts the number of items for this particular object in this case the number of orders and we can do the same thing for customers or anything that the Shopify API allows us to retrieve so pretty basic example but this was just to show how you take a python function that manipulates something or extract something from an API combine it with a language model like gpt4 and turn that into an agent and of course this is going to get a lot more interesting once we start developing some really good tools for the language models that's it for now if you enjoyed this video like And subscribe thanks for watching
Info
Channel: Rabbitmetrics
Views: 34,830
Rating: undefined out of 5
Keywords: langchain, langchain chatgpt, langchain own data, hugging face, gpt 4, cx analytics, langchain openai, large language models, pinecone, hugging face models, llm explained, langchain in python, langchain ai, langchain prompt, langchain agent, embeddings, vectore store, customer experience analytics, langchain tutorial, marketing analytics, copywriting, zapier, zapier automation, zapier nla
Id: Xi9Ui-9qcPw
Channel Id: undefined
Length: 9min 34sec (574 seconds)
Published: Fri May 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.