Token导航 LogoToken导航TokenDH.com
Open Evals logo
开发工具未说明官方级别未说明来源级核验

Open Evals

MCP Server

开源AI评估框架,支持LLM作为评判者和基于断言的评估,适用于任何AI应用。

工具数

8

提示词数

0

GitHub Stars

0

资源数

0
开源TypeScriptClaude开发工具Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

hasna

提供方

hasna

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

@hasna/evals

开源AI评估框架——LLM作为判断+基于断言的评估,适用于任何AI应用程序。

命令行界面 (evals) · MCP服务器 (evals-mcp) · TypeScript SDK

______________________________________________________________________

安装

bun install -g @hasna/evals
# or
npm install -g @hasna/evals

5分钟快速入门

1.编写数据集 (datasets/smoke.jsonl):

{"id":"q-001","input":"What is 2+2?","assertions":[{"type":"contains","value":"4"}],"judge":{"rubric":"Must answer 4 correctly."}}
{"id":"q-002","input":"Say hello","assertions":[{"type":"min_length","value":2}],"judge":{"rubric":"Should respond with a greeting."}}

2.对你的应用程序进行评估:

evals run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat

3.输出:

✓ PASS  q-001    124ms
✓ PASS  q-002     89ms
────────────────────────────────
  2/2 passed (100%)  0.2s  $0.0012

______________________________________________________________________

评估案例格式

单轮

{
  "id": "greeting-001",
  "input": "Hello, what can you do?",
  "expected": "A welcoming response listing capabilities",
  "adapter": { "type": "http", "url": "http://localhost:3000/api/chat" },
  "assertions": [
    { "type": "min_length", "value": 20 },
    { "type": "not_contains", "value": "I cannot" },
    { "type": "max_length", "value": 500 }
  ],
  "judge": {
    "rubric": "Should be welcoming and list 2-3 capabilities. PASS if friendly and informative.",
    "model": "claude-sonnet-4-6"
  },
  "tags": ["smoke", "greeting"]
}

多圈

{
  "id": "refund-flow-001",
  "turns": [
    { "role": "user", "content": "I want a refund." },
    { "role": "assistant", "expected": "asks for order ID" },
    { "role": "user", "content": "Order #1234" },
    { "role": "assistant", "expected": "confirms refund process" }
  ],
  "judge": {
    "rubric": "Should collect order ID before processing. Should not promise instant refund."
  }
}

通过^k(一致性测试)

{
  "id": "booking-001",
  "input": "Book a flight to Paris",
  "repeat": 5,
  "passThreshold": 0.8,
  "judge": { "rubric": "Should ask for dates and destination confirmation." }
}

______________________________________________________________________

断言类型

类型检查内容示例
contains输出包含字符串{"type":"contains","value":"hello"}
not_contains输出不包含字符串{"type":"not_contains","value":"error"}
starts_with / ends_with前缀/后缀匹配{"type":"starts_with","value":"Sure"}
equals完全匹配{"type":"equals","value":"4"}
regex / not_regex正则表达式匹配{"type":"regex","value":"\\d{4}"}
max_length / min_length字符计数{"type":"max_length","value":500}
json_valid响应是有效的JSON{"type":"json_valid"}
json_schema响应与JSON模式匹配{"type":"json_schema","value":{...}}
tool_called调用了特定工具{"type":"tool_called","value":"search"}
tool_not_called工具未被调用{"type":"tool_not_called","value":"delete"}
tool_call_count范围内的工具调用次数{"type":"tool_call_count","min":1,"max":3}
tool_args_match工具参数与预期匹配{"type":"tool_args_match","value":{"tool":"search","args":{"query":"AI"}}}
response_time_ms限时响应{"type":"response_time_ms","max":3000}
token_count令牌计数在范围内{"type":"token_count","min":10,"max":500}
cost_usd成本低于预算{"type":"cost_usd","max":0.01}
semantic_similarity预期的意义匹配{"type":"semantic_similarity","value":"acknowledge frustration","threshold":0.8}

