Software & Tools AI
0/2 sections
0%

LangChain

LangChain is the most widely used framework for building LLM-powered applications from simple chatbots to complex multi-step agents with memory, tools, and RAG.

Contents 2 Sections

  1. LCEL & Chains
  2. RAG & Agents

1LCEL & Chains

python
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnableParallel, RunnablePassthrough

llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)

# LCEL pipe syntax prompt = ChatPromptTemplate.from_template("Translate to {language}: {text}") chain = prompt | llm | StrOutputParser() result = chain.invoke({"text": "Hello world", "language": "Spanish"})

# Parallel execution parallel = RunnableParallel( summary=ChatPromptTemplate.from_template("Summarize: {text}") | llm | StrOutputParser(), sentiment=ChatPromptTemplate.from_template("Sentiment of: {text}") | llm | StrOutputParser(), ) result = parallel.invoke({"text": "The product was great but shipping was slow."})

# Streaming for chunk in chain.stream({"text": "Hello", "language": "French"}): print(chunk, end="", flush=True) ```

2RAG & Agents

python
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
from langchain_community.vectorstores import Chroma
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.document_loaders import WebBaseLoader

# Load and embed documents loader = WebBaseLoader("https://docs.example.com") docs = loader.load() chunks = RecursiveCharacterTextSplitter( chunk_size=1000, chunk_overlap=200 ).split_documents(docs)

vectorstore = Chroma.from_documents(chunks, OpenAIEmbeddings()) retriever = vectorstore.as_retriever(search_kwargs={"k": 4})

# RAG chain from langchain import hub prompt = hub.pull("rlm/rag-prompt")

rag_chain = ( {"context": retriever, "question": RunnablePassthrough()} | prompt | ChatOpenAI(model="gpt-4o-mini") | StrOutputParser() ) answer = rag_chain.invoke("How do I configure authentication?")

# Agent with tools from langchain.agents import create_openai_functions_agent, AgentExecutor from langchain.tools import DuckDuckGoSearchRun

tools = [DuckDuckGoSearchRun()] agent = create_openai_functions_agent(llm, tools, prompt) executor = AgentExecutor(agent=agent, tools=tools, verbose=True) executor.invoke({"input": "What is the current NVIDIA stock price?"}) ```

Explore the Full Portfolio

This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.

The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.

For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.