Langchain is a framework for developing AI powered applications using language models . There are many modules available in langchain which helps us to build a AI powered application which can be deployed in production too with less code change.
Langchain offers many modules to build an AI application which helps you to store your own data vector store by embedding them and query them and pass it to an LLM to generate or answer your query . we will see all the modules one by one .
Some of the modules are
- Model I/O
- Retrieval
- Chains
- Agents
- Memory
- Callbacks
- Chatbots
- Answering question from your own data
- Analyzing the data and give insights
- many more are there
pip install langchain
To install all the modules related to langchain , use the below command
pip install langchain[all]
We will see a simple example to see how to use an openai api to generate a text , to start using openai api , we need to install the openai package from pypi .To do so
pip install openai
There are two ways we can utilize the generated api key ,
- Setting up the API key as an environment variable
- Pass API key as a parameter to OPENAI LLM class
To use openai , we need to an api key you can get it here . after generating the key you have to set it at as environment variable by
export OPENAI_API_KEY="your_key"
Method - 2
pass the generated key as "openai_api_key" as a named parameter
from langchain.llms import OpenAI