Azure OpenAI in LangChain: Getting Started

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we're going to take a look at how we can use LINE chain with openai in azure now for those of you that don't know open AI can be accessed in one of two ways either through the openai API directly or via the Azure version of open ai's API now I'm going to show you how to do all this within Lang chain so we can have Lang chain open Ai and Azure so the first thing that we're going to do is head on over to portal.azure.com you will naturally need an Azure account if you don't already but once you have set that up all you're going to do is head on over to your subscriptions make sure you have a subscription you may need to create one so add a subscription there mine is called development and testing so okay I know that is there then I'm going to head over to Azure open AI if you can't find any of this stuff you can actually just go up here and type it in okay you may also need to create that resource but once you have it Azure open AI you come over here and we already have a deployment down here but what I'm going to do is create a new one so we can go from start to finish so we're going to create a new deployment I'm going to use that subscription that I showed you earlier I'm going to use a resource Group so you may also need to create a resource route you can click create new if you don't have one already and I'm going to go to instant details the name will be call it YouTube demo all right pricing tier a standard s0 and we can go on to next okay now here you just set up your security network security items for me I'm just going to go with all Networks tags so this is naturally if you have many people and categories on your Azure instance I I'm not going to do that okay and once you do not you have the times you just go down to create okay you will have to wait a minute while that is deploying and once it has deployed you'll get this your deployment is complete from here we want to go to I'm not sure the best way but I'm going to go to home I'm going to go back to Azure open Ai and you'll be able to see your new resource or deployment in there so I'm going to click on that deployment and there's now a few things that we need to grab from here okay so we have the end point so let's copy this I'm going to go to this notebook so you'll be able to find your own version of this notebook linked near the top of the video right now or if not in the video description so I'm going to come down to here and you see that we have this openai API base right that is that's the end point so I'm going to replace that with what I just pasted from the endpoint so YouTube demo AI azure.com I also need the open AI API version right now the one of the most up-to-date versions what version I'm using at least is this so there might be more recent versions but that's it works right now so I'm using that we want to set the open AI API type which is azure and we also want to set the open AI API key right so where do we get that we want to come over to keys and endpoint and we just copy this okay and we just paste it into here so once we have our items there what we now need to do is we want to go to Azure open AI Studio let's open that and this is one of the main differences between the default version of open Ai and the Azure version of openai with Azure or actually with the default version we would just call the model endpoints we would say okay we want to use gft4 and we do that you can't do that with the Azure version you actually need to create a deployment for every model that you'd like to use so you'd come over to create new deployment and you see I currently have no deployments okay this is how I'm going to create a new one I'm going to choose a model so we have a few here um let's go with a tube G4 model version we can let's use the default and deployment name so this is the deployment name that you will use within line chain to connect to this deployment right so it needs to be unique I don't currently have any other deployments so I can call it whatever I want essentially so I'm going to call it chat endpoint okay let's create that okay so I now have chat endpoint so I'm going to come over to the code again I'm just going to run the PIP install up at the top here then I'm going to come down to here so I have deployment name I need to change this because I called it chats endpoint so we have the Jam point is our deployment name we have our model name which aligns to our deployment over here now if we try to run this straight away we'll get an error it won't work so after waiting a little while it will work as we can see here so for this it took sort of three to four minutes for that to actually deploy now what we've done here is we're using a chat model so when we're using chat model we use LINE trains system meshes human message and AI message to create that sort of chat log so we initialize it with the system message then we basically system message just tells the model how to behave okay so I'm saying that it's basically it's an AGI but it cannot answer any questions about cheese because it just doesn't understand cheese as a concept okay so we can ask it like hey how are you doing today what is the meaning of life and it's going to respond you know it's really typical like as an AI I don't have emotions or personal experiences so and so on but I'm here to help and then it gives you kind of a generic meaning of life answer okay cool so after that we want to take this message the AI message and append it to our messages okay and then we can feed that back into the model so I'm going to take all those interactions so far and I'm going to ask you another question can you give me one concrete example of one of these interpretations so interpretations that's a very I'm not specifying what exactly I want to know about in that query in order for that to work it has to rely on the previous messages Associated you need to take a look at this but because it's a chat model and because we appended the response to those messages it will understand that we're asking about the interpretation of something around here so we're saying what are the interpretations of the sort of meaning of life that people have been debating for centuries okay so in order to answer that it needs to have some of that conversational history which it does so we asked that question okay and we get this so one concrete example of an interpretation meaning life is found within the philosophy of existentialism and yeah it's like it's a pretty good kind of like meaningful answer I think so that's great it's working as an expert AGI now just to confirm that it is still considering it's a system message that we initially set it up with we can say okay something really simple what is the color of cheese so we can ask that and it says as an Adria system I'm unable to provide any information related to cheese I apologize for the inconvenience and so on and so on right so it's it's considering all those previous messages so everything seems to be working and we have rather than use the typical open AI API endpoints we're doing this through azure's like opening eye offering so everything seems to be working that looks good and that is exactly what I wanted to show you in this video so that is it for now I hope this has been useful and interesting so thank you very much for watching and I will see you again in the next one bye foreign
Info
Channel: James Briggs
Views: 6,494
Rating: undefined out of 5
Keywords: python, machine learning, artificial intelligence, natural language processing, nlp, azure openai, azure openai demo, azure openai chatbot, azure openai langchain, langchain, langchain tutorial, langchain chatbot, azure openai setup, azure openai service, openai, azure, microsoft azure, azu, azure gpt, azure gpt 4, langchain agent, langchain chat gpt, chatgpt, chatgpt 4, large language model, openai gpt 4, gpt-3.5-turbo, gpt-4, gpt 4, gpt 3.5, gpt 4 tutorial, gpt 4 python, chatbot
Id: Cgyz7NNuV1M
Channel Id: undefined
Length: 9min 23sec (563 seconds)
Published: Wed Aug 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.