Commit a55503b
authored
feat: add support for custom judges via evaluation metric key (#86)
**Requirements**
- [X] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [X] I have validated my changes against all supported platform
versions
**Related issues**
https://launchdarkly.atlassian.net/browse/REL-11511
See tech spec at
https://docs.google.com/document/d/1lzYwQqCcTzN_2zkxJZDfJtgUcEJ4jbpx0KSsJ2bRENw/edit?tab=t.0#heading=h.69bdm7karsxh
**Describe the solution you've provided**
Updating the SDK to check the AI Config's evaluationMetricKey property
which now exists. Also added missing tests from previous implementation,
and fallback to the original evaluationMetricKeys list.
**Describe alternatives you've considered**
Provide a clear and concise description of any alternative solutions or
features you've considered.
**Additional context**
Add any other context about the pull request here.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Implements single-key judge evaluation with backward compatibility and
comprehensive tests.
>
> - Switches judge configs to use `evaluationMetricKey` (deprecated
`evaluationMetricKeys`), updating `AIJudgeConfig(Default)` serialization
> - `LDAIClient.__evaluate` now returns the raw `variation`;
`judge_config` extracts `evaluationMetricKey` with fallback to first in
`evaluationMetricKeys`
> - `Judge` updated to validate and parse a single metric;
`EvaluationSchemaBuilder` builds a single-key structured schema; minor
cleanup of unused imports/comments
> - Adds extensive unit tests for judge behavior, schema building, and
client extraction (including consistency of single variation, sampling,
error paths)
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c6d086a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->5 files changed
Lines changed: 709 additions & 77 deletions
File tree
- packages/sdk/server-ai
- src/ldai
- judge
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
106 | 119 | | |
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
110 | | - | |
| 123 | + | |
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
| |||
144 | 157 | | |
145 | 158 | | |
146 | 159 | | |
147 | | - | |
| 160 | + | |
148 | 161 | | |
149 | 162 | | |
150 | 163 | | |
| |||
160 | 173 | | |
161 | 174 | | |
162 | 175 | | |
163 | | - | |
164 | 176 | | |
165 | 177 | | |
166 | | - | |
167 | | - | |
| 178 | + | |
168 | 179 | | |
169 | | - | |
| 180 | + | |
170 | 181 | | |
171 | | - | |
172 | 182 | | |
173 | 183 | | |
174 | 184 | | |
175 | 185 | | |
176 | 186 | | |
177 | 187 | | |
178 | 188 | | |
179 | | - | |
180 | 189 | | |
181 | 190 | | |
182 | | - | |
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
188 | 196 | | |
189 | | - | |
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
| |||
279 | 286 | | |
280 | 287 | | |
281 | 288 | | |
282 | | - | |
283 | 289 | | |
284 | 290 | | |
285 | 291 | | |
| |||
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
336 | | - | |
337 | 342 | | |
338 | 343 | | |
339 | 344 | | |
| |||
399 | 404 | | |
400 | 405 | | |
401 | 406 | | |
402 | | - | |
403 | 407 | | |
404 | 408 | | |
405 | 409 | | |
| |||
538 | 542 | | |
539 | 543 | | |
540 | 544 | | |
541 | | - | |
| 545 | + | |
542 | 546 | | |
543 | 547 | | |
544 | 548 | | |
| |||
547 | 551 | | |
548 | 552 | | |
549 | 553 | | |
550 | | - | |
| 554 | + | |
551 | 555 | | |
552 | 556 | | |
553 | 557 | | |
| |||
556 | 560 | | |
557 | 561 | | |
558 | 562 | | |
559 | | - | |
560 | 563 | | |
561 | 564 | | |
562 | 565 | | |
| |||
571 | 574 | | |
572 | 575 | | |
573 | 576 | | |
574 | | - | |
575 | 577 | | |
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
579 | | - | |
580 | 581 | | |
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
584 | 585 | | |
585 | | - | |
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
597 | 596 | | |
598 | 597 | | |
599 | 598 | | |
| |||
606 | 605 | | |
607 | 606 | | |
608 | 607 | | |
609 | | - | |
610 | 608 | | |
611 | 609 | | |
612 | 610 | | |
| |||
622 | 620 | | |
623 | 621 | | |
624 | 622 | | |
625 | | - | |
| 623 | + | |
626 | 624 | | |
627 | 625 | | |
628 | 626 | | |
| |||
640 | 638 | | |
641 | 639 | | |
642 | 640 | | |
643 | | - | |
| 641 | + | |
644 | 642 | | |
645 | 643 | | |
646 | 644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | | - | |
43 | | - | |
| 40 | + | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
| |||
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | | - | |
| 59 | + | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
| |||
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
| 72 | + | |
75 | 73 | | |
76 | | - | |
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
| |||
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
86 | | - | |
87 | | - | |
| 83 | + | |
| 84 | + | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
| |||
191 | 188 | | |
192 | 189 | | |
193 | 190 | | |
194 | | - | |
195 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
196 | 195 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 196 | + | |
200 | 197 | | |
201 | | - | |
202 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
203 | 201 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 202 | + | |
| 203 | + | |
210 | 204 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
217 | 218 | | |
218 | | - | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
Lines changed: 19 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
| 32 | + | |
30 | 33 | | |
31 | | - | |
32 | | - | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
41 | | - | |
| 44 | + | |
42 | 45 | | |
43 | | - | |
| 46 | + | |
44 | 47 | | |
45 | | - | |
46 | | - | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
0 commit comments