DEV Community

Rushank Savant
Rushank Savant

Posted on

Day 14: Deployment & LangSmith

When your LangGraph agent runs, a lot happens under the hood. If it gives a wrong answer, you need to know: Was it a bad retrieval? Did the tool fail? Or did the LLM just misinterpret the data?

LangSmith allows you to trace every single step.

  • Tracing: See the exact prompt sent and the raw JSON returned.

  • Latency: Find out which node is slowing down your app.

  • Cost: Track exactly how many tokens that "loop" consumed.

Pro Tip: Simply setting two environment variables in your .env file enables tracing automatically. No code changes required!


🌐 2. LangServe: Turning Code into an API

You can't give your users a Python script. You need a REST API.
LangServe helps you deploy your chains and graphs as a professional web service using FastAPI.
It even gives you a built-in "Playground" UI to test your API in the browser.

from fastapi import FastAPI
from langserve import add_routes
# Import your 'graph' from Day 13
from my_agent import graph 

app = FastAPI(title="My AI Agent API")

# This creates /invoke, /stream, and /batch endpoints automatically!
add_routes(app, graph, path="/agent")

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="localhost", port=8000)
Enter fullscreen mode Exit fullscreen mode

βœ… 3. The Production Checklist

Before you hit "Deploy," ask yourself these three questions:

  1. Does it have a System Prompt? Ensure your agent has clear "guardrails" (e.g., "Do not answer political questions").

  2. Is the Memory capped? Use WindowMemory or SummaryMemory so your database doesn't explode.

  3. Are the Tools safe? If your tool can delete data, make sure there is a "human-in-the-loop" check.


πŸŽ“ Graduation: Where to go from here?

Two weeks ago, LangChain was a mystery. Now, it’s a tool in your belt. The field of AI moves fast, but the fundamentals you learnedβ€”Prompts, Models, Parsers, RAG, and Graphsβ€”are the pillars of the industry.

Your Final Challenge: Take everything you’ve built over the last 14 days and combine it. Build a "Personal Study Assistant" that can read your local PDFs (RAG), search the web (Tools), and remember your name (Memory).


🎯 Day 14 Summary

  • LangSmith: For debugging and tracing.

  • LangServe: For deploying as an API.

  • Evaluations: Testing your agent against "Golden Sets" of data to ensure it stays smart.

It has been an incredible journey. Keep building, keep breaking things, and most importantly, keep sharing your progress.

The future is agentic. And you’re ready for it. β˜•

Top comments (0)