agentv 3.10.2 → 3.10.3
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/dist/{chunk-6UE665XI.js → chunk-7LC3VNOC.js} +4 -4
- package/dist/{chunk-KGK5NUFG.js → chunk-JUQCB3ZW.js} +56 -15
- package/dist/chunk-JUQCB3ZW.js.map +1 -0
- package/dist/{chunk-F7LAJMTO.js → chunk-U556GRI3.js} +4 -4
- package/dist/{chunk-F7LAJMTO.js.map → chunk-U556GRI3.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/{dist-3QUJEJUT.js → dist-2X7A3TTC.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{interactive-EO6AR2R3.js → interactive-CSA4KIND.js} +3 -3
- package/dist/templates/.agentv/.env.example +9 -11
- package/dist/templates/.agentv/config.yaml +13 -4
- package/dist/templates/.agentv/targets.yaml +16 -0
- package/package.json +1 -1
- package/dist/chunk-KGK5NUFG.js.map +0 -1
- package/dist/templates/.agents/skills/agentv-chat-to-eval/README.md +0 -84
- package/dist/templates/.agents/skills/agentv-chat-to-eval/SKILL.md +0 -144
- package/dist/templates/.agents/skills/agentv-chat-to-eval/examples/transcript-json.md +0 -67
- package/dist/templates/.agents/skills/agentv-chat-to-eval/examples/transcript-markdown.md +0 -101
- package/dist/templates/.agents/skills/agentv-eval-builder/SKILL.md +0 -458
- package/dist/templates/.agents/skills/agentv-eval-builder/references/config-schema.json +0 -36
- package/dist/templates/.agents/skills/agentv-eval-builder/references/custom-evaluators.md +0 -118
- package/dist/templates/.agents/skills/agentv-eval-builder/references/eval-schema.json +0 -12753
- package/dist/templates/.agents/skills/agentv-eval-builder/references/rubric-evaluator.md +0 -77
- package/dist/templates/.agents/skills/agentv-eval-orchestrator/SKILL.md +0 -50
- package/dist/templates/.agents/skills/agentv-prompt-optimizer/SKILL.md +0 -78
- package/dist/templates/.claude/skills/agentv-eval-builder/SKILL.md +0 -177
- package/dist/templates/.claude/skills/agentv-eval-builder/references/batch-cli-evaluator.md +0 -316
- package/dist/templates/.claude/skills/agentv-eval-builder/references/compare-command.md +0 -137
- package/dist/templates/.claude/skills/agentv-eval-builder/references/composite-evaluator.md +0 -215
- package/dist/templates/.claude/skills/agentv-eval-builder/references/config-schema.json +0 -27
- package/dist/templates/.claude/skills/agentv-eval-builder/references/custom-evaluators.md +0 -115
- package/dist/templates/.claude/skills/agentv-eval-builder/references/eval-schema.json +0 -278
- package/dist/templates/.claude/skills/agentv-eval-builder/references/example-evals.md +0 -333
- package/dist/templates/.claude/skills/agentv-eval-builder/references/rubric-evaluator.md +0 -79
- package/dist/templates/.claude/skills/agentv-eval-builder/references/structured-data-evaluators.md +0 -121
- package/dist/templates/.claude/skills/agentv-eval-builder/references/tool-trajectory-evaluator.md +0 -298
- package/dist/templates/.claude/skills/agentv-prompt-optimizer/SKILL.md +0 -78
- package/dist/templates/.github/prompts/agentv-eval-build.prompt.md +0 -5
- package/dist/templates/.github/prompts/agentv-optimize.prompt.md +0 -4
- /package/dist/{chunk-6UE665XI.js.map → chunk-7LC3VNOC.js.map} +0 -0
- /package/dist/{dist-3QUJEJUT.js.map → dist-2X7A3TTC.js.map} +0 -0
- /package/dist/{interactive-EO6AR2R3.js.map → interactive-CSA4KIND.js.map} +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Compare Command
|
|
2
|
-
|
|
3
|
-
Compare evaluation results between two runs to measure performance differences.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
agentv compare <baseline.jsonl> <candidate.jsonl> [options]
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Arguments
|
|
12
|
-
|
|
13
|
-
| Argument | Description |
|
|
14
|
-
|----------|-------------|
|
|
15
|
-
| `result1` | Path to baseline JSONL result file |
|
|
16
|
-
| `result2` | Path to candidate JSONL result file |
|
|
17
|
-
| `--threshold`, `-t` | Score delta threshold for win/loss classification (default: 0.1) |
|
|
18
|
-
| `--format`, `-f` | Output format: `table` (default) or `json` |
|
|
19
|
-
| `--json` | Shorthand for `--format=json` |
|
|
20
|
-
|
|
21
|
-
## How It Works
|
|
22
|
-
|
|
23
|
-
1. **Load Results**: Reads both JSONL files containing evaluation results
|
|
24
|
-
2. **Match by eval_id**: Pairs results with matching `eval_id` fields
|
|
25
|
-
3. **Compute Deltas**: Calculates `delta = score2 - score1` for each pair
|
|
26
|
-
4. **Classify Outcomes**:
|
|
27
|
-
- `win`: delta >= threshold (candidate better)
|
|
28
|
-
- `loss`: delta <= -threshold (baseline better)
|
|
29
|
-
- `tie`: |delta| < threshold (no significant difference)
|
|
30
|
-
5. **Output Summary**: Human-readable table (default) or JSON
|
|
31
|
-
|
|
32
|
-
## Output Format
|
|
33
|
-
|
|
34
|
-
### Table Format (default)
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
Comparing: baseline.jsonl → candidate.jsonl
|
|
38
|
-
|
|
39
|
-
Eval ID Baseline Candidate Delta Result
|
|
40
|
-
───────────── ──────── ───────── ──────── ────────
|
|
41
|
-
safety-check 0.70 0.90 +0.20 ✓ win
|
|
42
|
-
accuracy-test 0.85 0.80 -0.05 = tie
|
|
43
|
-
latency-eval 0.90 0.75 -0.15 ✗ loss
|
|
44
|
-
|
|
45
|
-
Summary: 1 win, 1 loss, 1 tie | Mean Δ: +0.000 | Status: neutral
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Colors are used to highlight wins (green), losses (red), and ties (gray). Colors are automatically disabled when output is piped or `NO_COLOR` is set.
|
|
49
|
-
|
|
50
|
-
### JSON Format (`--json`)
|
|
51
|
-
|
|
52
|
-
Output uses snake_case for Python ecosystem compatibility:
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
{
|
|
56
|
-
"matched": [
|
|
57
|
-
{
|
|
58
|
-
"eval_id": "case-1",
|
|
59
|
-
"score1": 0.7,
|
|
60
|
-
"score2": 0.9,
|
|
61
|
-
"delta": 0.2,
|
|
62
|
-
"outcome": "win"
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
"unmatched": {
|
|
66
|
-
"file1": 0,
|
|
67
|
-
"file2": 0
|
|
68
|
-
},
|
|
69
|
-
"summary": {
|
|
70
|
-
"total": 2,
|
|
71
|
-
"matched": 1,
|
|
72
|
-
"wins": 1,
|
|
73
|
-
"losses": 0,
|
|
74
|
-
"ties": 0,
|
|
75
|
-
"mean_delta": 0.2
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Exit Codes
|
|
81
|
-
|
|
82
|
-
| Code | Meaning |
|
|
83
|
-
|------|---------|
|
|
84
|
-
| `0` | Candidate is equal or better (meanDelta >= 0) |
|
|
85
|
-
| `1` | Baseline is better (regression detected) |
|
|
86
|
-
|
|
87
|
-
## Workflow Examples
|
|
88
|
-
|
|
89
|
-
### Model Comparison
|
|
90
|
-
|
|
91
|
-
Compare different model versions:
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# Run baseline evaluation
|
|
95
|
-
agentv eval evals/*.yaml --target gpt-4 --out baseline.jsonl
|
|
96
|
-
|
|
97
|
-
# Run candidate evaluation
|
|
98
|
-
agentv eval evals/*.yaml --target gpt-4o --out candidate.jsonl
|
|
99
|
-
|
|
100
|
-
# Compare results
|
|
101
|
-
agentv compare baseline.jsonl candidate.jsonl
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Prompt Optimization
|
|
105
|
-
|
|
106
|
-
Compare before/after prompt changes:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Run with original prompt
|
|
110
|
-
agentv eval evals/*.yaml --out before.jsonl
|
|
111
|
-
|
|
112
|
-
# Modify prompt, then run again
|
|
113
|
-
agentv eval evals/*.yaml --out after.jsonl
|
|
114
|
-
|
|
115
|
-
# Compare with strict threshold
|
|
116
|
-
agentv compare before.jsonl after.jsonl --threshold 0.05
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### CI Quality Gate
|
|
120
|
-
|
|
121
|
-
Fail CI if candidate regresses:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
#!/bin/bash
|
|
125
|
-
agentv compare baseline.jsonl candidate.jsonl
|
|
126
|
-
if [ $? -eq 1 ]; then
|
|
127
|
-
echo "Regression detected! Candidate performs worse than baseline."
|
|
128
|
-
exit 1
|
|
129
|
-
fi
|
|
130
|
-
echo "Candidate is equal or better than baseline."
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Tips
|
|
134
|
-
|
|
135
|
-
- **Threshold Selection**: Default 0.1 means 10% difference required. Use stricter thresholds (0.05) for critical evaluations.
|
|
136
|
-
- **Unmatched Results**: Check `unmatched` counts to identify eval cases that only exist in one file.
|
|
137
|
-
- **Multiple Comparisons**: Compare against multiple baselines by running the command multiple times.
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
# Composite Evaluator Guide
|
|
2
|
-
|
|
3
|
-
Composite evaluators combine multiple evaluators and aggregate their results. This enables sophisticated evaluation patterns like safety gates, weighted scoring, and conflict resolution.
|
|
4
|
-
|
|
5
|
-
## Basic Structure
|
|
6
|
-
|
|
7
|
-
```yaml
|
|
8
|
-
execution:
|
|
9
|
-
evaluators:
|
|
10
|
-
- name: my_composite
|
|
11
|
-
type: composite
|
|
12
|
-
evaluators:
|
|
13
|
-
- name: evaluator_1
|
|
14
|
-
type: llm_judge
|
|
15
|
-
prompt: ./prompts/check1.md
|
|
16
|
-
- name: evaluator_2
|
|
17
|
-
type: code_judge
|
|
18
|
-
script: uv run check2.py
|
|
19
|
-
aggregator:
|
|
20
|
-
type: weighted_average
|
|
21
|
-
weights:
|
|
22
|
-
evaluator_1: 0.6
|
|
23
|
-
evaluator_2: 0.4
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Aggregator Types
|
|
27
|
-
|
|
28
|
-
### 1. Weighted Average (Default)
|
|
29
|
-
|
|
30
|
-
Combines scores using weighted arithmetic mean:
|
|
31
|
-
|
|
32
|
-
```yaml
|
|
33
|
-
aggregator:
|
|
34
|
-
type: weighted_average
|
|
35
|
-
weights:
|
|
36
|
-
safety: 0.3 # 30% weight
|
|
37
|
-
quality: 0.7 # 70% weight
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
If weights are omitted, all evaluators have equal weight (1.0).
|
|
41
|
-
|
|
42
|
-
**Score calculation:**
|
|
43
|
-
```
|
|
44
|
-
final_score = Σ(score_i × weight_i) / Σ(weight_i)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### 2. Code Judge Aggregator
|
|
48
|
-
|
|
49
|
-
Run custom code to decide final score based on all evaluator results:
|
|
50
|
-
|
|
51
|
-
```yaml
|
|
52
|
-
aggregator:
|
|
53
|
-
type: code_judge
|
|
54
|
-
path: node ./scripts/safety-gate.js
|
|
55
|
-
cwd: ./evaluators # optional working directory
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Input (stdin):**
|
|
59
|
-
```json
|
|
60
|
-
{
|
|
61
|
-
"results": {
|
|
62
|
-
"safety": { "score": 0.9, "hits": [...], "misses": [...] },
|
|
63
|
-
"quality": { "score": 0.85, "hits": [...], "misses": [...] }
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Output (stdout):**
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"score": 0.87,
|
|
72
|
-
"verdict": "pass",
|
|
73
|
-
"hits": ["Combined check passed"],
|
|
74
|
-
"misses": [],
|
|
75
|
-
"reasoning": "Safety gate passed, quality acceptable"
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 3. LLM Judge Aggregator
|
|
80
|
-
|
|
81
|
-
Use an LLM to resolve conflicts or make nuanced decisions:
|
|
82
|
-
|
|
83
|
-
```yaml
|
|
84
|
-
aggregator:
|
|
85
|
-
type: llm_judge
|
|
86
|
-
prompt: ./prompts/conflict-resolution.md
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The `{{EVALUATOR_RESULTS_JSON}}` variable is replaced with the JSON results from all child evaluators.
|
|
90
|
-
|
|
91
|
-
## Example Patterns
|
|
92
|
-
|
|
93
|
-
### Safety Gate Pattern
|
|
94
|
-
|
|
95
|
-
Block outputs that fail safety even if quality is high:
|
|
96
|
-
|
|
97
|
-
```yaml
|
|
98
|
-
evalcases:
|
|
99
|
-
- id: safety-gated-response
|
|
100
|
-
expected_outcome: Safe and accurate response
|
|
101
|
-
|
|
102
|
-
input_messages:
|
|
103
|
-
- role: user
|
|
104
|
-
content: Explain quantum computing
|
|
105
|
-
|
|
106
|
-
execution:
|
|
107
|
-
evaluators:
|
|
108
|
-
- name: safety_gate
|
|
109
|
-
type: composite
|
|
110
|
-
evaluators:
|
|
111
|
-
- name: safety
|
|
112
|
-
type: llm_judge
|
|
113
|
-
prompt: ./prompts/safety-check.md
|
|
114
|
-
- name: quality
|
|
115
|
-
type: llm_judge
|
|
116
|
-
prompt: ./prompts/quality-check.md
|
|
117
|
-
aggregator:
|
|
118
|
-
type: code_judge
|
|
119
|
-
path: ./scripts/safety-gate.js
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Multi-Criteria Weighted Evaluation
|
|
123
|
-
|
|
124
|
-
```yaml
|
|
125
|
-
- name: release_readiness
|
|
126
|
-
type: composite
|
|
127
|
-
evaluators:
|
|
128
|
-
- name: correctness
|
|
129
|
-
type: llm_judge
|
|
130
|
-
prompt: ./prompts/correctness.md
|
|
131
|
-
- name: style
|
|
132
|
-
type: code_judge
|
|
133
|
-
script: uv run style_checker.py
|
|
134
|
-
- name: security
|
|
135
|
-
type: llm_judge
|
|
136
|
-
prompt: ./prompts/security.md
|
|
137
|
-
aggregator:
|
|
138
|
-
type: weighted_average
|
|
139
|
-
weights:
|
|
140
|
-
correctness: 0.5
|
|
141
|
-
style: 0.2
|
|
142
|
-
security: 0.3
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Nested Composites
|
|
146
|
-
|
|
147
|
-
Composites can contain other composites for complex hierarchies:
|
|
148
|
-
|
|
149
|
-
```yaml
|
|
150
|
-
- name: comprehensive_eval
|
|
151
|
-
type: composite
|
|
152
|
-
evaluators:
|
|
153
|
-
- name: content_quality
|
|
154
|
-
type: composite
|
|
155
|
-
evaluators:
|
|
156
|
-
- name: accuracy
|
|
157
|
-
type: llm_judge
|
|
158
|
-
prompt: ./prompts/accuracy.md
|
|
159
|
-
- name: clarity
|
|
160
|
-
type: llm_judge
|
|
161
|
-
prompt: ./prompts/clarity.md
|
|
162
|
-
aggregator:
|
|
163
|
-
type: weighted_average
|
|
164
|
-
weights:
|
|
165
|
-
accuracy: 0.6
|
|
166
|
-
clarity: 0.4
|
|
167
|
-
- name: safety
|
|
168
|
-
type: llm_judge
|
|
169
|
-
prompt: ./prompts/safety.md
|
|
170
|
-
aggregator:
|
|
171
|
-
type: weighted_average
|
|
172
|
-
weights:
|
|
173
|
-
content_quality: 0.7
|
|
174
|
-
safety: 0.3
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Result Structure
|
|
178
|
-
|
|
179
|
-
Composite evaluators return nested `evaluator_results`:
|
|
180
|
-
|
|
181
|
-
```json
|
|
182
|
-
{
|
|
183
|
-
"score": 0.85,
|
|
184
|
-
"verdict": "pass",
|
|
185
|
-
"hits": ["[safety] No harmful content", "[quality] Clear explanation"],
|
|
186
|
-
"misses": ["[quality] Could use more examples"],
|
|
187
|
-
"reasoning": "safety: Passed all checks; quality: Good but could improve",
|
|
188
|
-
"evaluator_results": [
|
|
189
|
-
{
|
|
190
|
-
"name": "safety",
|
|
191
|
-
"type": "llm_judge",
|
|
192
|
-
"score": 0.95,
|
|
193
|
-
"verdict": "pass",
|
|
194
|
-
"hits": ["No harmful content"],
|
|
195
|
-
"misses": []
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"name": "quality",
|
|
199
|
-
"type": "llm_judge",
|
|
200
|
-
"score": 0.8,
|
|
201
|
-
"verdict": "pass",
|
|
202
|
-
"hits": ["Clear explanation"],
|
|
203
|
-
"misses": ["Could use more examples"]
|
|
204
|
-
}
|
|
205
|
-
]
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Best Practices
|
|
210
|
-
|
|
211
|
-
1. **Name evaluators clearly** - Names appear in results and debugging output
|
|
212
|
-
2. **Use safety gates for critical checks** - Don't let high quality override safety failures
|
|
213
|
-
3. **Balance weights thoughtfully** - Consider which aspects matter most for your use case
|
|
214
|
-
4. **Keep nesting shallow** - Deep nesting makes debugging harder
|
|
215
|
-
5. **Test aggregators independently** - Verify your custom aggregation logic with unit tests
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "AgentV Config Schema",
|
|
4
|
-
"description": "Schema for .agentv/config.yaml configuration files",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"$schema": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "Schema identifier",
|
|
10
|
-
"enum": ["agentv-config-v2"]
|
|
11
|
-
},
|
|
12
|
-
"guideline_patterns": {
|
|
13
|
-
"type": "array",
|
|
14
|
-
"description": "Glob patterns for identifying guideline files (instructions, prompts). Files matching these patterns are treated as guidelines, while non-matching files are treated as regular file content.",
|
|
15
|
-
"items": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "Glob pattern (e.g., '**/*.instructions.md', '**/prompts/**')"
|
|
18
|
-
},
|
|
19
|
-
"examples": [
|
|
20
|
-
["**/*.instructions.md", "**/instructions/**", "**/*.prompt.md", "**/prompts/**"],
|
|
21
|
-
["**/*.guide.md", "**/guidelines/**", "docs/AGENTS.md"]
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"required": ["$schema"],
|
|
26
|
-
"additionalProperties": false
|
|
27
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Custom Evaluators
|
|
2
|
-
|
|
3
|
-
## Wire Format
|
|
4
|
-
|
|
5
|
-
### Input (stdin JSON)
|
|
6
|
-
|
|
7
|
-
```json
|
|
8
|
-
{
|
|
9
|
-
"question": "string",
|
|
10
|
-
"expected_outcome": "string",
|
|
11
|
-
"reference_answer": "string",
|
|
12
|
-
"candidate_answer": "string",
|
|
13
|
-
"guideline_files": ["path"],
|
|
14
|
-
"input_files": ["path"],
|
|
15
|
-
"input_messages": [{"role": "user", "content": "..."}],
|
|
16
|
-
"expected_messages": [{"role": "assistant", "content": "..."}],
|
|
17
|
-
"output_messages": [{"role": "assistant", "content": "..."}],
|
|
18
|
-
"trace_summary": {
|
|
19
|
-
"event_count": 5,
|
|
20
|
-
"tool_names": ["fetch"],
|
|
21
|
-
"tool_calls_by_name": {"fetch": 1},
|
|
22
|
-
"error_count": 0,
|
|
23
|
-
"token_usage": {"input": 1000, "output": 500},
|
|
24
|
-
"cost_usd": 0.0015,
|
|
25
|
-
"duration_ms": 3500
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Output (stdout JSON)
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
{
|
|
34
|
-
"score": 0.85,
|
|
35
|
-
"hits": ["passed check"],
|
|
36
|
-
"misses": ["failed check"],
|
|
37
|
-
"reasoning": "explanation"
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`score` (0.0-1.0) required. `hits`, `misses`, `reasoning` optional.
|
|
42
|
-
|
|
43
|
-
## SDK Functions
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import { defineCodeJudge, createTargetClient, definePromptTemplate } from '@agentv/eval';
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
- `defineCodeJudge(fn)` - Wraps evaluation function with stdin/stdout handling
|
|
50
|
-
- `createTargetClient()` - Returns LLM proxy client (when `target: {}` configured)
|
|
51
|
-
- `.invoke({question, systemPrompt})` - Single LLM call
|
|
52
|
-
- `.invokeBatch(requests)` - Batch LLM calls
|
|
53
|
-
- `definePromptTemplate(fn)` - Wraps prompt generation function
|
|
54
|
-
- Context fields: `question`, `candidateAnswer`, `referenceAnswer`, `expectedOutcome`, `expectedMessages`, `outputMessages`, `config`, `traceSummary`
|
|
55
|
-
|
|
56
|
-
## Python Example
|
|
57
|
-
|
|
58
|
-
```python
|
|
59
|
-
#!/usr/bin/env python3
|
|
60
|
-
import json, sys
|
|
61
|
-
|
|
62
|
-
def evaluate(data: dict) -> dict:
|
|
63
|
-
candidate = data.get("candidate_answer", "")
|
|
64
|
-
hits, misses = [], []
|
|
65
|
-
for kw in ["async", "await"]:
|
|
66
|
-
(hits if kw in candidate else misses).append(f"Keyword '{kw}'")
|
|
67
|
-
return {
|
|
68
|
-
"score": len(hits) / max(len(hits) + len(misses), 1),
|
|
69
|
-
"hits": hits, "misses": misses
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if __name__ == "__main__":
|
|
73
|
-
try:
|
|
74
|
-
print(json.dumps(evaluate(json.loads(sys.stdin.read()))))
|
|
75
|
-
except Exception as e:
|
|
76
|
-
print(json.dumps({"score": 0, "misses": [str(e)]}))
|
|
77
|
-
sys.exit(1)
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## TypeScript Example
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
#!/usr/bin/env bun
|
|
84
|
-
import { defineCodeJudge } from '@agentv/eval';
|
|
85
|
-
|
|
86
|
-
export default defineCodeJudge(({ candidateAnswer, expectedOutcome }) => {
|
|
87
|
-
const hits: string[] = [];
|
|
88
|
-
const misses: string[] = [];
|
|
89
|
-
if (candidateAnswer.includes(expectedOutcome)) {
|
|
90
|
-
hits.push('Matches expected outcome');
|
|
91
|
-
} else {
|
|
92
|
-
misses.push('Does not match expected outcome');
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
score: hits.length / Math.max(hits.length + misses.length, 1),
|
|
96
|
-
hits, misses,
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Template Variables
|
|
102
|
-
|
|
103
|
-
Derived from eval case fields (users never author these directly):
|
|
104
|
-
|
|
105
|
-
| Variable | Source |
|
|
106
|
-
|----------|--------|
|
|
107
|
-
| `question` | First user message in `input_messages` |
|
|
108
|
-
| `expected_outcome` | Eval case `expected_outcome` field |
|
|
109
|
-
| `reference_answer` | Last entry in `expected_messages` |
|
|
110
|
-
| `candidate_answer` | Last entry in `output_messages` (runtime) |
|
|
111
|
-
| `input_messages` | Full resolved input array (JSON) |
|
|
112
|
-
| `expected_messages` | Full resolved expected array (JSON) |
|
|
113
|
-
| `output_messages` | Full provider output array (JSON) |
|
|
114
|
-
|
|
115
|
-
Markdown templates use `{{variable}}` syntax. TypeScript templates receive context object.
|