@frogbotai/plugin-ai-evals 0.0.0-stage → 0.43.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 +21 -0
- package/README.md +4 -2
- package/dist/checks.d.ts +23 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +71 -0
- package/dist/checks.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +132 -0
- package/dist/cli.js.map +1 -0
- package/dist/collections.d.ts +21 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +367 -0
- package/dist/collections.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/judge.d.ts +11 -0
- package/dist/judge.d.ts.map +1 -0
- package/dist/judge.js +51 -0
- package/dist/judge.js.map +1 -0
- package/dist/options.d.ts +15 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +20 -0
- package/dist/options.js.map +1 -0
- package/dist/runCase.d.ts +27 -0
- package/dist/runCase.d.ts.map +1 -0
- package/dist/runCase.js +160 -0
- package/dist/runCase.js.map +1 -0
- package/dist/scorers.d.ts +45 -0
- package/dist/scorers.d.ts.map +1 -0
- package/dist/scorers.js +35 -0
- package/dist/scorers.js.map +1 -0
- package/dist/workflow.d.ts +16 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +145 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +46 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FrogBot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @frogbotai/plugin-ai-evals
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Test cases, scorers and scored runs for FrogBot agents, from the admin or CI.
|
|
4
|
+
|
|
5
|
+
See the [evals documentation](https://docs.frogbot.ai/plugins/ai-evals).
|
package/dist/checks.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Scorer } from './scorers.js';
|
|
2
|
+
/** Plain checks that score 0 or 1. */
|
|
3
|
+
export declare const checks: {
|
|
4
|
+
/** The answer, trimmed, equals `text`, or the case's `expected` when `text` is unset. */
|
|
5
|
+
equals: (text?: string) => Scorer;
|
|
6
|
+
/** The answer contains `text`, or every string in it. */
|
|
7
|
+
includes: (text: string | readonly string[]) => Scorer;
|
|
8
|
+
/** The answer matches `pattern`. */
|
|
9
|
+
matches: (pattern: RegExp) => Scorer;
|
|
10
|
+
/** The agent called `tool` at least once. */
|
|
11
|
+
calledTool: (tool: string) => Scorer;
|
|
12
|
+
/** The agent never called `tool`. */
|
|
13
|
+
didNotCall: (tool: string) => Scorer;
|
|
14
|
+
/** The agent called `tools` in this order; other calls may come between them. */
|
|
15
|
+
toolOrder: (tools: readonly string[]) => Scorer;
|
|
16
|
+
/** The agent made at most `max` tool calls. */
|
|
17
|
+
maxToolCalls: (max: number) => Scorer;
|
|
18
|
+
/** No tool call failed. */
|
|
19
|
+
noToolErrors: () => Scorer;
|
|
20
|
+
/** The agent called every tool in the case's `expectedTools`. */
|
|
21
|
+
expectedTools: () => Scorer;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AAWxD,sCAAsC;AACtC,eAAO,MAAM,MAAM;IACjB,yFAAyF;oBACzE,MAAM,KAAG,MAAM;IAW/B,yDAAyD;qBACxC,MAAM,GAAG,SAAS,MAAM,EAAE,KAAG,MAAM;IAWpD,oCAAoC;uBACjB,MAAM,KAAG,MAAM;IASlC,6CAA6C;uBAC1B,MAAM,KAAG,MAAM;IAKlC,qCAAqC;uBAClB,MAAM,KAAG,MAAM;IAKlC,iFAAiF;uBAC9D,SAAS,MAAM,EAAE,KAAG,MAAM;IAgB7C,+CAA+C;wBAC3B,MAAM,KAAG,MAAM;IAMnC,2BAA2B;wBACT,MAAM;IASxB,iEAAiE;yBAC9C,MAAM;CAa1B,CAAC"}
|
package/dist/checks.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineScorer } from './scorers.js';
|
|
2
|
+
function pass(ok, reason) {
|
|
3
|
+
return ok ? {
|
|
4
|
+
score: 1
|
|
5
|
+
} : {
|
|
6
|
+
score: 0,
|
|
7
|
+
reason
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function names(calls) {
|
|
11
|
+
return calls.map(({ toolName })=>toolName);
|
|
12
|
+
}
|
|
13
|
+
/** Plain checks that score 0 or 1. */ export const checks = {
|
|
14
|
+
/** The answer, trimmed, equals `text`, or the case's `expected` when `text` is unset. */ equals: (text)=>defineScorer({
|
|
15
|
+
score: ({ output, expected })=>{
|
|
16
|
+
const want = text ?? expected;
|
|
17
|
+
if (want === undefined) throw new Error('equals() needs `expected` on the case.');
|
|
18
|
+
return pass(output.trim() === want.trim(), `Expected "${want.trim()}".`);
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
/** The answer contains `text`, or every string in it. */ includes: (text)=>defineScorer({
|
|
22
|
+
score: ({ output })=>{
|
|
23
|
+
const missing = (typeof text === 'string' ? [
|
|
24
|
+
text
|
|
25
|
+
] : text).filter((part)=>!output.includes(part));
|
|
26
|
+
return pass(missing.length === 0, `Missing "${missing.join('", "')}".`);
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
/** The answer matches `pattern`. */ matches: (pattern)=>defineScorer({
|
|
30
|
+
score: ({ output })=>{
|
|
31
|
+
pattern.lastIndex = 0;
|
|
32
|
+
return pass(pattern.test(output), `Doesn't match ${String(pattern)}.`);
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
/** The agent called `tool` at least once. */ calledTool: (tool)=>defineScorer({
|
|
36
|
+
score: ({ toolCalls })=>pass(names(toolCalls).includes(tool), `Never called ${tool}.`)
|
|
37
|
+
}),
|
|
38
|
+
/** The agent never called `tool`. */ didNotCall: (tool)=>defineScorer({
|
|
39
|
+
score: ({ toolCalls })=>pass(!names(toolCalls).includes(tool), `Called ${tool}.`)
|
|
40
|
+
}),
|
|
41
|
+
/** The agent called `tools` in this order; other calls may come between them. */ toolOrder: (tools)=>defineScorer({
|
|
42
|
+
score: ({ toolCalls })=>{
|
|
43
|
+
let next = 0;
|
|
44
|
+
for (const name of names(toolCalls)){
|
|
45
|
+
if (name === tools[next]) next++;
|
|
46
|
+
}
|
|
47
|
+
return pass(next === tools.length, `Called ${names(toolCalls).join(', ') || 'no tools'}, not ${tools.join(' then ')}.`);
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
/** The agent made at most `max` tool calls. */ maxToolCalls: (max)=>defineScorer({
|
|
51
|
+
score: ({ toolCalls })=>pass(toolCalls.length <= max, `Made ${toolCalls.length} tool calls, more than ${max}.`)
|
|
52
|
+
}),
|
|
53
|
+
/** No tool call failed. */ noToolErrors: ()=>defineScorer({
|
|
54
|
+
score: ({ toolCalls })=>{
|
|
55
|
+
const failed = toolCalls.filter((call)=>call.error !== undefined);
|
|
56
|
+
return pass(failed.length === 0, `${names(failed).join(', ')} failed.`);
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
/** The agent called every tool in the case's `expectedTools`. */ expectedTools: ()=>defineScorer({
|
|
60
|
+
score: ({ toolCalls, expectedTools })=>{
|
|
61
|
+
if (!expectedTools?.length) {
|
|
62
|
+
throw new Error('expectedTools() needs `expectedTools` on the case.');
|
|
63
|
+
}
|
|
64
|
+
const called = names(toolCalls);
|
|
65
|
+
const missing = expectedTools.filter((tool)=>!called.includes(tool));
|
|
66
|
+
return pass(missing.length === 0, `Never called ${missing.join(', ')}.`);
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/checks.ts"],"names":["defineScorer","pass","ok","reason","score","names","calls","map","toolName","checks","equals","text","output","expected","want","undefined","Error","trim","includes","missing","filter","part","length","join","matches","pattern","lastIndex","test","String","calledTool","tool","toolCalls","didNotCall","toolOrder","tools","next","name","maxToolCalls","max","noToolErrors","failed","call","error","expectedTools","called"],"mappings":"AACA,SAASA,YAAY,QAAQ,eAAe;AAE5C,SAASC,KAAKC,EAAW,EAAEC,MAAc;I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gBAEA,MAAM4B,SAASvC,MAAM0B;gBACrB,MAAMZ,UAAUwB,cAAcvB,MAAM,CAAC,CAACU,OAAS,CAACc,OAAO1B,QAAQ,CAACY;gBAEhE,OAAO7B,KAAKkB,QAAQG,MAAM,KAAK,GAAG,CAAC,aAAa,EAAEH,QAAQI,IAAI,CAAC,MAAM,CAAC,CAAC;YACzE;QACF;AACJ,EAAE","file":"checks.js"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CLICommand } from 'frogbot';
|
|
2
|
+
export type EvalsRunArgs = {
|
|
3
|
+
dataset: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
minScore?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseEvalsRunArgs(args: readonly string[]): EvalsRunArgs;
|
|
8
|
+
/** `frogbot evals:run`: runs a dataset with no user, in this process, and fails below `--min-score`. */
|
|
9
|
+
export declare const evalsRunCommand: CLICommand;
|
|
10
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,SAAS,CAAC;AAM1D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAqCvE;AA+DD,wGAAwG;AACxG,eAAO,MAAM,eAAe,EAAE,UAkC7B,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { DATASETS, runJobID, RUNS } from './collections.js';
|
|
2
|
+
import { RUN_RETRIES } from './workflow.js';
|
|
3
|
+
const usage = 'Usage: frogbot evals:run <dataset> [--model <id>] [--min-score <0-1>]';
|
|
4
|
+
export function parseEvalsRunArgs(args) {
|
|
5
|
+
const positional = [];
|
|
6
|
+
const flags = {};
|
|
7
|
+
for(let index = 0; index < args.length; index++){
|
|
8
|
+
const arg = args[index];
|
|
9
|
+
if (!arg.startsWith('--')) {
|
|
10
|
+
positional.push(arg);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const [name, inline] = arg.slice(2).split(/=(.*)/s, 2);
|
|
14
|
+
const value = inline ?? args[++index];
|
|
15
|
+
if (name !== 'model' && name !== 'min-score') {
|
|
16
|
+
throw new Error(`Unknown flag --${name}. ${usage}`);
|
|
17
|
+
}
|
|
18
|
+
if (value === undefined || value === '') throw new Error(`--${name} needs a value. ${usage}`);
|
|
19
|
+
flags[name] = value;
|
|
20
|
+
}
|
|
21
|
+
if (positional.length !== 1) throw new Error(usage);
|
|
22
|
+
const minScore = flags['min-score'] === undefined ? undefined : Number(flags['min-score']);
|
|
23
|
+
if (minScore !== undefined && !(minScore >= 0 && minScore <= 1)) {
|
|
24
|
+
throw new Error(`--min-score must be a number from 0 to 1. ${usage}`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
dataset: positional[0],
|
|
28
|
+
...flags.model === undefined ? {} : {
|
|
29
|
+
model: flags.model
|
|
30
|
+
},
|
|
31
|
+
...minScore === undefined ? {} : {
|
|
32
|
+
minScore
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function findDataset(frogbot, nameOrID) {
|
|
37
|
+
const { docs } = await frogbot.find({
|
|
38
|
+
collection: DATASETS,
|
|
39
|
+
where: {
|
|
40
|
+
name: {
|
|
41
|
+
equals: nameOrID
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
limit: 1,
|
|
45
|
+
depth: 0,
|
|
46
|
+
overrideAccess: true
|
|
47
|
+
});
|
|
48
|
+
const byName = docs[0]?.id;
|
|
49
|
+
if (byName !== undefined) return byName;
|
|
50
|
+
const byID = await frogbot.findByID({
|
|
51
|
+
collection: DATASETS,
|
|
52
|
+
id: nameOrID,
|
|
53
|
+
depth: 0,
|
|
54
|
+
disableErrors: true,
|
|
55
|
+
overrideAccess: true
|
|
56
|
+
}).catch(()=>null);
|
|
57
|
+
if (!byID) throw new Error(`No eval dataset named or with ID '${nameOrID}'.`);
|
|
58
|
+
return byID.id;
|
|
59
|
+
}
|
|
60
|
+
async function readRun(frogbot, id) {
|
|
61
|
+
return await frogbot.findByID({
|
|
62
|
+
collection: RUNS,
|
|
63
|
+
id,
|
|
64
|
+
depth: 0,
|
|
65
|
+
overrideAccess: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function waitingJob(frogbot, run) {
|
|
69
|
+
const { docs } = await frogbot.find({
|
|
70
|
+
collection: 'payload-jobs',
|
|
71
|
+
where: {
|
|
72
|
+
and: [
|
|
73
|
+
{
|
|
74
|
+
jobId: {
|
|
75
|
+
equals: runJobID(run)
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
completedAt: {
|
|
80
|
+
exists: false
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
hasError: {
|
|
85
|
+
not_equals: true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
limit: 1,
|
|
91
|
+
depth: 0,
|
|
92
|
+
overrideAccess: true
|
|
93
|
+
});
|
|
94
|
+
return docs[0]?.id;
|
|
95
|
+
}
|
|
96
|
+
function format(score) {
|
|
97
|
+
return typeof score === 'number' ? score.toFixed(3) : '—';
|
|
98
|
+
}
|
|
99
|
+
/** `frogbot evals:run`: runs a dataset with no user, in this process, and fails below `--min-score`. */ export const evalsRunCommand = async ({ args, getFrogBot })=>{
|
|
100
|
+
const parsed = parseEvalsRunArgs(args);
|
|
101
|
+
const frogbot = await getFrogBot();
|
|
102
|
+
const dataset = await findDataset(frogbot, parsed.dataset);
|
|
103
|
+
const created = await frogbot.create({
|
|
104
|
+
collection: RUNS,
|
|
105
|
+
data: {
|
|
106
|
+
dataset,
|
|
107
|
+
...parsed.model ? {
|
|
108
|
+
model: parsed.model
|
|
109
|
+
} : {}
|
|
110
|
+
},
|
|
111
|
+
depth: 0,
|
|
112
|
+
overrideAccess: true
|
|
113
|
+
});
|
|
114
|
+
for(let attempt = 0; attempt <= RUN_RETRIES; attempt++){
|
|
115
|
+
const job = await waitingJob(frogbot, created.id);
|
|
116
|
+
if (job === undefined) break;
|
|
117
|
+
await frogbot.jobs.runByID({
|
|
118
|
+
id: job,
|
|
119
|
+
overrideAccess: true,
|
|
120
|
+
silent: true
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const run = await readRun(frogbot, created.id);
|
|
124
|
+
for (const [name, mean] of Object.entries(run.scorerMeans ?? {})){
|
|
125
|
+
process.stdout.write(`${name}: ${format(mean)}\n`);
|
|
126
|
+
}
|
|
127
|
+
process.stdout.write(`score: ${format(run.score)} · ${run.passed ?? 0}/${run.total ?? 0} passed · ${run.errored ?? 0} errored · ${run.status}\n`);
|
|
128
|
+
const belowMin = parsed.minScore !== undefined && (run.score === null || run.score < parsed.minScore);
|
|
129
|
+
if (run.status !== 'completed' || (run.errored ?? 0) > 0 || belowMin) process.exitCode = 1;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"names":["DATASETS","runJobID","RUNS","RUN_RETRIES","usage","parseEvalsRunArgs","args","positional","flags","index","length","arg","startsWith","push","name","inline","slice","split","value","Error","undefined","minScore","Number","dataset","model","findDataset","frogbot","nameOrID","docs","find","collection","where","equals","limit","depth","overrideAccess","byName","id","byID","findByID","disableErrors","catch","readRun","waitingJob","run","and","jobId","completedAt","exists","hasError","not_equals","format","score","toFixed","evalsRunCommand","getFrogBot","parsed","created","create","data","attempt","job","jobs","runByID","silent","mean","Object","entries","scorerMeans","process","stdout","write","passed","total","errored","status","belowMin","exitCode"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,QAAQ,mBAAmB;AAE5D,SAASC,WAAW,QAAQ,gBAAgB;AAQ5C,MAAMC,QAAQ;AAEd,OAAO,SAASC,kBAAkBC,IAAuB;IACvD,MAAMC,aAAuB,EAAE;IAC/B,MAAMC,QAAgC,CAAC;IAEvC,IAAK,IAAIC,QAAQ,GAAGA,QAAQH,KAAKI,MAAM,EAAED,QAAS;QAChD,MAAME,MAAML,IAAI,CAACG,MAAM;QAEvB,IAAI,CAACE,IAAIC,UAAU,CAAC,OAAO;YACzBL,WAAWM,IAAI,CAACF;YAChB;QACF;QAEA,MAAM,CAACG,MAAMC,OAAO,GAAGJ,IAAIK,KAAK,CAAC,GAAGC,KAAK,CAAC,UAAU;QACpD,MAAMC,QAAQH,UAAUT,IAAI,CAAC,EAAEG,MAAM;QAErC,IAAIK,SAAS,WAAWA,SAAS,aAAa;YAC5C,MAAM,IAAIK,MAAM,CAAC,eAAe,EAAEL,KAAK,EAAE,EAAEV,OAAO;QACpD;QAEA,IAAIc,UAAUE,aAAaF,UAAU,IAAI,MAAM,IAAIC,MAAM,CAAC,EAAE,EAAEL,KAAK,gBAAgB,EAAEV,OAAO;QAE5FI,KAAK,CAACM,KAAK,GAAGI;IAChB;IAEA,IAAIX,WAAWG,MAAM,KAAK,GAAG,MAAM,IAAIS,MAAMf;IAE7C,MAAMiB,WAAWb,KAAK,CAAC,YAAY,KAAKY,YAAYA,YAAYE,OAAOd,KAAK,CAAC,YAAY;IAEzF,IAAIa,aAAaD,aAAa,CAAEC,CAAAA,YAAY,KAAKA,YAAY,CAAA,GAAI;QAC/D,MAAM,IAAIF,MAAM,CAAC,0CAA0C,EAAEf,OAAO;IACtE;IAEA,OAAO;QACLmB,SAAShB,UAAU,CAAC,EAAE;QACtB,GAAIC,MAAMgB,KAAK,KAA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EAAE7B,IAAI8B,OAAO,IAAI,EAAE,WAAW,EAAE9B,IAAI+B,MAAM,CAAC,EAAE,CAAC;IAG7H,MAAMC,WACJpB,OAAOnC,QAAQ,KAAKD,aAAcwB,CAAAA,IAAIQ,KAAK,KAAK,QAAQR,IAAIQ,KAAK,GAAGI,OAAOnC,QAAQ,AAAD;IAEpF,IAAIuB,IAAI+B,MAAM,KAAK,eAAe,AAAC/B,CAAAA,IAAI8B,OAAO,IAAI,CAAA,IAAK,KAAKE,UAAUP,QAAQQ,QAAQ,GAAG;AAC3F,EAAE","file":"cli.js"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CollectionAccess, CollectionConfig, DocID } from 'frogbot';
|
|
2
|
+
export declare const DATASETS = "eval-datasets";
|
|
3
|
+
export declare const CASES = "eval-cases";
|
|
4
|
+
export declare const RUNS = "eval-runs";
|
|
5
|
+
export declare const RESULTS = "eval-results";
|
|
6
|
+
export declare const WORKFLOW = "frogbot-eval-run";
|
|
7
|
+
/** Set on the plugin's own writes to a run, so its hooks leave them alone. */
|
|
8
|
+
export declare const PLUGIN_WRITE = "pluginEvalsWrite";
|
|
9
|
+
export type EvalRunInput = {
|
|
10
|
+
run: DocID;
|
|
11
|
+
userCollection?: string;
|
|
12
|
+
userID?: DocID;
|
|
13
|
+
};
|
|
14
|
+
export declare function runJobID(run: DocID): string;
|
|
15
|
+
export declare function toID(value: unknown): DocID | undefined;
|
|
16
|
+
export declare function createEvalCollections({ agents, scorers, access, }: {
|
|
17
|
+
agents: readonly string[];
|
|
18
|
+
scorers: readonly string[];
|
|
19
|
+
access?: CollectionAccess;
|
|
20
|
+
}): CollectionConfig[];
|
|
21
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAGhB,gBAAgB,EAChB,KAAK,EACN,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AACxC,eAAO,MAAM,KAAK,eAAe,CAAC;AAClC,eAAO,MAAM,IAAI,cAAc,CAAC;AAChC,eAAO,MAAM,OAAO,iBAAiB,CAAC;AACtC,eAAO,MAAM,QAAQ,qBAAqB,CAAC;AAE3C,8EAA8E;AAC9E,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAI/C,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,KAAK,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAgBF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAE3C;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAItD;AA2ED,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,OAAO,EACP,MAAM,GACP,EAAE;IACD,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B,GAAG,gBAAgB,EAAE,CA8GrB"}
|