Skip to content

CodeUltr0n/LangChain-ai-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangChain Agentic AI

A hands-on crash course for building AI agents with LangChain — from basics to middleware, tools, structured output, and human-in-the-loop workflows.

Python LangChain Groq Google AI License



Table of Contents


Overview

This repository is a structured learning path for LangChain's agentic AI capabilities. Each notebook walks through a core concept with runnable examples — from sending your first message to building agents with human-in-the-loop safeguards.

Whether you're new to LangChain or looking to understand middleware, tools, and structured outputs, this repo gives you copy-paste-ready code with explanations.


Topics Covered

Topic Description
Model Integration Connect to Groq, Google Gemini, and other LLM providers
Messages System, Human, and AI message types and conversation flow
Tools Define and bind custom tools for agent function calling
Structured Output Get typed, schema-validated responses from LLMs
Middleware Summarization, token management, and execution control
Human in the Loop Pause agent execution for human approval, editing, or rejection

Project Structure

langchain-agentic-ai/
├── main.py
├── pyproject.toml
├── requirements.txt
├── README.md
└── updatedlangchain/
    ├── langchainintro.ipynb        # LangChain basics
    ├── messages.ipynb              # Message types & roles
    ├── modelIntegration.ipynb      # LLM provider setup
    ├── structuredoutput.ipynb      # Schema-validated outputs
    ├── tools.ipynb                 # Tool binding & calling
    ├── middleware.ipynb             # Summarization middleware
    ├── api-integration-guide.md    # API setup reference
    ├── structured-output-notes.md  # Structured output cheat sheet
    ├── tools-notes.md              # Tools cheat sheet
    └── human-in-the-loop-notes.md  # HITL explanation

Setup

# Clone the repo
git clone https://github.com/<your-username>/langchain-agentic-ai.git
cd langchain-agentic-ai

# Install dependencies
uv sync

# Add new dependencies
uv add <package-name>

Environment Variables

Create a .env file in the project root:

GROQ_API_KEY=your_groq_api_key_here
GOOGLE_API_KEY=your_google_api_key_here

Note: Use underscores (_) in env variable names — Python's os.getenv() can't read hyphens.


Notebooks

1. LangChain Intro

Getting started with LangChain — model invocation, prompts, and chains.

2. Messages

Understanding SystemMessage, HumanMessage, and AIMessage — how conversation context flows through the agent.

3. Model Integration

Setting up LLM providers:

  • Groqgroq:llama-3.3-70b-versatile, groq:qwen/qwen3-32b
  • Google Geminigoogle_genai:gemini-2.0-flash

Always use the provider prefix (e.g., groq:, google_genai:). Auto-detection fails for non-OpenAI models.

4. Tools

Define custom functions with @tool decorator and bind them to agents for function calling.

5. Structured Output

Get typed Pydantic models back from LLMs instead of raw text.

6. Middleware — Summarization

Automatically compress long conversation histories to reduce token usage:

  • Message-based trigger — summarize after N messages
  • Token-based trigger — summarize after N tokens
  • Fraction-based trigger — summarize after X% of context window

7. Middleware — Human in the Loop

Pause agent execution before sensitive operations:

  • Approve — let the agent proceed
  • Reject — block the action
  • Edit — modify arguments before execution

Tech Stack

Component Technology
Framework LangChain 1.3+
LLM Providers Groq, Google Gemini
Agent Runtime LangGraph
Language Python 3.13+
Package Manager uv

Media

Screenshots

Coming soon

Demo Video

Coming soon


License

This project is licensed under the MIT License.


Built with LangChain

About

Building AI agents with LangChain — tools, middleware, structured output, and human-in-the-loop workflows

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors