From the course: Building Apps with AI Tools: ChatGPT, Semantic Kernel, and Langchain

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Building a simple prompt chain with LangChain

Building a simple prompt chain with LangChain

- [Speaker] LangChain is currently one of the most popular open source libraries, with over 50,000 GitHub stars. It makes it easier to build AI applications. So let's get started. I'm going to head over to my code spaces and check out branch 04 01b. Now, let's install LangChain. I'm going to click on requirements and see that we have our version of LangChain here. Let's open up a terminal and make sure that it's installed. So I'm going to cd into source and do my pip install -r requirements. Okay, there we go. We've installed LangChain. Now, let's go ahead and open up our main file. So we have a first import here, importing ChatOpenAI. So this uses ChatGPT or GPT-4. Now let's go ahead and start building our first chain. So let's go ahead and type out chat_model = ChatOpenAI. So this allows us to import our first chat model. Now I'm going to print chat_model.predict. I'm going to print, "hi". This…

Contents