# Clone the repository
git clone <your-repo-url>
cd langchain_tutorial
# Install packages
uv sync
# OR
pip install -e .Create .env file in project root:
# Required for OpenAI models (optional)
OPENAI_API_KEY=sk-...
OPENAI_LLM=gpt-4o-mini
# Required for Ollama (local, recommended)
OLLAMA_LLM=llama3.2:3b
# Optional: Other providers
GOOGLE_API_KEY=...
ANTHROPIC_API_KEY=...
TAVILY_API_KEY=...For production or offline use:
python scripts/setup_models.pyThis downloads:
- HuggingFace Embeddings:
BAAI/bge-large-en-v1.5(~1.34 GB)
Benefits:
- ✅ No 5-15 minute wait on first run
- ✅ Works offline
- ✅ Predictable deployment
Skip if:
- Just experimenting (auto-downloads on first use)
- Fast internet available
Windows:
- Download: https://github.com/UB-Mannheim/tesseract/wiki
- Install to:
C:\Program Files\Tesseract-OCR - Add to PATH
- Restart terminal
macOS:
brew install tesseractLinux:
sudo apt-get install tesseract-ocrtesseract --versioncd langchain-crash-course/5_agents_tools
python agent_tools_basic.pycd langchain-crash-course/5_agents_tools
python rag_pdf.py
python agent_react_rag_pdf.pycd langchain-crash-course/5_agents_tools
# 1. Pre-download models (if not done)
python ../../scripts/setup_models.py
# 2. Add a PDF to test
cp /path/to/your.pdf pdfs/
# 3. Initialize vector store
python rag_pdf_advanced.py
# 4. Run agent
python agent_react_rag_pdf_advanced.py# Manually download the model
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-large-en-v1.5')"- Ensure Tesseract is installed
- Check it's in your PATH:
tesseract --version - Restart terminal/IDE after installation
- This is normal - system falls back to PyPDFLoader
- Check logs for details
- Ensure
unstructuredpackage is installed
Use a smaller embedding model in rag_pdf_advanced.py:
# Replace in create_multimodal_embeddings():
model_name = "BAAI/bge-small-en-v1.5" # 133 MB instead of 1.34 GBCreate Dockerfile:
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
tesseract-ocr \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy and install Python dependencies
COPY pyproject.toml uv.lock ./
RUN pip install uv && uv sync
# Pre-download models
COPY scripts/setup_models.py scripts/
RUN python scripts/setup_models.py
# Copy application
COPY . .
CMD ["python", "langchain-crash-course/5_agents_tools/agent_react_rag_pdf_advanced.py"]Build and run:
docker build -t langchain-tutorial .
docker run -it --env-file .env langchain-tutorial- ✅ Complete setup steps above
- 📖 Read
langchain-crash-course/5_agents_tools/README.md - 🚀 Try the examples in order:
- Basic agent → Basic RAG → Advanced RAG
- 🔧 Customize for your use case
- Documentation: See README files in each directory
- Issues: Check troubleshooting sections
- Examples: All scripts include inline documentation