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.
@@ -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 = String(rawText);
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 PromptOutput({
97
+ function EvalOutputCell({
98
98
  output,
99
99
  maxTextLength,
100
100
  rowIndex,
101
101
  promptIndex,
102
102
  onRating,
103
103
  }: PromptOutputProps) {
104
- let text = String(output.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((row: EvalRow) => row.vars[idx], {
203
- id: `Variable ${idx + 1}`,
204
- header: () => (
205
- <TableHeader
206
- smallText={`Variable ${idx + 1}`}
207
- text={varName}
208
- maxLength={maxTextLength}
209
- />
210
- ),
211
- cell: (info: CellContext<EvalRow, string>) => (
212
- <TruncatedText text={info.getValue()} maxLength={maxTextLength} />
213
- ),
214
- // Minimize the size of Variable columns.
215
- size: 50,
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
- <PromptOutput
266
+ <EvalOutputCell
262
267
  output={info.getValue() as unknown as EvalRowOutput}
263
268
  maxTextLength={maxTextLength}
264
269
  rowIndex={info.row.index}
@@ -6,7 +6,7 @@ export type EvalHead = {
6
6
  export type EvalRowOutput = {
7
7
  pass: boolean;
8
8
  score: number;
9
- text: string;
9
+ text: string | object;
10
10
  };
11
11
 
12
12
  export type EvalRow = {