promptfoo 0.15.0 → 0.16.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/README.md +10 -7
- package/dist/package.json +1 -1
- package/dist/src/assertions.js +1 -1
- package/dist/src/cache.js +2 -2
- package/dist/src/evaluator.d.ts.map +1 -1
- package/dist/src/evaluator.js +18 -4
- package/dist/src/evaluator.js.map +1 -1
- package/dist/src/prompts.js +2 -2
- package/dist/src/prompts.js.map +1 -1
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/util.d.ts +1 -0
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +30 -22
- package/dist/src/util.js.map +1 -1
- package/dist/src/web/client/assets/{index-9d27a707.js → index-eb1e9052.js} +1 -1
- package/dist/src/web/client/index.html +1 -1
- package/package.json +1 -1
- package/src/assertions.ts +2 -2
- package/src/cache.ts +3 -3
- package/src/evaluator.ts +27 -11
- package/src/prompts.ts +2 -2
- package/src/types.ts +3 -3
- package/src/util.ts +32 -19
- package/src/web/client/package-lock.json +5726 -0
- package/src/web/client/src/ResultsTable.tsx +24 -19
- package/src/web/client/src/types.ts +1 -1
|
@@ -54,7 +54,7 @@ interface TruncatedTextProps {
|
|
|
54
54
|
|
|
55
55
|
function TruncatedText({ text: rawText, maxLength }: TruncatedTextProps) {
|
|
56
56
|
const [isTruncated, setIsTruncated] = React.useState<boolean>(true);
|
|
57
|
-
const text =
|
|
57
|
+
const text = typeof rawText === 'string' ? rawText : JSON.stringify(rawText);
|
|
58
58
|
|
|
59
59
|
const toggleTruncate = () => {
|
|
60
60
|
setIsTruncated(!isTruncated);
|
|
@@ -94,14 +94,14 @@ interface PromptOutputProps {
|
|
|
94
94
|
onRating: (rowIndex: number, promptIndex: number, isPass: boolean) => void;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function
|
|
97
|
+
function EvalOutputCell({
|
|
98
98
|
output,
|
|
99
99
|
maxTextLength,
|
|
100
100
|
rowIndex,
|
|
101
101
|
promptIndex,
|
|
102
102
|
onRating,
|
|
103
103
|
}: PromptOutputProps) {
|
|
104
|
-
let text =
|
|
104
|
+
let text = typeof output.text === 'string' ? output.text : JSON.stringify(output.text);
|
|
105
105
|
let chunks: string[] = [];
|
|
106
106
|
if (!output.pass && text.includes('---')) {
|
|
107
107
|
// TODO(ian): Plumb through failure message instead of parsing it out.
|
|
@@ -199,21 +199,26 @@ export default function ResultsTable({
|
|
|
199
199
|
id: 'vars',
|
|
200
200
|
header: () => <span>Variables</span>,
|
|
201
201
|
columns: head.vars.map((varName, idx) =>
|
|
202
|
-
columnHelper.accessor(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
202
|
+
columnHelper.accessor(
|
|
203
|
+
(row: EvalRow) => {
|
|
204
|
+
return row.vars[idx];
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: `Variable ${idx + 1}`,
|
|
208
|
+
header: () => (
|
|
209
|
+
<TableHeader
|
|
210
|
+
smallText={`Variable ${idx + 1}`}
|
|
211
|
+
text={varName}
|
|
212
|
+
maxLength={maxTextLength}
|
|
213
|
+
/>
|
|
214
|
+
),
|
|
215
|
+
cell: (info: CellContext<EvalRow, string>) => (
|
|
216
|
+
<TruncatedText text={info.getValue()} maxLength={maxTextLength} />
|
|
217
|
+
),
|
|
218
|
+
// Minimize the size of Variable columns.
|
|
219
|
+
size: 50,
|
|
220
|
+
},
|
|
221
|
+
),
|
|
217
222
|
),
|
|
218
223
|
}),
|
|
219
224
|
columnHelper.group({
|
|
@@ -258,7 +263,7 @@ export default function ResultsTable({
|
|
|
258
263
|
);
|
|
259
264
|
},
|
|
260
265
|
cell: (info: CellContext<EvalRow, string>) => (
|
|
261
|
-
<
|
|
266
|
+
<EvalOutputCell
|
|
262
267
|
output={info.getValue() as unknown as EvalRowOutput}
|
|
263
268
|
maxTextLength={maxTextLength}
|
|
264
269
|
rowIndex={info.row.index}
|