Part 1: Getting Started with Langchain

·

2 min read

What is Langchain:

LangChain is a framework for developing applications powered by large language models (LLMs).

What is large language model:

A large language model (LLM) is a type of artificial intelligence (AI) program that can recognize and generate text, HAHAH you already interacted with LLMS, I bet you used ChatGPT!

Bigger Picture:

Langchain is a Python and JavaScript Framework designed to simplify the process of developing applications that leverage large language models (LLMs). It provides a set of tools and abstractions that help developers.The library supports multiple LLM providers like OpenAI, Anthropic, and others, making it a flexible framework for AI application development

Getting Hands-Dirty with Langchain:

Before we install and start using Langchain, we need API Keys for the LLMs we are going to use, it is up to use whatever LLM You want, OPENAI, Anthropic, Groq…ext

Installing Langchain:

Once you get your API KEY, we can continue and install langchain, for each LLM langchain has a library.

To install it for OpenAI:

 pip install  langchain-openai

To install it for Anthropic:

pip install langchain-anthropic

As you can see it support a wide range of LLMs!! See More in: Providers | 🦜️🔗 LangChain

Basic Usage: Using Langchain With OpenAI:

In this simple example we going to interact with OpenAI LLM:

First Export Your OpenAI API KEY via the CLI/Powershell:

# Linux Cli
export OPENAI_API_KEY=your-key
# Windows Powershell
$env:OPENAI_API_KEY = "your-key"

Once that is done, we can start interactig with OpenAI LLM:

# We Import ChatOpen AI
from langchain_openai import ChatOpenAI
# we init a llm instance
model = ChatOpenAI(model="gpt-4o")
# we invoke on it
model.invoke('Hello, There')

This is similar to:

More is Coming Soon:

  • Job search and Matcher based on a user upload resume: This Application let the user upload his/her resume, and then it goes out to the internet looking for matching jobs with the user’s skills

  • Network Automation With AI: This Application, allows the user to connect and configure network devices using natural languages, eg: ‘i want OSPF to be configured with process 1 and router id 1.1.1.1 and advertise 192.168.1.0/24 on area 0‘

  • and much more!