पाठ 10 / 31

LangSmith: Projects and Setup

यह पाठ अभी हिंदी में अनुवादित नहीं है, इसलिए अंग्रेज़ी में दिखाया जा रहा है।

Configure LangSmith tracing with environment variables and organise traces into projects.

लेखक: · 15 साल से वेब डेवलपर

What LangSmith is

LangSmith is the observability and evaluation platform from the LangChain team. It is a managed service, with self-hosting available on enterprise plans. A common misconception is that it only works with LangChain: it does not. The langsmith SDK traces any Python or JS/TS code, and LangChain and LangGraph send traces to it automatically once tracing is enabled. Traces are grouped into projects (one per app or environment), and each step is a run with a run_type such as chain, llm, tool, retriever, embedding, prompt or parser. Beyond tracing, LangSmith offers datasets and experiments for offline evaluation, feedback on runs, annotation queues for human review, monitoring charts, and a prompt hub and playground. Configuration is mostly environment variables: turn tracing on, provide an API key, and name the project. Older code uses LANGCHAIN_-prefixed variable names, which are still widely seen; newer docs use the LANGSMITH_ prefix.

LangSmith building blocks

Runs nest into traces, traces live in projects, and selected runs flow into datasets that experiments evaluate.

Four connected stages: runs, traces, projects, datasets and experiments.
Figure 4.1: runs -> traces -> projects -> datasets and experiments

Enable tracing

Set these before your process starts. The project is created on first use if it does not exist.

pip install langsmith

export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY="<your-api-key>"
export LANGSMITH_PROJECT="support-bot-dev"   # defaults to "default" if unset

त्वरित जाँच: Which statement about LangSmith is correct?

  • It can only trace applications built with LangChain
  • It can trace plain Python or JS/TS code through its SDK, not only LangChain apps
  • It requires every run to be of type `llm`
  • It stores traces only on the developer's laptop
Answer

It can trace plain Python or JS/TS code through its SDK, not only LangChain apps — The `langsmith` SDK's `@traceable` decorator and client wrappers work with any code; LangChain integration is a convenience, not a requirement.