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:

  1. Use langchain_anthropic.ChatAnthropic with model claude-sonnet-4-6.
  2. Load documents with langchain.document_loaders.TextLoader (use any local .txt file or hardcoded strings).
  3. Split with RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50).
  4. Embed with langchain_community.embeddings.HuggingFaceEmbeddings (all-MiniLM-L6-v2).
  5. Store in langchain_community.vectorstores.Chroma (in-memory).
  6. Build a RetrievalQA chain and run 3 sample questions.
  7. 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:

  1. Use langgraph.graph.StateGraph with a typed state dict: {messages: list, next_step: str}.
  2. Define nodes: llm_node (calls Claude with tool-use), tool_executor_node (runs the selected tool), end_node.
  3. 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).
  4. Use MemorySaver checkpointer to enable conversation persistence across runs.
  5. Compile and run the graph with a sample multi-step task (e.g. “calculate 15% of 230, then double it”).
  6. Print the full state at each step to show the graph traversal.

How to run: python langgraph_agent.py
Dependencies: langgraph, langchain-anthropic, anthropic