Posts

Subscribe to Youtube channel

Working with Langchain and google Gemini Integration step by step

Image
 In this article I am going to explain about how can we use Gemini AI model with Lanchain library in python by step by step. The langchain is powerful library framework by using it we can develop LLM app easily.     Prerequisites for this example is as follows: Visual studio code Python Api Key of Gemini can be obtain from https://aistudio.google.com    Open visual studio code and create the file with name "langchainexample.py" and add below code in the file.Now in visual studio code and go to terminal menu and click on New terminal link it will open new terminal. In terminal enter below command to install the Langchain library for google gen ai in your machine. pip install langchain-google-genai Now add below code in the "langchainexample.py" file. from langchain_google_genai import ChatGoogleGenerativeAI apikey="your api key" inputstr="" llm=ChatGoogleGenerativeAI(model="gemini-pro",google_api_key=apikey) while inputst