Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import { createColumnHelper } from "@tanstack/react-table";
import Image from "next/image";
import Link from "next/link";
import { useParams, useRouter } from "next/navigation";
import { Avatar, Badge, Button, DataTable, Spinner, Tag, Text } from "opub-ui";
import {
Avatar,
Badge,
Button,
DataTable,
Spinner,
Tag,
Text,
toast,
} from "opub-ui";
import React from "react";
import AuditorInvitation from "../../evaluations/components/AuditorInvitation";
import { useOrganization } from "../../OrganizationContext";
Expand Down Expand Up @@ -164,6 +173,15 @@ const formatDateShort = (dateString: string) => {
});
};

const isDeprecatedLifecycle = (lifecycleStage: string) => {
const normalizedStage = (lifecycleStage || "").toUpperCase();
return (
normalizedStage === "DEPRECATED" ||
normalizedStage === "DEPRECETED" ||
normalizedStage === "DEPRECIATED"
);
};

const ModelDetailPage = () => {
const params = useParams();
const router = useRouter();
Expand Down Expand Up @@ -378,17 +396,34 @@ const ModelDetailPage = () => {
</div>

<div className="flex items-center gap-4">
{(() => {
const isStartEvaluationDisabled =
isDeprecatedLifecycle(v.lifecycleStage);
return (
<button
type="button"
style={{ textDecoration: "none" }}
className="prompt-add-filters-link no-underline"
className={`prompt-add-filters-link no-underline ${
isStartEvaluationDisabled
? "opacity-50 cursor-not-allowed pointer-events-auto"
: ""
}`}
aria-disabled={isStartEvaluationDisabled}
onClick={(e) => {
e.stopPropagation();
if (isStartEvaluationDisabled) {
toast.error(
"Sorry this model version is depreceted",
);
return;
}
handleNewEvaluation(v.id);
}}
>
Start Evaluation
</button>
);
})()}

<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useGraphQL } from "@/lib/api";
import { useParams, useRouter } from "next/navigation";
import { Button, Dialog, Select, Spinner, Text } from "opub-ui";
import { Button, Dialog, Select, Spinner, Text, toast } from "opub-ui";
import { useEffect, useState } from "react";

// GraphQL query to fetch AI models with their versions
Expand Down Expand Up @@ -33,6 +33,7 @@ const AI_MODELS_QUERY = `
version
isLatest
status
lifecycleStage
}
}
}
Expand All @@ -49,6 +50,7 @@ type AIModel = {
version: string;
isLatest: boolean;
status: string;
lifecycleStage: string;
}>;
};

Expand Down Expand Up @@ -84,6 +86,13 @@ const ModelSelectionModal = ({

const selectedModel = aiModels.find((m) => m.id === selectedModelId);
const latestVersion = selectedModel?.versions?.find((v) => v.isLatest);
const selectedVersion = selectedModel?.versions?.find(
(v) => v.id === selectedVersionId,
);
const isSelectedVersionDeprecated =
(selectedVersion?.lifecycleStage || "").toUpperCase() === "DEPRECATED" ||
(selectedVersion?.lifecycleStage || "").toUpperCase() === "DEPRECETED" ||
(selectedVersion?.lifecycleStage || "").toUpperCase() === "DEPRECIATED";

// Fetch AI models when modal opens
useEffect(() => {
Expand Down Expand Up @@ -165,6 +174,10 @@ const ModelSelectionModal = ({
if (!selectedModelId || !selectedVersionId) {
return;
}
if (isSelectedVersionDeprecated) {
toast.error("Sorry this model version is depreceted");
return;
}

setIsSubmitting(true);

Expand Down Expand Up @@ -233,9 +246,10 @@ const ModelSelectionModal = ({
label: `${ver.version}${ver.isLatest ? " (Latest)" : ""}`,
}))}
value={selectedVersionId ? String(selectedVersionId) : ""}
onChange={(value) =>
setSelectedVersionId(value ? Number(value) : null)
}
onChange={(value) => {
const nextVersionId = value ? Number(value) : null;
setSelectedVersionId(nextVersionId);
}}
/>
</div>
)}
Expand All @@ -257,7 +271,12 @@ const ModelSelectionModal = ({
kind="primary"
onClick={handleStart}
disabled={!canStart || isSubmitting}
className="bg-primaryPurple2 hover:bg-[#6849EE] hover:!bg-[#6849EE] text-white hover:text-white hover:!text-white px-8 py-3 rounded-[8px] font-bold text-base"
aria-disabled={isSelectedVersionDeprecated}
className={`bg-primaryPurple2 hover:bg-[#6849EE] hover:!bg-[#6849EE] text-white hover:text-white hover:!text-white px-8 py-3 rounded-[8px] font-bold text-base ${
isSelectedVersionDeprecated
? "!opacity-50 !cursor-not-allowed hover:!bg-primaryPurple2"
: ""
}`}
>
{isSubmitting ? "Starting..." : "Start"}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ const NewEvaluationContent: React.FC<NewEvaluationContentProps> = ({
const params = useParams();
const locale = params?.locale || "en";

const evaluationsListPath = fromAuditor
? `/${locale}/dashboard/auditor/evaluations`
: `/${locale}/dashboard/ai-maker/${orgId}/evaluations`;

const urlModelId = searchParams.get("modelId");
const urlVersion = searchParams.get("version");
const urlVersionId = searchParams.get("versionId");
Expand Down Expand Up @@ -1114,9 +1118,7 @@ const NewEvaluationContent: React.FC<NewEvaluationContentProps> = ({
if (!auditId) {
isNavigatingAwayRef.current = true;
// Avoid router.back() here because history guards can keep user on the same page.
window.location.assign(
`/${locale}/dashboard/ai-maker/${orgId}/evaluations`
);
window.location.assign(evaluationsListPath);
return;
}
setIsCancelling(true);
Expand All @@ -1135,9 +1137,7 @@ const NewEvaluationContent: React.FC<NewEvaluationContentProps> = ({
);
if (result?.updateAudit?.success) {
// Use a hard navigation so the list refreshes immediately and doesn't rely on client cache.
window.location.assign(
`/${locale}/dashboard/ai-maker/${orgId}/evaluations`
);
window.location.assign(evaluationsListPath);
} else {
isNavigatingAwayRef.current = false;
setAuditError(
Expand Down Expand Up @@ -1762,7 +1762,7 @@ const NewEvaluationContent: React.FC<NewEvaluationContentProps> = ({
if (!saved) return;

isNavigatingAwayRef.current = true;
router.push(`/${locale}/dashboard/ai-maker/${orgId}/evaluations`);
router.push(evaluationsListPath);
};

const handleRunAudit = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const TestCases: React.FC<TestCasesProps> = ({
rows={promptDatasets}
columns={promptDatasetColumns}
hideSelection={false}
hideFooter={true}
hideFooter={promptDatasets.length <= 10}
defaultSelectedRows={selectedPromptLibraries}
onRowSelectionChange={(selected) => {
// DataTable emits an initial empty selection before applying defaultSelectedRows.
Expand All @@ -297,7 +297,7 @@ const TestCases: React.FC<TestCasesProps> = ({
<Text variant="headingMd" className="enter-test-cases-heading mb-4">
Enter Your Own Test Cases (Optional)
</Text>
<div className="flex gap-6 mb-4 test-input-buttons-container">
{/* <div className="flex gap-6 mb-4 test-input-buttons-container">
<Button
kind="secondary"
onClick={() => setTestInputMode("paste")}
Expand Down Expand Up @@ -325,7 +325,7 @@ const TestCases: React.FC<TestCasesProps> = ({
</span>
Upload File
</Button>
</div>
</div> */}

{testInputMode === "paste" ? (
<div className="test-cases-input-wrapper">
Expand Down