Implementation Guide — Ecosystem Examples
This directory originally contained Python example scripts that were removed from this archive.
An AI assistant can recreate them by following the instructions below.
langchain_rag.py
Purpose: Build a RAG pipeline using LangChain with Claude as the LLM.
What to implement:
- Use
langchain_anthropic.ChatAnthropicwith modelclaude-sonnet-4-6. - Load documents with
langchain.document_loaders.TextLoader(use any local.txtfile or hardcoded strings). - Split with
RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50). - Embed with
langchain_community.embeddings.HuggingFaceEmbeddings(all-MiniLM-L6-v2). - Store in
langchain_community.vectorstores.Chroma(in-memory). - Build a
RetrievalQAchain and run 3 sample questions. - Print the answer and the source documents.
How to run: python langchain_rag.py
Dependencies: langchain, langchain-anthropic, langchain-community, chromadb, sentence-transformers
langgraph_agent.py
Purpose: Build a stateful agent graph using LangGraph.
What to implement:
- Use
langgraph.graph.StateGraphwith a typed state dict:{messages: list, next_step: str}. - Define nodes:
llm_node(calls Claude with tool-use),tool_executor_node(runs the selected tool),end_node. - Define edges:
llm_node → tool_executor_node(if tool call present),llm_node → end_node(if no tool call),tool_executor_node → llm_node(loop back). - Use
MemorySavercheckpointer to enable conversation persistence across runs. - Compile and run the graph with a sample multi-step task (e.g. “calculate 15% of 230, then double it”).
- Print the full state at each step to show the graph traversal.
How to run: python langgraph_agent.py
Dependencies: langgraph, langchain-anthropic, anthropic