langsmith-code-eval

作者: langchain-ai

为LangSmith追踪的智能体创建基于代码的评估器。在构建自定义评估逻辑、测试工具使用模式或对智能体输出进行评分时使用…

npx skills add https://github.com/langchain-ai/lca-skills --skill langsmith-code-eval

LangSmith Code Evaluator Creation

Creates evaluators for LangSmith experiments through structured inspection and implementation.

Prerequisites

  • langsmith Python package installed
  • LANGSMITH_API_KEY environment variable set (check project's .env file)

Workflow

Copy this checklist and track progress:

Evaluator Creation Progress:
- [ ] Step 1: Gather info from user
- [ ] Step 2: Inspect trace and dataset structure
- [ ] Step 3: Read agent code
- [ ] Step 4: Write evaluator
- [ ] Step 5: Write experiment runner
- [ ] Step 6: Run and iterate

Step 1: Gather Info from User

IMPORTANT: Do NOT search or explore the codebase. Ask the user all of these questions upfront using AskUserQuestion before doing anything else.

Ask the user the following in a single AskUserQuestion call:

  1. Python command: How do you run Python in this project? (e.g., python, python3, uv run python, poetry run python)
  2. Agent file path: What is the path to your agent file?
  3. LangSmith project name: What is your LangSmith project name (where traces are logged)?
  4. LangSmith dataset name: What is the name of the dataset to evaluate against?
  5. Evaluation goal: What behavior should pass vs fail? Common types:
    • Tool usage: Did the agent call the correct tool?
    • Output correctness: Does output match expected format/content?
    • Policy compliance: Did it follow specific rules?
    • Classification: Did it categorize correctly?

Step 2: Inspect Trace and Dataset Structure

Using the info from Step 1, run the inspection scripts located in this skill's directory:

{python_cmd} {skill_dir}/scripts/inspect_trace.py PROJECT_NAME [RUN_ID]
{python_cmd} {skill_dir}/scripts/inspect_dataset.py DATASET_NAME

Replace {python_cmd} with the command from Step 1, and {skill_dir} with this skill's directory path.

Verify the trace matches the agent:

  • Does the trace type match? (e.g., OpenAI trace for OpenAI agent)
  • Does it contain the data needed for evaluation?
  • If mismatched, clarify before proceeding.

From the dataset inspection, note:

  • Input schema (what gets passed to the agent)
  • Output schema (reference/expected outputs)
  • Metadata fields (e.g., expected_tool, difficulty, labels)

The dataset metadata often contains ground truth for evaluation (e.g., which tool should be called, expected classification).

Step 3: Read Agent Code

Read the agent file provided in Step 1 to identify:

  • Entry point function (look for @traceable decorator)
  • Available tools
  • Output format (what the function returns)

Step 4: Write the Evaluator

Create evaluator functions based on trace and dataset structure. See EVALUATOR_REFERENCE.md for function signatures and return formats.

Step 5: Write Experiment Runner

Create a script that:

  1. Imports the agent's entry function
  2. Wraps it as a target function
  3. Runs evaluate() or aevaluate() against the dataset

See EVALUATOR_REFERENCE.md for evaluate() usage.

Step 6: Run and Iterate

Execute the experiment, review results in LangSmith, refine evaluators as needed.

来自 langchain-ai 的更多技能

arxiv-search
langchain-ai
通过主题搜索arXiv上的预印本和学术论文,并获取摘要。基于查询的搜索涵盖物理学、数学、计算机科学、生物学、统计学及相关领域。可配置结果数量限制(默认10篇论文),结果按相关性排序。返回每篇匹配论文的标题和摘要。需要安装arxiv Python包;若未安装,请通过pip安装。
official
blog-post
langchain-ai
长篇幅博客文章撰写,包含研究委托、结构化内容模板和AI生成的封面图片。在写作前将研究任务委托给子代理,并将发现结果以Markdown格式存储以供参考和上下文参考。强制采用五部分文章结构:钩子、背景、主要内容(3-5个部分)、实际应用和带行动号召的结论。通过涵盖主题、风格、构图、色彩和光线的详细提示生成SEO优化的封面图片。将文章输出至...
official
code-review
langchain-ai
对变更进行结构化代码审查,检查正确性、风格、测试及潜在问题。
official
coding-prefs
langchain-ai
在做出非平凡的样式决策前,先从 /memory/coding-prefs.md 读取用户的编码偏好,并在用户给出新偏好时追加记录。
official
competitor-analysis
langchain-ai
当被要求分析竞争对手时:
official
cudf-analytics
langchain-ai
用于在数据集、CSV或表格数据上执行GPU加速的数据分析,使用NVIDIA cuDF。当任务涉及分组聚合、统计…时触发。
official
cuml-machine-learning
langchain-ai
使用NVIDIA cuML在表格数据上进行GPU加速的机器学习。当任务涉及分类、回归、聚类、降维…时触发。
official
data-visualization
langchain-ai
用于创建出版级图表和多面板分析摘要。当任务涉及数据可视化、结果绘图、创建……时触发。
official