断言运行 最便宜的先 --在嵌入之前进行确定性检查。LLM法官只有在所有断言都通过时才运行。

______________________________________________________________________

适配器

配置哪个适配器将eval runner连接到您的应用程序:

# HTTP (any REST endpoint)
evals run dataset.jsonl --adapter http --url http://localhost:3000/api/chat

# Direct Anthropic API
evals run dataset.jsonl --adapter anthropic --model claude-sonnet-4-6

# Direct OpenAI API (also works with Ollama)
evals run dataset.jsonl --adapter openai --model gpt-4o --url http://localhost:11434

# MCP tool (eval your MCP server directly)
evals run dataset.jsonl --adapter mcp --mcp-command "node dist/mcp/index.js" --tool my_tool

# JS function (fastest, no network)
evals run dataset.jsonl --adapter function --module ./src/handler.js

# CLI command (pipe stdin, capture stdout)
evals run dataset.jsonl --adapter cli --command "my-cli-tool --input '{{input}}'"

______________________________________________________________________

法学硕士评委

  • 通过/失败/未知 --无数字刻度
  • 判决前的思维链 --法官总是先推理
  • 温度=0 --确定性判断
  • 可配置模型 --默认值 claude-sonnet-4-6,支持任何Anthropic或OpenAI模型
"judge": {
  "rubric": "Should answer in Romanian. Should reference at least one feature. Under 100 words.",
  "model": "claude-opus-4-6",
  "provider": "anthropic"
}

______________________________________________________________________

CLI参考

# Run a dataset
evals run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat

# CI mode — exit 1 on regression
evals ci run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat --baseline main --fail-if-regression 5

# Set baseline for CI comparison
evals ci set-baseline main

# Cost estimate before running (no API calls)
evals estimate datasets/smoke.jsonl --model claude-sonnet-4-6

# Compare two runs
evals compare  
evals compare main latest --markdown

# One-shot judge
evals judge --input "What is AI?" --output "AI is..." --rubric "Should define AI clearly"

# Generate eval cases from a description
evals generate --description "users asking about refund policies" --count 20 --output datasets/refunds.jsonl

# Calibrate your judge against gold labels
evals calibrate gold-50.jsonl --model claude-sonnet-4-6

# Capture production traffic as eval cases
evals capture --app http://localhost:3000 --rate 0.1 --output datasets/captured.jsonl

# Health check
evals doctor

# Register MCP server with Claude Code / Codex / Gemini
evals mcp register --claude      # Claude Code (~/.claude/mcp.json)
evals mcp register --codex       # Codex (~/.codex/config.json)
evals mcp register --gemini      # Gemini (~/.gemini/settings.json)
evals mcp register --all         # all three at once

______________________________________________________________________

CI/GitHub操作

- name: Run evals
  run: |
    evals ci run datasets/smoke.jsonl \
      --adapter http \
      --url ${{ env.APP_URL }} \
      --baseline main \
      --fail-if-regression 5
  env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

______________________________________________________________________

MCP工具(用于代理)

向您的代理人注册: evals mcp register --claude (或 --codex, --gemini, --all)

工具说明
evals_run运行完整的eval数据集
evals_run_single在会话中期判断单个响应
evals_judge一枪LLM法官电话
evals_list_datasets列出可用数据集
evals_get_results获取过去的跑步成绩
evals_compare比较两次运行
evals_create_case将案例添加到数据集中
evals_generate_cases根据描述自动生成案例

密钥代理模式 --回复前进行自检:

evals_run_single(
  input: "What is the capital of France?",
  output: "The capital of France is Paris.",
  rubric: "Must correctly identify Paris as the capital."
)
→ PASS — The response correctly identifies Paris.

______________________________________________________________________

许可证

Apache 2.0——请参阅 许可证

目录标签

目录标签

开源TypeScriptClaude开发工具本地部署AI评估LLM断言测试

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

8

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP