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