Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

langsmith

БесплатноБез исполняемых скриптовНе проверен

Monitor, trace, debug, and evaluate LLM applications with LangSmith. Use when a user asks to trace LLM calls, debug chain executions, evaluate AI output…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

LangSmith

Overview

LangSmith is the observability and evaluation platform for LLM applications. It traces every step of your chains and agents, helps you build evaluation datasets, run automated quality checks, and monitor production performance. Essential for moving LLM apps from prototype to production.

Instructions

Step 1: Setup and Configuration

Create a LangSmith account at smith.langchain.com and get an API key.

pip install -U langsmith     # JS/TS: npm install langsmith

Set environment variables (the LANGSMITH_* names are current; the older LANGCHAIN_TRACING_V2 / LANGCHAIN_API_KEY names are legacy aliases):

export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY="lsv2_pt_8f3a1c9d2b7e4a60"  # from Settings > API Keys
export LANGSMITH_PROJECT="support-bot-dev"           # optional, defaults to "default"
export LANGSMITH_ENDPOINT="https://eu.api.smith.langchain.com"  # only for EU accounts
export LANGSMITH_WORKSPACE_ID="..."                  # only if your key spans several workspaces

Once set, all LangChain and LangGraph calls are automatically traced — no code changes needed. For a single block only, use with langsmith.tracing_context(enabled=True):.

For non-LangChain code, use the SDK directly (@traceable below, or wrappers.wrap_openai(OpenAI()) to trace OpenAI calls):

from langsmith import Client
client = Client()

Step 2: Tracing

Automatic Tracing (LangChain)

With LANGSMITH_TRACING=true, every .invoke(), .stream(), .batch() call is traced automatically. Each trace shows:

  • Input/output at every step
  • Token usage and cost
  • Latency per component
  • Error details with full stack traces

Manual Tracing with @traceable

For custom functions outside LangChain:

from langsmith import traceable

@traceable(name="process_order", tags=["production"])
def process_order(order_id: str, items: list) -> dict:
    # Your business logic
    validated = validate_items(items)
    summary = generate_summary(validated)  # LLM call
    return {"order_id": order_id, "summary": summary, "status": "processed"}

@traceable
def validate_items(items: list) -> list:
    # Nested traces automatically link to parent
    return [item for item in items if item["quantity"] > 0]

Tracing with Context Manager

from langsmith import trace

with trace("data-pipeline", inputs={"source": "csv"}) as run:
    data = load_data("input.csv")
    processed = transform(data)
    run.end(outputs={"rows": len(processed)})

Metadata and Tags

# Add metadata to any LangChain call
result = chain.invoke(
    {"question": "..."},
    config={
        "metadata": {"user_id": "u-123", "environment": "staging"},
        "tags": ["beta-test", "gpt4"]
    }
)

Step 3: Datasets and Examples

Datasets are collections of input/output pairs used for evaluation:

from langsmith import Client

client = Client()

# Create a dataset
dataset = client.create_dataset("customer-support-qa", description="Real support questions with expected answers")

# Add examples
client.create_examples(
    dataset_id=dataset.id,
    examples=[
        {
            "inputs": {"question": "How do I reset my password?"},
            "outputs": {"answer": "Go to Settings > Security > Reset Password"},
        },
        {
            "inputs": {"question": "What's your refund policy?"},
            "outputs": {"answer": "Full refund within 30 days, no questions asked"},
        },
    ],
)
# Also create from existing traces: in the UI, select traces → "Add to Dataset"

Step 4: Evaluation

Run your chain against a dataset and score the results:

from langsmith import evaluate

# Your target function (chain, agent, or any callable)
def my_app(inputs: dict) -> dict:
    result = chain.invoke(inputs)
    return {"answer": result}

# Custom evaluator
# Evaluators may take any of: inputs, outputs, reference_outputs (older
# (run, example) signatures still work)
def correctness(outputs: dict, reference_outputs: dict) -> dict:
    """Check if the answer matches expected output."""
    predicted = outputs["answer"]
    expected = reference_outputs["answer"]
    score = 1.0 if expected.lower() in predicted.lower() else 0.0
    return {"key": "correctness", "score": score}

def conciseness(outputs: dict) -> dict:
    """Penalize overly long answers."""
    answer = outputs["answer"]
    word_count = len(answer.split())
    score = 1.0 if word_count < 100 else max(0, 1.0 - (word_count - 100) / 200)
    return {"key": "conciseness", "score": score}

# Run evaluation
results = evaluate(
    my_app,
    data="customer-support-qa",  # dataset name
    evaluators=[correctness, conciseness],
    experiment_prefix="gpt4o-v2",
    max_concurrency=4,
)

# Results visible in LangSmith UI with scores, comparisons, and drill-down

For LLM-as-judge evaluators, create a function that calls an LLM to

Полный SKILL.md на GitHub

Установить langsmith в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл langsmith?

Monitor, trace, debug, and evaluate LLM applications with LangSmith. Use when a user asks to trace LLM calls, debug chain executions, evaluate AI output quality, set up LLM observability, monitor agent performance, run prompt experiments, compare model outputs, create evaluation datasets, track token usage and latency, or build LLM testing pipelines. Covers tracing, datasets, evaluators, annotation queues, prompt hub, and production monitoring.

Как установить скилл langsmith?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл langsmith запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить langsmith с