Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(evals): render boolean test results as text (#16514)

Tobias Wochinger8dc616d6ce30
diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/TestResultPanelView/TestResultPanelView.stories.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/TestResultPanelView/TestResultPanelView.stories.tsx
index ec7b0f9300..b08f83ddc4 100644
--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/TestResultPanelView/TestResultPanelView.stories.tsx
+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/TestResultPanelView/TestResultPanelView.stories.tsx
@@ -86,6 +86,40 @@ export const CodeSuccess = meta.story({
},
});
+export const BooleanCodeSuccess = meta.story({
+ name: "Boolean Code Success",
+ args: {
+ title: "Code Output",
+ result: {
+ status: "code-success",
+ scores: [
+ {
+ name: "Factuality",
+ value: "true",
+ comment: "The response is factually correct.",
+ },
+ {
+ name: "Contains PII",
+ value: "false",
+ comment: null,
+ },
+ ],
+ },
+ durationMs: 280,
+ estimatedCostUsd: null,
+ rawOutput: {
+ scores: [
+ { name: "Factuality", value: 1, dataType: "BOOLEAN" },
+ { name: "Contains PII", value: 0, dataType: "BOOLEAN" },
+ ],
+ },
+ rawOpen: false,
+ traceActions: traceActions("trace-execution"),
+ rerunAction: rerunAction(false, null),
+ onRawOpenChange: actions.onRawOpenChange,
+ },
+});
+
export const Error = meta.story({
args: {
title: "LLM Output",
diff --git a/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.clienttest.ts b/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.clienttest.ts
index 4c384414ec..f778be55bc 100644
--- a/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.clienttest.ts
+++ b/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.clienttest.ts
@@ -33,6 +33,28 @@ describe("toTestResultPanelState", () => {
});
});
+ it("renders numeric boolean code scores as true and false", () => {
+ expect(
+ toTestResultPanelState({
+ type: "CODE",
+ isPending: false,
+ result: {
+ success: true,
+ scores: [
+ { name: "Passed", value: 1, dataType: "BOOLEAN" },
+ { name: "Failed", value: 0, dataType: "BOOLEAN" },
+ ],
+ },
+ }),
+ ).toEqual({
+ status: "code-success",
+ scores: [
+ { name: "Passed", value: "true", comment: null },
+ { name: "Failed", value: "false", comment: null },
+ ],
+ });
+ });
+
it.each([
{ matches: ["very funny"], expectedScore: "very funny" },
{
diff --git a/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.ts b/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.ts
index 657f4fbf1d..0b153d5004 100644
--- a/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.ts
+++ b/web/src/features/evals/v2/fns/evaluatorTesting/toTestResultPanelState.ts
@@ -33,9 +33,13 @@ export function toTestResultPanelState(params: {
status: "code-success",
scores: scores.map((score, index) => {
const item = score as Record<string, unknown>;
+ const value =
+ item.dataType === "BOOLEAN" && typeof item.value === "number"
+ ? item.value === 1
+ : item.value;
return {
name: String(item.name ?? `Score ${index + 1}`),
- value: String(item.value ?? ""),
+ value: String(value ?? ""),
comment: item.comment == null ? null : String(item.comment),
};
}),