@hasna/evals 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +244 -0
- package/datasets/examples/mcp-eval.jsonl +3 -0
- package/datasets/examples/multi-turn.jsonl +3 -0
- package/datasets/examples/smoke.jsonl +5 -0
- package/datasets/examples/tool-use.jsonl +3 -0
- package/dist/adapters/adapters.test.d.ts +2 -0
- package/dist/adapters/adapters.test.d.ts.map +1 -0
- package/dist/adapters/anthropic.d.ts +4 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/cli.d.ts +4 -0
- package/dist/adapters/cli.d.ts.map +1 -0
- package/dist/adapters/function.d.ts +4 -0
- package/dist/adapters/function.d.ts.map +1 -0
- package/dist/adapters/http.d.ts +16 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/mcp.d.ts +4 -0
- package/dist/adapters/mcp.d.ts.map +1 -0
- package/dist/adapters/openai.d.ts +4 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/cli/adapter-parser.d.ts +3 -0
- package/dist/cli/adapter-parser.d.ts.map +1 -0
- package/dist/cli/cli.test.d.ts +2 -0
- package/dist/cli/cli.test.d.ts.map +1 -0
- package/dist/cli/commands/calibrate.d.ts +3 -0
- package/dist/cli/commands/calibrate.d.ts.map +1 -0
- package/dist/cli/commands/capture.d.ts +3 -0
- package/dist/cli/commands/capture.d.ts.map +1 -0
- package/dist/cli/commands/ci.d.ts +3 -0
- package/dist/cli/commands/ci.d.ts.map +1 -0
- package/dist/cli/commands/compare.d.ts +3 -0
- package/dist/cli/commands/compare.d.ts.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/estimate.d.ts +3 -0
- package/dist/cli/commands/estimate.d.ts.map +1 -0
- package/dist/cli/commands/generate.d.ts +3 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/judge.d.ts +3 -0
- package/dist/cli/commands/judge.d.ts.map +1 -0
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +18455 -0
- package/dist/core/assertions.d.ts +18 -0
- package/dist/core/assertions.d.ts.map +1 -0
- package/dist/core/assertions.test.d.ts +2 -0
- package/dist/core/assertions.test.d.ts.map +1 -0
- package/dist/core/e2e.test.d.ts +2 -0
- package/dist/core/e2e.test.d.ts.map +1 -0
- package/dist/core/judge.d.ts +13 -0
- package/dist/core/judge.d.ts.map +1 -0
- package/dist/core/judge.test.d.ts +2 -0
- package/dist/core/judge.test.d.ts.map +1 -0
- package/dist/core/reporter.d.ts +21 -0
- package/dist/core/reporter.d.ts.map +1 -0
- package/dist/core/runner.d.ts +4 -0
- package/dist/core/runner.d.ts.map +1 -0
- package/dist/core/runner.test.d.ts +2 -0
- package/dist/core/runner.test.d.ts.map +1 -0
- package/dist/datasets/loader.d.ts +18 -0
- package/dist/datasets/loader.d.ts.map +1 -0
- package/dist/datasets/loader.test.d.ts +2 -0
- package/dist/datasets/loader.test.d.ts.map +1 -0
- package/dist/db/store.d.ts +17 -0
- package/dist/db/store.d.ts.map +1 -0
- package/dist/db/store.test.d.ts +2 -0
- package/dist/db/store.test.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22903 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +20120 -0
- package/dist/mcp/mcp.test.d.ts +2 -0
- package/dist/mcp/mcp.test.d.ts.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +22835 -0
- package/dist/types/index.d.ts +171 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 hasna
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# @hasna/evals
|
|
2
|
+
|
|
3
|
+
Open source AI evaluation framework — LLM-as-judge + assertion-based evals for any AI app.
|
|
4
|
+
|
|
5
|
+
**CLI** (`evals`) · **MCP server** (`evals-mcp`) · **TypeScript SDK**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun install -g @hasna/evals
|
|
13
|
+
# or
|
|
14
|
+
npm install -g @hasna/evals
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 5-minute quickstart
|
|
18
|
+
|
|
19
|
+
**1. Write a dataset** (`datasets/smoke.jsonl`):
|
|
20
|
+
```jsonl
|
|
21
|
+
{"id":"q-001","input":"What is 2+2?","assertions":[{"type":"contains","value":"4"}],"judge":{"rubric":"Must answer 4 correctly."}}
|
|
22
|
+
{"id":"q-002","input":"Say hello","assertions":[{"type":"min_length","value":2}],"judge":{"rubric":"Should respond with a greeting."}}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**2. Run evals against your app**:
|
|
26
|
+
```bash
|
|
27
|
+
evals run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**3. Output**:
|
|
31
|
+
```
|
|
32
|
+
✓ PASS q-001 124ms
|
|
33
|
+
✓ PASS q-002 89ms
|
|
34
|
+
────────────────────────────────
|
|
35
|
+
2/2 passed (100%) 0.2s $0.0012
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Eval case format
|
|
41
|
+
|
|
42
|
+
### Single-turn
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"id": "greeting-001",
|
|
46
|
+
"input": "Hello, what can you do?",
|
|
47
|
+
"expected": "A welcoming response listing capabilities",
|
|
48
|
+
"adapter": { "type": "http", "url": "http://localhost:3000/api/chat" },
|
|
49
|
+
"assertions": [
|
|
50
|
+
{ "type": "min_length", "value": 20 },
|
|
51
|
+
{ "type": "not_contains", "value": "I cannot" },
|
|
52
|
+
{ "type": "max_length", "value": 500 }
|
|
53
|
+
],
|
|
54
|
+
"judge": {
|
|
55
|
+
"rubric": "Should be welcoming and list 2-3 capabilities. PASS if friendly and informative.",
|
|
56
|
+
"model": "claude-sonnet-4-6"
|
|
57
|
+
},
|
|
58
|
+
"tags": ["smoke", "greeting"]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Multi-turn
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"id": "refund-flow-001",
|
|
66
|
+
"turns": [
|
|
67
|
+
{ "role": "user", "content": "I want a refund." },
|
|
68
|
+
{ "role": "assistant", "expected": "asks for order ID" },
|
|
69
|
+
{ "role": "user", "content": "Order #1234" },
|
|
70
|
+
{ "role": "assistant", "expected": "confirms refund process" }
|
|
71
|
+
],
|
|
72
|
+
"judge": {
|
|
73
|
+
"rubric": "Should collect order ID before processing. Should not promise instant refund."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Pass^k (consistency testing)
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"id": "booking-001",
|
|
82
|
+
"input": "Book a flight to Paris",
|
|
83
|
+
"repeat": 5,
|
|
84
|
+
"passThreshold": 0.8,
|
|
85
|
+
"judge": { "rubric": "Should ask for dates and destination confirmation." }
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Assertion types
|
|
92
|
+
|
|
93
|
+
| Type | What it checks | Example |
|
|
94
|
+
|------|---------------|---------|
|
|
95
|
+
| `contains` | Output contains string | `{"type":"contains","value":"hello"}` |
|
|
96
|
+
| `not_contains` | Output does NOT contain string | `{"type":"not_contains","value":"error"}` |
|
|
97
|
+
| `starts_with` / `ends_with` | Prefix/suffix match | `{"type":"starts_with","value":"Sure"}` |
|
|
98
|
+
| `equals` | Exact match | `{"type":"equals","value":"4"}` |
|
|
99
|
+
| `regex` / `not_regex` | Regex match | `{"type":"regex","value":"\\d{4}"}` |
|
|
100
|
+
| `max_length` / `min_length` | Character count | `{"type":"max_length","value":500}` |
|
|
101
|
+
| `json_valid` | Response is valid JSON | `{"type":"json_valid"}` |
|
|
102
|
+
| `json_schema` | Response matches JSON schema | `{"type":"json_schema","value":{...}}` |
|
|
103
|
+
| `tool_called` | Specific tool was invoked | `{"type":"tool_called","value":"search"}` |
|
|
104
|
+
| `tool_not_called` | Tool was NOT invoked | `{"type":"tool_not_called","value":"delete"}` |
|
|
105
|
+
| `tool_call_count` | Number of tool calls in range | `{"type":"tool_call_count","min":1,"max":3}` |
|
|
106
|
+
| `tool_args_match` | Tool arguments match expected | `{"type":"tool_args_match","value":{"tool":"search","args":{"query":"AI"}}}` |
|
|
107
|
+
| `response_time_ms` | Response under time limit | `{"type":"response_time_ms","max":3000}` |
|
|
108
|
+
| `token_count` | Token count in range | `{"type":"token_count","min":10,"max":500}` |
|
|
109
|
+
| `cost_usd` | Cost under budget | `{"type":"cost_usd","max":0.01}` |
|
|
110
|
+
| `semantic_similarity` | Meaning matches expected | `{"type":"semantic_similarity","value":"acknowledge frustration","threshold":0.8}` |
|
|
111
|
+
|
|
112
|
+
Assertions run **cheapest-first** — deterministic checks before embeddings. The LLM judge only runs if all assertions pass.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Adapters
|
|
117
|
+
|
|
118
|
+
Configure which adapter connects the eval runner to your app:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# HTTP (any REST endpoint)
|
|
122
|
+
evals run dataset.jsonl --adapter http --url http://localhost:3000/api/chat
|
|
123
|
+
|
|
124
|
+
# Direct Anthropic API
|
|
125
|
+
evals run dataset.jsonl --adapter anthropic --model claude-sonnet-4-6
|
|
126
|
+
|
|
127
|
+
# Direct OpenAI API (also works with Ollama)
|
|
128
|
+
evals run dataset.jsonl --adapter openai --model gpt-4o --url http://localhost:11434
|
|
129
|
+
|
|
130
|
+
# MCP tool (eval your MCP server directly)
|
|
131
|
+
evals run dataset.jsonl --adapter mcp --mcp-command "node dist/mcp/index.js" --tool my_tool
|
|
132
|
+
|
|
133
|
+
# JS function (fastest, no network)
|
|
134
|
+
evals run dataset.jsonl --adapter function --module ./src/handler.js
|
|
135
|
+
|
|
136
|
+
# CLI command (pipe stdin, capture stdout)
|
|
137
|
+
evals run dataset.jsonl --adapter cli --command "my-cli-tool --input '{{input}}'"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## LLM judge
|
|
143
|
+
|
|
144
|
+
- **PASS / FAIL / UNKNOWN** — no numeric scales
|
|
145
|
+
- **Chain-of-thought before verdict** — judge always reasons first
|
|
146
|
+
- **temperature=0** — deterministic judgments
|
|
147
|
+
- **Configurable model** — default `claude-sonnet-4-6`, supports any Anthropic or OpenAI model
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
"judge": {
|
|
151
|
+
"rubric": "Should answer in Romanian. Should reference at least one feature. Under 100 words.",
|
|
152
|
+
"model": "claude-opus-4-6",
|
|
153
|
+
"provider": "anthropic"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## CLI reference
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Run a dataset
|
|
163
|
+
evals run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat
|
|
164
|
+
|
|
165
|
+
# CI mode — exit 1 on regression
|
|
166
|
+
evals ci run datasets/smoke.jsonl --adapter http --url http://localhost:3000/api/chat --baseline main --fail-if-regression 5
|
|
167
|
+
|
|
168
|
+
# Set baseline for CI comparison
|
|
169
|
+
evals ci set-baseline main
|
|
170
|
+
|
|
171
|
+
# Cost estimate before running (no API calls)
|
|
172
|
+
evals estimate datasets/smoke.jsonl --model claude-sonnet-4-6
|
|
173
|
+
|
|
174
|
+
# Compare two runs
|
|
175
|
+
evals compare <run-id-before> <run-id-after>
|
|
176
|
+
evals compare main latest --markdown
|
|
177
|
+
|
|
178
|
+
# One-shot judge
|
|
179
|
+
evals judge --input "What is AI?" --output "AI is..." --rubric "Should define AI clearly"
|
|
180
|
+
|
|
181
|
+
# Generate eval cases from a description
|
|
182
|
+
evals generate --description "users asking about refund policies" --count 20 --output datasets/refunds.jsonl
|
|
183
|
+
|
|
184
|
+
# Calibrate your judge against gold labels
|
|
185
|
+
evals calibrate gold-50.jsonl --model claude-sonnet-4-6
|
|
186
|
+
|
|
187
|
+
# Capture production traffic as eval cases
|
|
188
|
+
evals capture --app http://localhost:3000 --rate 0.1 --output datasets/captured.jsonl
|
|
189
|
+
|
|
190
|
+
# Health check
|
|
191
|
+
evals doctor
|
|
192
|
+
|
|
193
|
+
# Register MCP server with Claude Code
|
|
194
|
+
evals mcp --claude
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## CI / GitHub Actions
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
- name: Run evals
|
|
203
|
+
run: |
|
|
204
|
+
evals ci run datasets/smoke.jsonl \
|
|
205
|
+
--adapter http \
|
|
206
|
+
--url ${{ env.APP_URL }} \
|
|
207
|
+
--baseline main \
|
|
208
|
+
--fail-if-regression 5
|
|
209
|
+
env:
|
|
210
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## MCP tools (for agents)
|
|
216
|
+
|
|
217
|
+
Register with Claude Code: `evals mcp --claude`
|
|
218
|
+
|
|
219
|
+
| Tool | Description |
|
|
220
|
+
|------|-------------|
|
|
221
|
+
| `evals_run` | Run a full eval dataset |
|
|
222
|
+
| `evals_run_single` | Judge a single response mid-session |
|
|
223
|
+
| `evals_judge` | One-shot LLM judge call |
|
|
224
|
+
| `evals_list_datasets` | List available datasets |
|
|
225
|
+
| `evals_get_results` | Get past run results |
|
|
226
|
+
| `evals_compare` | Compare two runs |
|
|
227
|
+
| `evals_create_case` | Add a case to a dataset |
|
|
228
|
+
| `evals_generate_cases` | Auto-generate cases from a description |
|
|
229
|
+
|
|
230
|
+
**Key agent pattern** — self-check before responding:
|
|
231
|
+
```
|
|
232
|
+
evals_run_single(
|
|
233
|
+
input: "What is the capital of France?",
|
|
234
|
+
output: "The capital of France is Paris.",
|
|
235
|
+
rubric: "Must correctly identify Paris as the capital."
|
|
236
|
+
)
|
|
237
|
+
→ PASS — The response correctly identifies Paris.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
Apache 2.0 — see [LICENSE](LICENSE)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"id":"mcp-001","input":"list tasks","adapter":{"type":"mcp","command":["todos-mcp"],"tool":"list_tasks","inputMapping":{"status":"pending"}},"assertions":[{"type":"json_valid"},{"type":"min_length","value":2}],"judge":{"rubric":"Response should be a valid list of tasks or an empty array. PASS if response is well-formed JSON."},"tags":["mcp-eval","todos"]}
|
|
2
|
+
{"id":"mcp-002","input":"get project status","adapter":{"type":"mcp","command":["todos-mcp"],"tool":"get_status"},"assertions":[{"type":"min_length","value":10}],"judge":{"rubric":"Should return status information including task counts. PASS if response contains meaningful project state."},"tags":["mcp-eval","todos"]}
|
|
3
|
+
{"id":"mcp-003","input":"search for AI tasks","adapter":{"type":"mcp","command":["todos-mcp"],"tool":"search_tasks","inputMapping":{"query":"{{input}}"}},"assertions":[{"type":"json_valid"}],"judge":{"rubric":"Should return search results or empty array. PASS if response is valid and well-structured."},"tags":["mcp-eval","search"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"id":"multi-001","turns":[{"role":"user","content":"I want to return an item."},{"role":"assistant","expected":"Asks for order ID or details"},{"role":"user","content":"My order is #12345."},{"role":"assistant","expected":"Confirms refund process and next steps"}],"judge":{"rubric":"Agent should collect order ID before confirming refund. Should not promise instant refund without verification. PASS if it asks for order ID and provides clear next steps."},"tags":["multi-turn","refund"]}
|
|
2
|
+
{"id":"multi-002","turns":[{"role":"user","content":"What's the weather like?"},{"role":"assistant","expected":"Asks for location"},{"role":"user","content":"In Paris."},{"role":"assistant","expected":"Provides weather or explains it cannot access real-time data"}],"judge":{"rubric":"Should ask for location on first turn (or assume a default). On second turn, should either provide weather info or clearly state it cannot access real-time data. PASS if interaction flows naturally."},"tags":["multi-turn","weather"]}
|
|
3
|
+
{"id":"multi-003","turns":[{"role":"user","content":"My name is Alice."},{"role":"assistant","expected":"Acknowledges the name"},{"role":"user","content":"What's my name?"},{"role":"assistant","expected":"Recalls the name Alice"}],"expected":"Agent should remember the user's name across turns","judge":{"rubric":"The agent must recall 'Alice' on the second turn. PASS only if it correctly references the name provided earlier."},"tags":["multi-turn","memory"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{"id":"smoke-001","input":"Hello, what can you do?","expected":"A welcoming response that lists capabilities","assertions":[{"type":"min_length","value":20},{"type":"not_contains","value":"I cannot"},{"type":"max_length","value":500}],"judge":{"rubric":"Response should be friendly and list at least 2-3 capabilities. PASS if welcoming and informative."},"tags":["smoke","greeting"]}
|
|
2
|
+
{"id":"smoke-002","input":"What is 2 + 2?","expected":"The answer is 4","assertions":[{"type":"contains","value":"4"}],"judge":{"rubric":"Must answer with 4. Any format is fine. PASS if correct."},"tags":["smoke","math"]}
|
|
3
|
+
{"id":"smoke-003","input":"Respond with valid JSON: {\"status\": \"ok\"}","expected":"Valid JSON response","assertions":[{"type":"json_valid"}],"judge":{"rubric":"Response must be valid JSON. PASS if parseable."},"tags":["smoke","json"]}
|
|
4
|
+
{"id":"smoke-004","input":"Say exactly: Hello World","expected":"Hello World","assertions":[{"type":"contains","value":"Hello World"}],"tags":["smoke","exact"]}
|
|
5
|
+
{"id":"smoke-005","input":"Write a one-sentence summary of AI.","expected":"A concise one-sentence definition of AI","assertions":[{"type":"min_length","value":10},{"type":"max_length","value":200}],"judge":{"rubric":"Must be exactly one sentence describing AI. PASS if concise and accurate."},"tags":["smoke","summary"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"id":"tool-001","input":"Search for the latest news about AI.","expected":"Calls a search tool","assertions":[{"type":"tool_called","value":"search"},{"type":"tool_call_count","min":1,"max":3}],"judge":{"rubric":"Should invoke a search tool with a relevant query. PASS if search tool is called with 'AI' or 'artificial intelligence' in the query."},"tags":["tool-use","search"]}
|
|
2
|
+
{"id":"tool-002","input":"Get the current time.","expected":"Calls get_time tool","assertions":[{"type":"tool_called","value":"get_time"},{"type":"tool_not_called","value":"search"}],"judge":{"rubric":"Should use get_time tool, not search. PASS if appropriate tool is selected."},"tags":["tool-use","time"]}
|
|
3
|
+
{"id":"tool-003","input":"Calculate 15% tip on $47.50","expected":"Returns the correct tip amount","assertions":[{"type":"contains","value":"7.13"},{"type":"not_contains","value":"Error"}],"judge":{"rubric":"Must calculate 15% of $47.50 = $7.125, rounded to $7.13. PASS if correct."},"tags":["tool-use","math"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.test.d.ts","sourceRoot":"","sources":["../../src/adapters/adapters.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnthropicAdapterConfig, ConversationTurn } from "../types/index.js";
|
|
2
|
+
import type { AdapterResponse } from "./http.js";
|
|
3
|
+
export declare function callAnthropicAdapter(config: AnthropicAdapterConfig, input: string, turns?: ConversationTurn[]): Promise<AdapterResponse>;
|
|
4
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/adapters/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,sBAAsB,EAC9B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,gBAAgB,EAAE,GACzB,OAAO,CAAC,eAAe,CAAC,CA+C1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/adapters/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CA4C1B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FunctionAdapterConfig } from "../types/index.js";
|
|
2
|
+
import type { AdapterResponse } from "./http.js";
|
|
3
|
+
export declare function callFunctionAdapter(config: FunctionAdapterConfig, input: string): Promise<AdapterResponse>;
|
|
4
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/adapters/function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CA2B1B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpAdapterConfig, ConversationTurn } from "../types/index.js";
|
|
2
|
+
export interface AdapterResponse {
|
|
3
|
+
output: string;
|
|
4
|
+
durationMs: number;
|
|
5
|
+
inputTokens?: number;
|
|
6
|
+
outputTokens?: number;
|
|
7
|
+
costUsd?: number;
|
|
8
|
+
toolCalls?: Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
arguments?: Record<string, unknown>;
|
|
11
|
+
}>;
|
|
12
|
+
statusCode?: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function callHttpAdapter(config: HttpAdapterConfig, input: string, turns?: ConversationTurn[]): Promise<AdapterResponse>;
|
|
16
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/adapters/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+BD,wBAAsB,eAAe,CACnC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,gBAAgB,EAAE,GACzB,OAAO,CAAC,eAAe,CAAC,CAqE1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/adapters/mcp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAqD1B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OpenAIAdapterConfig, ConversationTurn } from "../types/index.js";
|
|
2
|
+
import type { AdapterResponse } from "./http.js";
|
|
3
|
+
export declare function callOpenAIAdapter(config: OpenAIAdapterConfig, input: string, turns?: ConversationTurn[]): Promise<AdapterResponse>;
|
|
4
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,gBAAgB,EAAE,GACzB,OAAO,CAAC,eAAe,CAAC,CAmD1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-parser.d.ts","sourceRoot":"","sources":["../../src/cli/adapter-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CA8B9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.test.d.ts","sourceRoot":"","sources":["../../src/cli/cli.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calibrate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/calibrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,gBAAgB,IAAI,OAAO,CA+C1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,cAAc,IAAI,OAAO,CAyExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/ci.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,SAAS,IAAI,OAAO,CA0DnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,cAAc,IAAI,OAAO,CAgCxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,aAAa,IAAI,OAAO,CAoDvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/estimate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,eAAe,IAAI,OAAO,CA2CzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,wBAAgB,eAAe,IAAI,OAAO,CA2CzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/judge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,YAAY,IAAI,OAAO,CA+BtC"}
|