langsmith-fetch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fetching LangSmith Traces

获取LangSmith Traces

Requires
langsmith-fetch
in project dependencies and
LANGSMITH_API_KEY
in a
.env
file.
需要项目依赖中包含
langsmith-fetch
,且
.env
文件中配置有
LANGSMITH_API_KEY

Setup

配置

First, find the
.env
file containing
LANGSMITH_API_KEY
:
bash
find . -name ".env" -type f 2>/dev/null | head -5
首先,找到包含
LANGSMITH_API_KEY
.env
文件:
bash
find . -name ".env" -type f 2>/dev/null | head -5

Commands

命令

Use
--env-file <path-to-.env>
with all commands:
bash
undefined
所有命令都需要搭配
--env-file <.env文件路径>
使用:
bash
undefined

Fetch recent traces (uses LANGSMITH_PROJECT from .env, or specify --project-uuid)

Fetch recent traces (uses LANGSMITH_PROJECT from .env, or specify --project-uuid)

uv run --env-file <path> langsmith-fetch traces ./traces --limit 10 uv run --env-file <path> langsmith-fetch traces ./traces --project-uuid <uuid> --limit 10
uv run --env-file <path> langsmith-fetch traces ./traces --limit 10 uv run --env-file <path> langsmith-fetch traces ./traces --project-uuid <uuid> --limit 10

Fetch single trace by ID

Fetch single trace by ID

uv run --env-file <path> langsmith-fetch trace <trace-id>
uv run --env-file <path> langsmith-fetch trace <trace-id>

Include metadata (timing, tokens, costs)

Include metadata (timing, tokens, costs)

uv run --env-file <path> langsmith-fetch trace <trace-id> --include-metadata
undefined
uv run --env-file <path> langsmith-fetch trace <trace-id> --include-metadata
undefined

Output Formats

输出格式

  • --format pretty
    - Human-readable (default)
  • --format json
    - Pretty-printed JSON
  • --format raw
    - Compact JSON for piping
  • --format pretty
    - 人类可读格式(默认)
  • --format json
    - 格式化输出的JSON
  • --format raw
    - 适用于管道传输的紧凑JSON

Troubleshooting Workflow

排查工作流

  1. Find
    .env
    :
    find . -name ".env" -type f 2>/dev/null
  2. Fetch recent traces:
    uv run --env-file <path> langsmith-fetch traces ./debug --limit 10
  3. Find relevant trace in saved JSON files
  4. Check: What tools were called? What did they return? Was it correct/expected?
  1. 查找
    .env
    文件:
    find . -name ".env" -type f 2>/dev/null
  2. 获取最近的traces:
    uv run --env-file <path> langsmith-fetch traces ./debug --limit 10
  3. 在保存的JSON文件中找到相关trace
  4. 检查:调用了哪些工具?它们的返回结果是什么?是否正确/符合预期?