Skip to content

Commit

Permalink
Bug fixes to Evaluations (#111)
Browse files Browse the repository at this point in the history
* Pagination bug

* Bug fix

* Bug fixes to evals v2

* Minor fix
  • Loading branch information
karthikscale3 authored May 21, 2024
1 parent eab02bb commit f2d9ea5
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 319 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { ScaleType } from "@/components/evaluations/eval-scale-picker";
import { RangeScale } from "@/components/evaluations/range-scale";
import { ScaleType } from "@/components/evaluate/eval-scale-picker";
import { RangeScale } from "@/components/evaluate/range-scale";
import UserLogo from "@/components/shared/user-logo";
import { VendorLogo } from "@/components/shared/vendor-metadata";
import { Button } from "@/components/ui/button";
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function Page() {
toast.error("Failed to fetch the test", {
description: error?.message || "Failed to fetch test",
});
router.push(`/project/${projectId}/evaluations`);
router.push(`/project/${projectId}/evaluate`);
return;
}
const result = await response.json();
Expand All @@ -71,16 +71,6 @@ export default function Page() {
operation: "NOT_EQUALS",
value: "",
},
// Accuracy is the default test. So no need to
// send the testId with the spans when using the SDK.
{
key: "langtrace.testId",
operation: "EQUALS",
value:
testData?.test?.name.toLowerCase() !== "factual accuracy"
? testData?.test?.id
: "",
},
];

// convert filterserviceType to a string
Expand All @@ -106,7 +96,7 @@ export default function Page() {
toast.error("Failed to fetch the span data", {
description: error?.message || "Failed to fetch the span data",
});
router.push(`/project/${projectId}/evaluations`);
router.push(`/project/${projectId}/evaluate`);
return;
}

Expand All @@ -123,7 +113,7 @@ export default function Page() {
page <= 0 ||
page > parseInt(metadata?.total_pages)
) {
router.push(`/project/${projectId}/evaluations`);
router.push(`/project/${projectId}/evaluate`);
}

// Update the total pages and current page number
Expand All @@ -150,17 +140,15 @@ export default function Page() {
evaluate();
if (page < totalPages) {
const nextPage = page + 1;
router.push(
`/project/${projectId}/evaluations/${testId}?page=${nextPage}`
);
router.push(`/project/${projectId}/evaluate/${testId}?page=${nextPage}`);
}
};

const previous = () => {
if (page > 1) {
const previousPage = page - 1;
router.push(
`/project/${projectId}/evaluations/${testId}?page=${previousPage}`
`/project/${projectId}/evaluate/${testId}?page=${previousPage}`
);
}
};
Expand All @@ -174,12 +162,14 @@ export default function Page() {
toast.error("Failed to fetch the evaluation data", {
description: error?.message || "Failed to fetch the evaluation data",
});
router.push(`/project/${projectId}/evaluations`);
router.push(`/project/${projectId}/evaluate`);
return;
}
const result = await response.json();
const sc =
result.evaluations.length > 0 ? result.evaluations[0].ltUserScore ?? -1 : -1;
result.evaluations.length > 0
? result.evaluations[0].ltUserScore ?? -1
: -1;
onScoreSelected(sc);
return result;
},
Expand All @@ -196,7 +186,7 @@ export default function Page() {
}

if (event.key === "Escape") {
router.push(`/project/${projectId}/evaluations`);
router.push(`/project/${projectId}/evaluate`);
}
};

Expand Down Expand Up @@ -233,7 +223,7 @@ export default function Page() {
body: JSON.stringify({
id: evaluationsData.evaluations[0].id,
ltUserScore: score,
testId
testId,
}),
});
queryClient.invalidateQueries({
Expand Down Expand Up @@ -361,7 +351,7 @@ export default function Page() {
))}
</div>
) : (
< RangeScale
<RangeScale
variant="large"
type={ScaleType.Range}
min={testData?.test?.min}
Expand Down Expand Up @@ -432,7 +422,7 @@ export default function Page() {
<div className="absolute bottom-5 right-5 flex gap-2 items-center">
<Button
variant={"outline"}
onClick={() => router.push(`/project/${projectId}/evaluations`)}
onClick={() => router.push(`/project/${projectId}/evaluate`)}
disabled={isEvaluationLoading}
>
Exit
Expand Down Expand Up @@ -478,8 +468,8 @@ function ConversationView({ span }: { span: any }) {
const content = prompt?.content
? safeStringify(prompt?.content)
: prompt?.function_call
? safeStringify(prompt?.function_call)
: "No input found";
? safeStringify(prompt?.function_call)
: "No input found";
return (
<div key={i} className="flex flex-col gap-2">
<div className="flex gap-2 items-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import { EvalChart } from "@/components/charts/eval-chart";
import LargeChartSkeleton from "@/components/charts/large-chart-skeleton";
import { CreateTest } from "@/components/evaluations/create-test";
import { EditTest } from "@/components/evaluations/edit-test";
import { CreateTest } from "@/components/evaluate/create-test";
import { EditTest } from "@/components/evaluate/edit-test";
import EvaluationTable, {
EvaluationTableSkeleton,
} from "@/components/evaluations/evaluation-table";
} from "@/components/evaluate/evaluation-table";
import { AddtoDataset } from "@/components/shared/add-to-dataset";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
Expand Down Expand Up @@ -106,17 +106,17 @@ export default function PageClient({ email }: { email: string }) {
return (
<div className="w-full flex flex-col">
<div className="md:px-24 px-12 py-12 flex justify-between bg-muted">
<h1 className="text-3xl font-semibold">Evaluations</h1>
<h1 className="text-3xl font-semibold">Manual Evaluations</h1>
<div className="flex gap-2">
{selectedTest && (
<Link
href={`/project/${projectId}/evaluations/${selectedTest?.id}?page=1`}
href={`/project/${projectId}/evaluate/${selectedTest?.id}?page=1`}
>
<Button
className="bg-gradient-to-r from-pink-500 via-red-500 to-yellow-500 background-animate"
variant="default"
>
Start Testing <ChevronsRight className="ml-2" />{" "}
Start Evaluating <ChevronsRight className="ml-2" />{" "}
</Button>
</Link>
)}
Expand Down
Loading

0 comments on commit f2d9ea5

Please sign in to comment.