Skip to content

Commit

Permalink
updated score_result field (#105)
Browse files Browse the repository at this point in the history
* updated score_result field

* build errors
  • Loading branch information
vivirose authored Jan 3, 2024
1 parent ce9ad52 commit d99ef58
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,19 @@ export type TestRunCase = {
input: string;
output: string;
reference_output?: string;
score?: number;
score_result?: ScoreResult;
label?: string;
details?: Record<string, { label?: string; score?: number }>;
};

export type ScoreResult = {
score: number,
category?: {
name: string,
description?: string
}
};

export type TTestRun = {
data: TTestRunData[];
pagination: TPagination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useFela } from "react-fela";
import primary from "resources/colors/Arthur/primary";
import secondary from "resources/colors/Arthur/secondary";
import { useTranslation } from "react-i18next";
import { TestRunCase } from "arthur-redux/slices/testSuites/types";
import { TestRunCase } from "../../../arthur-redux/slices/testSuites/types";

type Props = {
runs: TestRunCase[];
Expand All @@ -17,7 +17,7 @@ const Header = ({ runs, isComposite }: Props) => {
const scorers = (runs.length && runs[0].details) ?? {};
const { hasScores, hasLabels, hasReference } = (runs || []).reduce(
(acc, run) => {
if (run.score !== undefined) {
if (run.score_result?.score !== undefined) {
acc.hasScores = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestRunCase } from "arthur-redux/slices/testSuites/types";
import { TestRunCase } from "../../../arthur-redux/slices/testSuites/types"
import React, { useCallback, useEffect, useState } from "react";
import { Table, TableCell, TableRow } from "../../core/Table";
import Header from "./Header";
Expand Down Expand Up @@ -38,7 +38,7 @@ const Row = ({ runCase, hasScores, hasLabels }: RowProps) => {
<ExpandableTableCell content={runCase.output} limit={300} tableCellProps={{ style: cellStyle }} />
{hasScores && (
<TableCell className={css(styles.cell())}>
<div>{runCase.score !== undefined ? runCase.score.toFixed(3) : "N/A"}</div>
<div>{runCase.score_result?.score !== undefined ? runCase.score_result.score.toFixed(3) : "N/A"}</div>
</TableCell>
)}
{hasLabels && (
Expand Down Expand Up @@ -80,8 +80,8 @@ const TestRunDeepDive = () => {
}, [page]);

const { hasScores, hasLabels, isComposite } = (runs || []).reduce(
(acc, run) => {
if (run.score !== undefined) {
(acc, run: TestRunCase) => {
if (run.score_result?.score !== undefined) {
acc.hasScores = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Output, TTestRunData } from "arthur-redux/slices/testSuites/types";
import { Output, TTestRunData } from "../../arthur-redux/slices/testSuites/types";

/**
* Formats test run data into a specific structure for the compare test runs table.
Expand Down Expand Up @@ -29,7 +29,7 @@ const formatTestRunData = (data: TTestRunData[]) => {
id: testRun.id,
name: testRun.name,
output: testCaseRun.output,
score: testCaseRun.score,
score: testCaseRun.score_result?.score,
};
formattedRow.outputs.push(output);
}
Expand Down

0 comments on commit d99ef58

Please sign in to comment.