This repository is a hands-on learning project for LangGraph, LangChain, and Gemini-powered agents. It starts with small graph concepts, then builds up to practical agents that can chat, remember conversation history, call tools, and retrieve information from a PDF.
- Defining graph state with
TypedDict - Creating LangGraph nodes as normal Python functions
- Connecting nodes with normal edges
- Routing execution with conditional edges
- Building loops inside a graph
- Passing multiple values through state
- Calling Google Gemini models through
langchain-google-genai - Keeping manual conversation memory
- Binding tools to an LLM
- Building a ReAct-style tool-using agent
- Building a RAG agent with PDF loading, chunking, embeddings, Chroma, retrieval, and tool calls
.
├── Agent1/
│ └── simple_llm_bot.py
├── Agent2/
│ └── manual_memory_agent.py
├── Agent3/
│ └── ReAct_agent.py
├── Agent4/
│ ├── RAG.py
│ └── Stock_Market_Performance_2024.pdf
├── LangGraph_concepts/
│ ├── hello_world_agent.py
│ ├── processor_multiple_inputs.py
│ ├── mutliple_nodes_sequential_agent.py
│ ├── operation_selector.py
│ ├── conditional_edges.py
│ └── looping_graph.py
├── pyproject.toml
└── README.md
LangGraph_concepts/hello_world_agent.py introduces the smallest possible graph: one state type, one node, one compiled graph, and one invocation.
LangGraph_concepts/processor_multiple_inputs.py shows how a graph state can carry multiple inputs, such as a name and a list of numbers.
LangGraph_concepts/mutliple_nodes_sequential_agent.py demonstrates sequential node execution. Each node updates the same state and passes it to the next node.
LangGraph_concepts/operation_selector.py shows how one node can choose behavior based on a value in state.
LangGraph_concepts/conditional_edges.py demonstrates conditional routing between different math nodes.
LangGraph_concepts/looping_graph.py demonstrates a graph loop with a guessing game that keeps running until a condition is met.
Agent1/simple_llm_bot.py is a simple Gemini chat bot. It wraps a single LLM call inside a LangGraph node and runs in a terminal loop until the user types exit.
Agent2/manual_memory_agent.py extends the simple bot with manual memory. It stores HumanMessage and AIMessage objects in a Python list and passes the full conversation back into the graph on every turn.
Agent3/ReAct_agent.py is a ReAct-style tool agent. The LLM can request math tools, LangGraph routes to a ToolNode, and the model receives tool results before producing the final answer.
Agent4/RAG.py is a retrieval-augmented generation agent. It loads a stock market PDF, splits it into chunks, embeds those chunks with Google Gemini embeddings, stores them in Chroma, exposes retrieval as a tool, and lets the LLM answer questions using retrieved document context.
Install dependencies with uv:
uv syncCreate a .env file in the repo root:
GEMINI_API_KEY=your_google_gemini_api_keyThe .env file should stay local and should not be committed.
Run any script with uv run python:
UV_CACHE_DIR=/tmp/uv-cache uv run python LangGraph_concepts/hello_world_agent.py
UV_CACHE_DIR=/tmp/uv-cache uv run python Agent1/simple_llm_bot.py
UV_CACHE_DIR=/tmp/uv-cache uv run python Agent3/ReAct_agent.py
UV_CACHE_DIR=/tmp/uv-cache uv run python Agent4/RAG.pyThe UV_CACHE_DIR=/tmp/uv-cache prefix is useful in restricted environments where the default uv cache directory is not writable.
- The Gemini examples require a valid API key with access to the configured model.
- If you see
RESOURCE_EXHAUSTED, your key or project has hit a quota limit. - If you see
PERMISSION_DENIED, check whether the API key is valid, leaked, restricted, or missing access to the selected model. - The RAG example needs
Agent4/Stock_Market_Performance_2024.pdfto exist.