Category

python

34 articles across 15 sub-topics

RAG vs Fine-Tuning: When to Use Each (and When to Combine Them)

TLDR: RAG gives LLMs access to current knowledge at inference time; fine-tuning changes how they reason and write. Use RAG when your data changes. Use fine-tuning when you need consistent style, tone, or domain reasoning. Use both for production assi...

•27 min read

Build vs Buy: Deploying Your Own LLM vs Using ChatGPT, Gemini, and Claude APIs

TLDR: Use the API until you hit $10K/month or a hard data privacy requirement. Then add a semantic cache. Then evaluate hybrid routing. Self-hosting full model serving is only cost-effective at > 50M tokens/day with a dedicated MLOps team. The build ...

•30 min read

LangChain Tools and Agents: The Classic Agent Loop

šŸŽÆ Quick TLDR: The Classic Agent Loop TLDR: LangChain's @tool decorator plus AgentExecutor give you a working tool-calling agent in about 30 lines of Python. The ReAct loop — Thought → Action → Observation — drives every reasoning step. For simple l...

•20 min read
LangChain 101: Chains, Prompts, and LLM Integration

LangChain 101: Chains, Prompts, and LLM Integration

TLDR: LangChain's LCEL pipe operator (|) wires prompts, models, and output parsers into composable chains — swap OpenAI for Anthropic or Ollama by changing one line without touching the rest of your code. šŸ“– One LLM API Today, Rewrite Tomorrow: The...

•19 min read

From LangChain to LangGraph: When Agents Need State Machines

TLDR: LangChain's AgentExecutor is a solid starting point — but it has five hard limits (no branching, no pause/resume, no parallelism, no human-in-the-loop, no crash recovery). LangGraph replaces the implicit loop with an explicit graph, unlocking e...

•18 min read
LangGraph Tool Calling: ToolNode, Parallel Tools, and Custom Tools

LangGraph Tool Calling: ToolNode, Parallel Tools, and Custom Tools

TLDR: Wire @tool, ToolNode, and bind_tools into LangGraph for agents that call APIs at runtime. šŸ“– The Stale Knowledge Problem: Why LLMs Need Runtime Tools Your agent confidently tells you the current stock price of NVIDIA. It's from its training d...

•17 min read

Streaming Agent Responses in LangGraph: Tokens, Events, and Real-Time UI Integration

TLDR: Stream agents token by token with astream_events; wire to FastAPI SSE for zero-spinner UX. šŸ“– The 25-Second Spinner: Why Streaming Is a UX Requirement, Not a Nice-to-Have Your agent takes 25 seconds to respond. Users abandon after 8 seconds....

•19 min read

The ReAct Agent Pattern in LangGraph: Think, Act, Observe, Repeat

TLDR: ReAct = Think + Act + Observe, looped as a LangGraph graph — prebuilt or custom. šŸ“– The Single-Shot Failure: Why One LLM Call Isn't Enough for Complex Tasks Your agent is supposed to write a function, run the tests, fix the failures, and re...

•22 min read

Multi-Agent Systems in LangGraph: Supervisor Pattern, Handoffs, and Agent Networks

TLDR: Split work across specialist agents — supervisor routing beats one overloaded generalist every time. šŸ“– The Context Ceiling: Why One Agent Can't Do Everything Your research agent is writing a 20-page report. It has 15 tools. Its context windo...

•26 min read

LangGraph Memory and State Persistence: Checkpointers, Threads, and Cross-Session Memory

TLDR: Checkpointers + thread IDs give LangGraph agents persistent memory across turns and sessions. šŸ“– The Amnesia Problem: Why Stateless Agents Frustrate Users Your customer support agent is on its third message with a user. The user says: "As I ...

•17 min read

Human-in-the-Loop Workflows with LangGraph: Interrupts, Approvals, and Async Execution

TLDR: Pause LangGraph agents mid-run with interrupt(), get human approval, resume with Command. šŸ“– The Autonomous Agent Risk: When Acting Without Permission Goes Wrong Your autonomous coding agent refactored the authentication module while you were...

•17 min read
Deploying LangGraph Agents: LangServe, Docker, LangGraph Platform, and Production Observability

Deploying LangGraph Agents: LangServe, Docker, LangGraph Platform, and Production Observability

TLDR: Swap InMemorySaver → PostgresSaver, add LangServe + Docker, trace with LangSmith. šŸ“– The Demo-to-Production Gap: Why Notebook Agents Fail at Scale Your LangGraph agent works perfectly in the demo. You deploy it to a single FastAPI instance. ...

•25 min read
LangGraph 101: Building Your First Stateful Agent

LangGraph 101: Building Your First Stateful Agent

TLDR: LangGraph adds state, branching, and loops to LLM chains — build stateful agents with graphs, nodes, and typed state. šŸ“– The Stateless Chain Problem: Why Your Agent Forgets Everything You built a LangChain chain that answers questions. Then y...

•18 min read
Step-by-Step: How to Expose a Skill as an MCP Server

Step-by-Step: How to Expose a Skill as an MCP Server

TLDR: Turn any Python function into a multi-client MCP server in 11 steps — from annotation to Docker. šŸ“– The Copy-Paste Problem: Why Skills Die at IDE Boundaries A developer pastes their summarize_pr_diff function into a Slack message because thei...

•26 min read
Headless Agents: Deploy Skills as MCP Servers — Full Guide from Concept to Three Clients

Headless Agents: Deploy Skills as MCP Servers — Full Guide from Concept to Three Clients

TLDR: Build an MCP server once and call it from Cursor, Claude Desktop, and VS Code without rewrites — this guide takes you from a single Python function to a containerized, authenticated, three-client deployment in 11 concrete steps. šŸ“– The Trappe...

•31 min read