promptfoo 0.17.9 → 0.18.1
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/README.md +5 -5
- package/dist/package.json +1 -1
- package/dist/src/assertions.d.ts.map +1 -1
- package/dist/src/assertions.js +97 -42
- package/dist/src/assertions.js.map +1 -1
- package/dist/src/evaluator.d.ts.map +1 -1
- package/dist/src/evaluator.js +35 -7
- package/dist/src/evaluator.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/main.js +9 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/providers/llama.d.ts +30 -0
- package/dist/src/providers/llama.d.ts.map +1 -0
- package/dist/src/providers/llama.js +67 -0
- package/dist/src/providers/llama.js.map +1 -0
- package/dist/src/providers.d.ts +2 -2
- package/dist/src/providers.d.ts.map +1 -1
- package/dist/src/providers.js +21 -2
- package/dist/src/providers.js.map +1 -1
- package/dist/src/table.js +2 -2
- package/dist/src/table.js.map +1 -1
- package/dist/src/types.d.ts +11 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +5 -2
- package/dist/src/util.js.map +1 -1
- package/package.json +1 -1
- package/src/assertions.ts +102 -49
- package/src/evaluator.ts +33 -4
- package/src/index.ts +6 -1
- package/src/main.ts +14 -0
- package/src/providers/llama.ts +95 -0
- package/src/providers.ts +27 -5
- package/src/table.ts +2 -2
- package/src/types.ts +25 -5
- package/src/util.ts +12 -2
- package/src/web/client/package-lock.json +0 -5726
package/src/util.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as os from 'os';
|
|
|
4
4
|
|
|
5
5
|
import $RefParser from '@apidevtools/json-schema-ref-parser';
|
|
6
6
|
import fetch from 'node-fetch';
|
|
7
|
+
import invariant from 'tiny-invariant';
|
|
7
8
|
import yaml from 'js-yaml';
|
|
8
9
|
import nunjucks from 'nunjucks';
|
|
9
10
|
import { globSync } from 'glob';
|
|
@@ -44,6 +45,15 @@ export function readProviderPromptMap(
|
|
|
44
45
|
allPrompts.push(prompt.display);
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
invariant(
|
|
49
|
+
typeof config.providers !== 'string',
|
|
50
|
+
'In order to use a provider-prompt map, config.providers should be an array of objects, not a string',
|
|
51
|
+
);
|
|
52
|
+
invariant(
|
|
53
|
+
typeof config.providers !== 'function',
|
|
54
|
+
'In order to use a provider-prompt map, config.providers should be an array of objects, not a function',
|
|
55
|
+
);
|
|
56
|
+
|
|
47
57
|
for (const provider of config.providers) {
|
|
48
58
|
if (typeof provider === 'object') {
|
|
49
59
|
const rawProvider = provider as RawProviderConfig;
|
|
@@ -446,7 +456,7 @@ export function writeLatestResults(results: EvaluateSummary, config: Partial<Uni
|
|
|
446
456
|
2,
|
|
447
457
|
),
|
|
448
458
|
);
|
|
449
|
-
if (fs.existsSync(latestResultsPath)) {
|
|
459
|
+
if (fs.existsSync(latestResultsPath) && fs.lstatSync(latestResultsPath).isSymbolicLink()) {
|
|
450
460
|
fs.unlinkSync(latestResultsPath);
|
|
451
461
|
}
|
|
452
462
|
fs.symlinkSync(newResultsPath, latestResultsPath);
|
|
@@ -463,7 +473,7 @@ export function listPreviousResults(): string[] {
|
|
|
463
473
|
const sortedFiles = resultsFiles.sort((a, b) => {
|
|
464
474
|
const statA = fs.statSync(path.join(directory, a));
|
|
465
475
|
const statB = fs.statSync(path.join(directory, b));
|
|
466
|
-
return
|
|
476
|
+
return statA.birthtime.getTime() - statB.birthtime.getTime(); // sort in ascending order
|
|
467
477
|
});
|
|
468
478
|
return sortedFiles;
|
|
469
479
|
}
|