@grekt/cli 6.43.0-beta.1 → 6.43.0-beta.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/index.js +17 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104390,18 +104390,15 @@ function detectPromptfoo() {
|
|
|
104390
104390
|
function getCommand(mode) {
|
|
104391
104391
|
return mode === "npx" ? ["npx", "promptfoo"] : ["promptfoo"];
|
|
104392
104392
|
}
|
|
104393
|
-
function
|
|
104393
|
+
function assemblePromptMessages(config) {
|
|
104394
|
+
return [
|
|
104395
|
+
{ role: "system", content: config.systemPrompt },
|
|
104396
|
+
{ role: "user", content: "{{input}}" }
|
|
104397
|
+
];
|
|
104398
|
+
}
|
|
104399
|
+
function assemblePromptfooConfig(config, promptPath) {
|
|
104394
104400
|
return {
|
|
104395
|
-
prompts: [
|
|
104396
|
-
{
|
|
104397
|
-
role: "system",
|
|
104398
|
-
content: config.systemPrompt
|
|
104399
|
-
},
|
|
104400
|
-
{
|
|
104401
|
-
role: "user",
|
|
104402
|
-
content: "{{input}}"
|
|
104403
|
-
}
|
|
104404
|
-
],
|
|
104401
|
+
prompts: promptPath ? [promptPath] : [assemblePromptMessages(config)],
|
|
104405
104402
|
providers: [config.provider],
|
|
104406
104403
|
tests: config.tests.map((test) => ({
|
|
104407
104404
|
description: test.description,
|
|
@@ -104469,19 +104466,19 @@ function createPromptfooEngine() {
|
|
|
104469
104466
|
return mode !== "none";
|
|
104470
104467
|
},
|
|
104471
104468
|
async run(config) {
|
|
104472
|
-
const promptfooConfig = assemblePromptfooConfig(config);
|
|
104473
104469
|
if (mode === "global") {
|
|
104474
104470
|
try {
|
|
104475
104471
|
const promptfoo = await import("promptfoo");
|
|
104476
104472
|
const evaluate = promptfoo.evaluate;
|
|
104477
104473
|
if (typeof evaluate === "function") {
|
|
104478
|
-
const
|
|
104474
|
+
const nodeConfig = assemblePromptfooConfig(config);
|
|
104475
|
+
const evaluateResult = await evaluate(nodeConfig);
|
|
104479
104476
|
const results = evaluateResult.results ?? [];
|
|
104480
104477
|
return extractFailures(results);
|
|
104481
104478
|
}
|
|
104482
104479
|
} catch {}
|
|
104483
104480
|
}
|
|
104484
|
-
return runViaCli(mode,
|
|
104481
|
+
return runViaCli(mode, config);
|
|
104485
104482
|
},
|
|
104486
104483
|
openReport() {
|
|
104487
104484
|
const cmd = getCommand(mode);
|
|
@@ -104489,13 +104486,16 @@ function createPromptfooEngine() {
|
|
|
104489
104486
|
}
|
|
104490
104487
|
};
|
|
104491
104488
|
}
|
|
104492
|
-
async function runViaCli(mode,
|
|
104489
|
+
async function runViaCli(mode, config) {
|
|
104493
104490
|
const tempDir = `${process.env.TMPDIR ?? "/tmp"}/grekt-eval-${Date.now()}`;
|
|
104494
104491
|
const configPath = `${tempDir}/promptfoo-config.json`;
|
|
104492
|
+
const promptPath = `${tempDir}/prompt.json`;
|
|
104495
104493
|
const outputPath = `${tempDir}/output.json`;
|
|
104496
104494
|
const { mkdirSync: mkdirSync3, writeFileSync: writeFileSync2, readFileSync: readFileSync2, rmSync: rmSync2 } = await import("fs");
|
|
104497
104495
|
mkdirSync3(tempDir, { recursive: true });
|
|
104498
104496
|
try {
|
|
104497
|
+
writeFileSync2(promptPath, JSON.stringify(assemblePromptMessages(config), null, 2));
|
|
104498
|
+
const promptfooConfig = assemblePromptfooConfig(config, promptPath);
|
|
104499
104499
|
writeFileSync2(configPath, JSON.stringify(promptfooConfig, null, 2));
|
|
104500
104500
|
const cmd = getCommand(mode);
|
|
104501
104501
|
const result = Bun.spawnSync([...cmd, "eval", "--config", configPath, "--output", outputPath, "--no-cache"], { stdout: "pipe", stderr: "pipe" });
|
|
@@ -104721,6 +104721,7 @@ var evalCommand = new Command("eval").description("Run eval tests against artifa
|
|
|
104721
104721
|
}
|
|
104722
104722
|
process.exit(0);
|
|
104723
104723
|
}
|
|
104724
|
+
info(`Found ${allDiscovered.length} eval${allDiscovered.length === 1 ? "" : "s"} using ${engine2.name}`);
|
|
104724
104725
|
const spin = spinner("Running evals...");
|
|
104725
104726
|
spin.start();
|
|
104726
104727
|
const results = await runAllEvals(allDiscovered, {
|
|
@@ -104973,7 +104974,7 @@ var whoamiCommand = new Command("whoami").description("Show current user").actio
|
|
|
104973
104974
|
// package.json
|
|
104974
104975
|
var package_default = {
|
|
104975
104976
|
name: "@grekt/cli",
|
|
104976
|
-
version: "6.43.0-beta.
|
|
104977
|
+
version: "6.43.0-beta.3",
|
|
104977
104978
|
description: "AI tools versioned, synced, and shared across tools and teams",
|
|
104978
104979
|
type: "module",
|
|
104979
104980
|
bin: {
|