LangSmith โ Observability & Evaluation
Lesson 5: LangSmith โ Observability & Evaluation
Once your app runs, you need to see it. LangSmith is LangChain Inc.'s LLMOps platform: a proprietary, cloud-hosted service for tracing every LLM call, evaluating outputs, managing prompts, and monitoring production. It's the closest thing the Lang ecosystem has to "the official dashboard."
What LangSmith gives you
| Feature | What it does |
|---|---|
| Tracing | Records every step of a run โ model calls, retriever hits, tool invocations โ with tokens, latency, and costs |
| Datasets & evals | Curate test inputs, run them through your app, score outputs (LLM-as-judge, custom scorers, or human) |
| Prompt Hub | Versioned, shareable prompt management โ pull prompts into code, roll back bad edits |
| Monitoring | Dashboards, alerts, and feedback collection for production traffic |
| Playground | Interactive UI to experiment with prompts and models before changing code |
| Automations | Rule-based actions: run an eval when a new trace arrives, annotate anomalous runs |
Hooking it up
With LangChain, tracing is nearly free โ set an API key and runs appear automatically:
# Works automatically with LangChain/LangGraph โ no code changes needed
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=lsv2_...
export LANGCHAIN_PROJECT=my-app
# Or set it in code:
from langchain_core.callbacks import config
from langchain_core.runnables import RunnableConfig
config = RunnableConfig(tags=["production"], metadata={"user_id": "u-42"})
result = chain.invoke({"topic": "RAG"}, config=config)
Not using LangChain? The langsmith SDK traces any framework via decorators, and OpenTelemetry support lets non-LangChain apps send spans in too. The tracing layer is deliberately framework-agnostic โ LangSmith doesn't require you to use LangChain.
The eval loop
The workflow that makes LangSmith (or any LLMOps tool) valuable is the eval loop: collect a dataset of real inputs โ run them through your app โ score outputs automatically โ fix the worst failures โ re-run. With LLM-as-judge scorers you can grade hundreds of outputs in minutes. This is how "good enough" becomes "measurably better."
๐ง Knowledge Check
1. What is LangSmith, in one line?
2. How do you enable LangChain tracing?
3. What is the "eval loop"?