@iblai/iblai-js 2.76.1 → 2.77.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.
- package/dist/data-layer/playwright/evaluation-tab-helpers.d.ts +181 -68
- package/dist/playwright/index.cjs +414 -164
- package/dist/playwright/index.cjs.map +1 -1
- package/dist/playwright/index.d.ts +181 -69
- package/dist/playwright/index.esm.js +407 -165
- package/dist/playwright/index.esm.js.map +1 -1
- package/dist/playwright/playwright/evaluation-tab-helpers.d.ts +181 -68
- package/dist/security/playwright/evaluation-tab-helpers.d.ts +181 -68
- package/dist/web-containers/playwright/evaluation-tab-helpers.d.ts +181 -68
- package/dist/web-containers/source/_virtual/index2.js +2 -2
- package/dist/web-containers/source/_virtual/index3.js +2 -2
- package/dist/web-containers/source/activity-empty-state.js +2 -2
- package/dist/web-containers/source/activity-empty-state.js.map +1 -1
- package/dist/web-containers/source/activity-tab/activity-empty-state.js +2 -2
- package/dist/web-containers/source/activity-tab/activity-empty-state.js.map +1 -1
- package/dist/web-containers/source/add-items-modal.js +26 -91
- package/dist/web-containers/source/add-items-modal.js.map +1 -1
- package/dist/web-containers/source/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/benchmark-items-modal.js +28 -7
- package/dist/web-containers/source/benchmark-items-modal.js.map +1 -1
- package/dist/web-containers/source/benchmarks/add-items-modal.js +26 -91
- package/dist/web-containers/source/benchmarks/add-items-modal.js.map +1 -1
- package/dist/web-containers/source/benchmarks/benchmark-items-modal.js +28 -7
- package/dist/web-containers/source/benchmarks/benchmark-items-modal.js.map +1 -1
- package/dist/web-containers/source/benchmarks/create-benchmark-modal.js +166 -20
- package/dist/web-containers/source/benchmarks/create-benchmark-modal.js.map +1 -1
- package/dist/web-containers/source/benchmarks/delete-item-confirm.js +10 -9
- package/dist/web-containers/source/benchmarks/delete-item-confirm.js.map +1 -1
- package/dist/web-containers/source/benchmarks/evals-ui.js +39 -0
- package/dist/web-containers/source/benchmarks/evals-ui.js.map +1 -0
- package/dist/web-containers/source/benchmarks/index.js +30 -11
- package/dist/web-containers/source/benchmarks/index.js.map +1 -1
- package/dist/web-containers/source/benchmarks/qa-form.js +233 -0
- package/dist/web-containers/source/benchmarks/qa-form.js.map +1 -0
- package/dist/web-containers/source/components/activity-tab/activity-empty-state.js +2 -2
- package/dist/web-containers/source/components/activity-tab/activity-empty-state.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/index.js +68 -37
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/index.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/labels.js +68 -46
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/labels.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/utils.js +14 -1
- package/dist/web-containers/source/components/modals/edit-mentor-modal/tabs/evaluation-tab/utils.js.map +1 -1
- package/dist/web-containers/source/components/platform-sidebar/index.js +2 -0
- package/dist/web-containers/source/components/platform-sidebar/index.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/add-items-modal.js +26 -91
- package/dist/web-containers/source/components/profile/benchmarks/add-items-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/benchmark-items-modal.js +28 -7
- package/dist/web-containers/source/components/profile/benchmarks/benchmark-items-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/create-benchmark-modal.js +166 -20
- package/dist/web-containers/source/components/profile/benchmarks/create-benchmark-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/delete-item-confirm.js +10 -9
- package/dist/web-containers/source/components/profile/benchmarks/delete-item-confirm.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/evals-ui.js +39 -0
- package/dist/web-containers/source/components/profile/benchmarks/evals-ui.js.map +1 -0
- package/dist/web-containers/source/components/profile/benchmarks/index.js +30 -11
- package/dist/web-containers/source/components/profile/benchmarks/index.js.map +1 -1
- package/dist/web-containers/source/components/profile/benchmarks/qa-form.js +233 -0
- package/dist/web-containers/source/components/profile/benchmarks/qa-form.js.map +1 -0
- package/dist/web-containers/source/components/rich-text-editor.js +24 -3
- package/dist/web-containers/source/components/rich-text-editor.js.map +1 -1
- package/dist/web-containers/source/create-benchmark-modal.js +166 -20
- package/dist/web-containers/source/create-benchmark-modal.js.map +1 -1
- package/dist/web-containers/source/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/delete-item-confirm.js +10 -9
- package/dist/web-containers/source/delete-item-confirm.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/index.js +68 -37
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/index.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/labels.js +68 -46
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/labels.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/utils.js +14 -1
- package/dist/web-containers/source/edit-mentor-modal/tabs/evaluation-tab/utils.js.map +1 -1
- package/dist/web-containers/source/en.json.js +100 -74
- package/dist/web-containers/source/en.json.js.map +1 -1
- package/dist/web-containers/source/es.json.js +81 -55
- package/dist/web-containers/source/es.json.js.map +1 -1
- package/dist/web-containers/source/evals-ui.js +39 -0
- package/dist/web-containers/source/evals-ui.js.map +1 -0
- package/dist/web-containers/source/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/evaluation-tab/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/evaluation-tab/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/evaluation-tab/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/evaluation-tab/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/index.js +68 -37
- package/dist/web-containers/source/evaluation-tab/index.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/labels.js +68 -46
- package/dist/web-containers/source/evaluation-tab/labels.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/evaluation-tab/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/evaluation-tab/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/evaluation-tab/utils.js +14 -1
- package/dist/web-containers/source/evaluation-tab/utils.js.map +1 -1
- package/dist/web-containers/source/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/fr.json.js +82 -56
- package/dist/web-containers/source/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/en.json.js +100 -74
- package/dist/web-containers/source/i18n/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/es.json.js +81 -55
- package/dist/web-containers/source/i18n/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/fr.json.js +82 -56
- package/dist/web-containers/source/i18n/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/zh.json.js +71 -45
- package/dist/web-containers/source/i18n/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/index2.js +2 -2
- package/dist/web-containers/source/index3.js +2 -2
- package/dist/web-containers/source/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/messages/en.json.js +100 -74
- package/dist/web-containers/source/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/messages/es.json.js +81 -55
- package/dist/web-containers/source/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/messages/fr.json.js +82 -56
- package/dist/web-containers/source/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/messages/zh.json.js +71 -45
- package/dist/web-containers/source/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/index.js +68 -37
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/index.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/labels.js +68 -46
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/labels.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/utils.js +14 -1
- package/dist/web-containers/source/modals/edit-mentor-modal/tabs/evaluation-tab/utils.js.map +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
- package/dist/web-containers/source/platform-sidebar/index.js +2 -0
- package/dist/web-containers/source/platform-sidebar/index.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/add-items-modal.js +26 -91
- package/dist/web-containers/source/profile/benchmarks/add-items-modal.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/benchmark-items-modal.js +28 -7
- package/dist/web-containers/source/profile/benchmarks/benchmark-items-modal.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/create-benchmark-modal.js +166 -20
- package/dist/web-containers/source/profile/benchmarks/create-benchmark-modal.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/delete-item-confirm.js +10 -9
- package/dist/web-containers/source/profile/benchmarks/delete-item-confirm.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/evals-ui.js +39 -0
- package/dist/web-containers/source/profile/benchmarks/evals-ui.js.map +1 -0
- package/dist/web-containers/source/profile/benchmarks/index.js +30 -11
- package/dist/web-containers/source/profile/benchmarks/index.js.map +1 -1
- package/dist/web-containers/source/profile/benchmarks/qa-form.js +233 -0
- package/dist/web-containers/source/profile/benchmarks/qa-form.js.map +1 -0
- package/dist/web-containers/source/qa-form.js +233 -0
- package/dist/web-containers/source/qa-form.js.map +1 -0
- package/dist/web-containers/source/rich-text-editor.js +24 -3
- package/dist/web-containers/source/rich-text-editor.js.map +1 -1
- package/dist/web-containers/source/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/benchmark-combobox.js +2 -2
- package/dist/web-containers/source/tabs/evaluation-tab/benchmark-combobox.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/delete-experiment-modal.js +6 -6
- package/dist/web-containers/source/tabs/evaluation-tab/delete-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/evaluate-llm-picker.js +7 -6
- package/dist/web-containers/source/tabs/evaluation-tab/evaluate-llm-picker.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/experiment-detail-modal.js +51 -43
- package/dist/web-containers/source/tabs/evaluation-tab/experiment-detail-modal.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/index.js +68 -37
- package/dist/web-containers/source/tabs/evaluation-tab/index.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/labels.js +68 -46
- package/dist/web-containers/source/tabs/evaluation-tab/labels.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/llm-judge-modal.js +13 -6
- package/dist/web-containers/source/tabs/evaluation-tab/llm-judge-modal.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/start-experiment-modal.js +16 -7
- package/dist/web-containers/source/tabs/evaluation-tab/start-experiment-modal.js.map +1 -1
- package/dist/web-containers/source/tabs/evaluation-tab/utils.js +14 -1
- package/dist/web-containers/source/tabs/evaluation-tab/utils.js.map +1 -1
- package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/zh.json.js +71 -45
- package/dist/web-containers/source/zh.json.js.map +1 -1
- package/dist/web-utils/playwright/evaluation-tab-helpers.d.ts +181 -68
- package/package.json +4 -4
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import { jsx, jsxs
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '../../ui/dialog.js';
|
|
4
|
+
import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '../../ui/table.js';
|
|
4
5
|
import { Button } from '../../ui/button.js';
|
|
5
6
|
import { Spinner } from '../../spinner/index.js';
|
|
6
7
|
import { AdvancedPagination } from '../../advance-pagination.js';
|
|
8
|
+
import { ActivityControlRow, ActivityControlActions, ACTIVITY_CONTROL } from '../../activity-tab/activity-layout.js';
|
|
9
|
+
import { ActivityEmptyState } from '../../activity-tab/activity-empty-state.js';
|
|
10
|
+
import '../../activity-tab/activity-phone.js';
|
|
11
|
+
import '../../ui/pagination.js';
|
|
12
|
+
import 'date-fns';
|
|
13
|
+
import 'rehype-parse';
|
|
14
|
+
import 'rehype-remark';
|
|
15
|
+
import 'remark-stringify';
|
|
16
|
+
import 'remark-html';
|
|
17
|
+
import 'remark';
|
|
18
|
+
import '../../../node_modules/.pnpm/dompurify@3.4.18/node_modules/dompurify/dist/purify.es.js';
|
|
7
19
|
import { useListEvalDatasetItemsQuery, evalTotalPages } from '@iblai/data-layer';
|
|
8
20
|
import { useT } from '../../../i18n/context.js';
|
|
9
21
|
import '../../../packages/i18n/dist/index.esm.js';
|
|
10
22
|
import { AddItemsModal } from './add-items-modal.js';
|
|
11
23
|
import { DeleteItemConfirm } from './delete-item-confirm.js';
|
|
12
|
-
import
|
|
24
|
+
import { EVALS_DIALOG, EVALS_TABLE, IconAction } from './evals-ui.js';
|
|
13
25
|
import Trash2 from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/trash-2.js';
|
|
26
|
+
import Plus from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js';
|
|
14
27
|
|
|
15
28
|
const PAGE_SIZE = 10;
|
|
29
|
+
const asText = (value) => (typeof value === 'string' ? value : JSON.stringify(value));
|
|
30
|
+
const hasAnswer = (value) => value != null && value !== '';
|
|
16
31
|
function BenchmarkItemsModal({ isOpen, onClose, tenantKey, username, datasetName }) {
|
|
17
|
-
var _a;
|
|
32
|
+
var _a, _b;
|
|
18
33
|
const t = useT();
|
|
19
34
|
const [page, setPage] = useState(1);
|
|
20
35
|
const [showAdd, setShowAdd] = useState(false);
|
|
@@ -27,11 +42,17 @@ function BenchmarkItemsModal({ isOpen, onClose, tenantKey, username, datasetName
|
|
|
27
42
|
limit: PAGE_SIZE,
|
|
28
43
|
});
|
|
29
44
|
const items = (_a = data === null || data === void 0 ? void 0 : data.results) !== null && _a !== void 0 ? _a : [];
|
|
45
|
+
const count = (_b = data === null || data === void 0 ? void 0 : data.count) !== null && _b !== void 0 ? _b : 0;
|
|
30
46
|
const totalPages = evalTotalPages(data === null || data === void 0 ? void 0 : data.count, PAGE_SIZE);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
const deleteLabel = t('benchmarksBenchmarkItemsModal.deleteItemAriaLabel');
|
|
48
|
+
// The backend answers a page past the end with an error, so leave a page
|
|
49
|
+
// before its last row goes.
|
|
50
|
+
const leaveEmptiedPage = () => {
|
|
51
|
+
if (items.length === 1 && page > 1)
|
|
52
|
+
setPage(page - 1);
|
|
53
|
+
};
|
|
54
|
+
const addButton = (placement) => (jsxs(Button, { type: "button", onClick: () => setShowAdd(true), className: `${placement} ${ACTIVITY_CONTROL.primaryButton}`, children: [jsx(Plus, { className: "h-4 w-4" }), t('benchmarksBenchmarkItemsModal.addItems')] }));
|
|
55
|
+
return (jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: jsxs(DialogContent, { "aria-label": "benchmark-items", className: "max-h-[90vh] w-full max-w-4xl overflow-y-auto", children: [jsxs(DialogHeader, { className: "min-w-0", children: [jsx(DialogTitle, { className: EVALS_DIALOG.nameTitle, children: datasetName }), jsx(DialogDescription, { children: t('benchmarksBenchmarkItemsModal.description') })] }), !isLoading && items.length > 0 && (jsxs(ActivityControlRow, { children: [jsx("p", { className: "min-w-0 flex-1 text-sm text-[#646464] dark:text-gray-400", children: t('benchmarksBenchmarkItemsModal.count', { count }) }), jsx(ActivityControlActions, { children: addButton('cursor-pointer max-md:flex-1') })] })), isLoading && (jsx("div", { className: EVALS_DIALOG.loading, children: jsx(Spinner, {}) })), !isLoading && items.length === 0 && (jsx(ActivityEmptyState, { className: EVALS_DIALOG.empty, action: addButton('cursor-pointer'), children: t('benchmarksBenchmarkItemsModal.empty') })), !isLoading && items.length > 0 && (jsx("div", { className: EVALS_TABLE.frame, children: jsxs(Table, { className: "table-fixed", children: [jsx(TableHeader, { children: jsxs(TableRow, { className: EVALS_TABLE.headerRow, children: [jsx(TableHead, { className: EVALS_TABLE.head, children: t('benchmarksBenchmarkItemsModal.questionColumn') }), jsx(TableHead, { className: `hidden sm:table-cell ${EVALS_TABLE.head}`, children: t('benchmarksBenchmarkItemsModal.answerColumn') }), jsx(TableHead, { className: EVALS_TABLE.actionsHead, children: t('benchmarksBenchmarkItemsModal.actionsColumn') })] }) }), jsx(TableBody, { children: items.map((item) => (jsxs(TableRow, { className: EVALS_TABLE.row, children: [jsxs(TableCell, { className: EVALS_TABLE.cell, children: [jsx("div", { className: "line-clamp-3 break-words", children: asText(item.input) }), hasAnswer(item.expected_output) && (jsx("div", { className: "mt-1 line-clamp-3 break-words text-gray-500 sm:hidden dark:text-gray-400", children: asText(item.expected_output) }))] }), jsx(TableCell, { className: `hidden sm:table-cell ${EVALS_TABLE.cell}`, children: jsx("div", { className: "line-clamp-3 break-words", children: hasAnswer(item.expected_output) ? (asText(item.expected_output)) : (jsx("span", { className: "text-gray-400", children: "\u2014" })) }) }), jsx(TableCell, { className: EVALS_TABLE.actionsCell, children: jsx(IconAction, { label: deleteLabel, icon: Trash2, destructive: true, onClick: () => setDeleteItemId(item.id), className: EVALS_TABLE.rowAction }) })] }, item.id))) })] }) })), totalPages > 1 && (jsx(AdvancedPagination, { totalPages: totalPages, currentPage: page, onPageChange: setPage })), jsx(AddItemsModal, { isOpen: showAdd, onClose: () => setShowAdd(false), tenantKey: tenantKey, username: username, datasetName: datasetName }), deleteItemId && (jsx(DeleteItemConfirm, { isOpen: !!deleteItemId, onClose: () => setDeleteItemId(null), tenantKey: tenantKey, username: username, datasetName: datasetName, itemId: deleteItemId, onDeleted: leaveEmptiedPage }))] }) }));
|
|
35
56
|
}
|
|
36
57
|
|
|
37
58
|
export { BenchmarkItemsModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benchmark-items-modal.js","sources":["../../../../../../../../src/components/profile/benchmarks/benchmark-items-modal.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"benchmark-items-modal.js","sources":["../../../../../../../../src/components/profile/benchmarks/benchmark-items-modal.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAS,GAAG,EAAE;AAUpB,MAAM,MAAM,GAAG,CAAC,KAAc,MAAM,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAE9F,MAAM,SAAS,GAAG,CAAC,KAAc,KAAK,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;AAE7D,SAAU,mBAAmB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,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Q,CAAA,EAAA,CACN,EAAA,CACJ,CACP,EAEA,UAAU,GAAG,CAAC,KACbA,GAAA,CAAC,kBAAkB,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAA,CAAI,CACzF,EAEDA,GAAA,CAAC,aAAa,EAAA,EACZ,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM,UAAU,CAAC,KAAK,CAAC,EAChC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EAAA,CACxB,EAED,YAAY,KACXA,GAAA,CAAC,iBAAiB,EAAA,EAChB,MAAM,EAAE,CAAC,CAAC,YAAY,EACtB,OAAO,EAAE,MAAM,eAAe,CAAC,IAAI,CAAC,EACpC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,gBAAgB,EAAA,CAC3B,CACH,CAAA,EAAA,CACa,EAAA,CACT;AAEb;;;;"}
|
|
@@ -1,54 +1,200 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { toast } from 'sonner';
|
|
4
4
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '../../ui/dialog.js';
|
|
5
5
|
import { Input } from '../../ui/input.js';
|
|
6
6
|
import { Label } from '../../ui/label.js';
|
|
7
7
|
import { Textarea } from '../../ui/textarea.js';
|
|
8
8
|
import { Button } from '../../ui/button.js';
|
|
9
|
-
import {
|
|
9
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../ui/tabs.js';
|
|
10
|
+
import { FieldInfo } from '../../field-info.js';
|
|
11
|
+
import { useLazyListEvalDatasetsQuery, useCreateEvalDatasetMutation } from '@iblai/data-layer';
|
|
10
12
|
import { useT } from '../../../i18n/context.js';
|
|
11
13
|
import '../../../packages/i18n/dist/index.esm.js';
|
|
14
|
+
import { EVALS_DIALOG } from './evals-ui.js';
|
|
15
|
+
import { useQaForm, QaForm } from './qa-form.js';
|
|
16
|
+
import Info from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/info.js';
|
|
12
17
|
import LoaderCircle from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/loader-circle.js';
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
// Every address of a benchmark carries its name as one path segment, so a
|
|
20
|
+
// name with a slash, or one made only of dots, could never be opened again.
|
|
21
|
+
const UNREACHABLE_NAME = /\/|^\.+$/;
|
|
22
|
+
const LABEL_ROW = 'flex h-4 items-center gap-2';
|
|
23
|
+
// The Create Agent dialog's step tabs.
|
|
24
|
+
const STEP_TAB = 'rounded-md bg-gray-100 px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-200 data-[state=active]:bg-gradient-to-r data-[state=active]:from-[#2563EB] data-[state=active]:to-[#93C5FD] data-[state=active]:text-white';
|
|
25
|
+
const FIRST_QUESTION_ID = 'benchmark-item-input-0';
|
|
26
|
+
const CSV_FILE_ID = 'benchmark-csv-file';
|
|
27
|
+
const MAX_NAME_MATCHES = 200;
|
|
28
|
+
function CreateBenchmarkModal({ isOpen, onClose, tenantKey, username, onCreated }) {
|
|
15
29
|
const t = useT();
|
|
30
|
+
const [step, setStep] = useState('details');
|
|
16
31
|
const [name, setName] = useState('');
|
|
17
32
|
const [description, setDescription] = useState('');
|
|
18
|
-
const [
|
|
33
|
+
const [nameError, setNameError] = useState(null);
|
|
34
|
+
const [formError, setFormError] = useState(null);
|
|
35
|
+
const [createdName, setCreatedName] = useState(null);
|
|
36
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
37
|
+
const [findDatasets] = useLazyListEvalDatasetsQuery();
|
|
38
|
+
const [createDataset, { isLoading: isCreating }] = useCreateEvalDatasetMutation();
|
|
39
|
+
const qa = useQaForm({ tenantKey, username });
|
|
40
|
+
const isBusy = isSubmitting || isCreating || qa.isSaving;
|
|
41
|
+
const isCreated = createdName !== null;
|
|
42
|
+
const hasName = name.trim().length > 0;
|
|
43
|
+
// The retry follows the rule `qa.save` sends by, not the showing tab alone,
|
|
44
|
+
// so Save Q&A stays on for the Q&A that Create has just tried to send.
|
|
45
|
+
const canSubmit = !qa.hasProblem && (isCreated ? !qa.isEmpty : hasName);
|
|
46
|
+
// A name refused at Create comes back to Details while Name is still
|
|
47
|
+
// disabled by the request, so the cursor can only go there once it ends.
|
|
48
|
+
const nameInputRef = useRef(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
var _a;
|
|
51
|
+
if (nameError && !isBusy)
|
|
52
|
+
(_a = nameInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
53
|
+
}, [nameError, isBusy]);
|
|
54
|
+
// The first Question is only on the page while the Manual tab is showing.
|
|
55
|
+
// Left on the footer, the cursor would sit on Create and a second Enter
|
|
56
|
+
// would create the benchmark.
|
|
57
|
+
const focusQaField = useRef(false);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if (step !== 'qa' || !focusQaField.current)
|
|
61
|
+
return;
|
|
62
|
+
focusQaField.current = false;
|
|
63
|
+
(_b = ((_a = document.getElementById(FIRST_QUESTION_ID)) !== null && _a !== void 0 ? _a : document.getElementById(CSV_FILE_ID))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
64
|
+
}, [step]);
|
|
65
|
+
const nameLabel = t('benchmarksCreateBenchmarkModal.nameLabel');
|
|
66
|
+
const descriptionLabel = t('benchmarksCreateBenchmarkModal.descriptionLabel');
|
|
19
67
|
const reset = () => {
|
|
68
|
+
setStep('details');
|
|
20
69
|
setName('');
|
|
21
70
|
setDescription('');
|
|
71
|
+
setNameError(null);
|
|
72
|
+
setFormError(null);
|
|
73
|
+
setCreatedName(null);
|
|
74
|
+
qa.reset();
|
|
22
75
|
};
|
|
23
|
-
const
|
|
24
|
-
if (isLoading)
|
|
25
|
-
return;
|
|
76
|
+
const finish = (created) => {
|
|
26
77
|
reset();
|
|
27
78
|
onClose();
|
|
79
|
+
if (created)
|
|
80
|
+
onCreated === null || onCreated === void 0 ? void 0 : onCreated(created);
|
|
28
81
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
82
|
+
const handleClose = () => {
|
|
83
|
+
if (isBusy)
|
|
84
|
+
return;
|
|
85
|
+
finish(createdName);
|
|
86
|
+
};
|
|
87
|
+
// The backend answers a second create with the same name by updating the
|
|
88
|
+
// benchmark that already has it, so the Q&A would land in that one.
|
|
89
|
+
const isNameTaken = async (candidate) => {
|
|
90
|
+
const matches = await findDatasets({
|
|
91
|
+
org: tenantKey,
|
|
92
|
+
userId: username,
|
|
93
|
+
name: candidate,
|
|
94
|
+
limit: MAX_NAME_MATCHES,
|
|
95
|
+
}).unwrap();
|
|
96
|
+
return matches.results.some((dataset) => dataset.name === candidate);
|
|
97
|
+
};
|
|
98
|
+
const refuseName = (reason) => {
|
|
99
|
+
setNameError(reason);
|
|
100
|
+
setStep('details');
|
|
101
|
+
};
|
|
102
|
+
const handleNext = () => {
|
|
103
|
+
if (!hasName)
|
|
34
104
|
return;
|
|
105
|
+
if (UNREACHABLE_NAME.test(name.trim())) {
|
|
106
|
+
refuseName('invalid');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
focusQaField.current = true;
|
|
110
|
+
setStep('qa');
|
|
111
|
+
};
|
|
112
|
+
const createBenchmark = async () => {
|
|
113
|
+
const trimmedName = name.trim();
|
|
114
|
+
if (UNREACHABLE_NAME.test(trimmedName)) {
|
|
115
|
+
refuseName('invalid');
|
|
116
|
+
return null;
|
|
35
117
|
}
|
|
36
118
|
try {
|
|
119
|
+
if (await isNameTaken(trimmedName)) {
|
|
120
|
+
refuseName('taken');
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
37
123
|
await createDataset({
|
|
38
124
|
org: tenantKey,
|
|
39
125
|
userId: username,
|
|
40
|
-
body: { name:
|
|
126
|
+
body: { name: trimmedName, description: description.trim() || undefined },
|
|
41
127
|
}).unwrap();
|
|
42
|
-
toast.success(t('benchmarksCreateBenchmarkModal.successToast'));
|
|
43
|
-
reset();
|
|
44
|
-
onClose();
|
|
45
128
|
}
|
|
46
|
-
catch (
|
|
47
|
-
|
|
48
|
-
|
|
129
|
+
catch (_a) {
|
|
130
|
+
setFormError('create');
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
setCreatedName(trimmedName);
|
|
134
|
+
return trimmedName;
|
|
135
|
+
};
|
|
136
|
+
const handleSubmit = async (event) => {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
if (step === 'details' && !isCreated) {
|
|
139
|
+
handleNext();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!canSubmit || isBusy)
|
|
143
|
+
return;
|
|
144
|
+
setNameError(null);
|
|
145
|
+
setFormError(null);
|
|
146
|
+
setIsSubmitting(true);
|
|
147
|
+
try {
|
|
148
|
+
const benchmarkName = createdName !== null && createdName !== void 0 ? createdName : (await createBenchmark());
|
|
149
|
+
if (!benchmarkName)
|
|
150
|
+
return;
|
|
151
|
+
if (qa.isEmpty) {
|
|
152
|
+
toast.success(t('benchmarksCreateBenchmarkModal.successToastNoQa'));
|
|
153
|
+
finish(benchmarkName);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let count;
|
|
157
|
+
try {
|
|
158
|
+
count = await qa.save(benchmarkName);
|
|
159
|
+
}
|
|
160
|
+
catch (_a) {
|
|
161
|
+
setFormError('qa');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
toast.success(t('benchmarksCreateBenchmarkModal.successToast', { count }));
|
|
165
|
+
finish(benchmarkName);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
setIsSubmitting(false);
|
|
49
169
|
}
|
|
50
170
|
};
|
|
51
|
-
return (jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: jsxs(DialogContent, { "aria-label": "create-benchmark", className: "
|
|
171
|
+
return (jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && handleClose(), children: jsxs(DialogContent, { "aria-label": "create-benchmark", className: "flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden",
|
|
172
|
+
// Not the autoFocus attribute: opened from another dialog, that dialog
|
|
173
|
+
// takes the focus back and it then lands on the Name info icon.
|
|
174
|
+
onOpenAutoFocus: (event) => {
|
|
175
|
+
var _a;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
(_a = nameInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
178
|
+
}, children: [jsxs(DialogHeader, { className: "flex-none", children: [jsx(DialogTitle, { children: t('benchmarksCreateBenchmarkModal.title') }), jsx(DialogDescription, { children: t('benchmarksCreateBenchmarkModal.description') })] }), jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col gap-4", children: [jsxs(Tabs, { value: step, onValueChange: (next) => setStep(next), className: "flex min-h-0 flex-1 flex-col gap-4", children: [jsxs(TabsList, { className: "flex-none justify-start self-start", children: [jsx(TabsTrigger, { value: "details", disabled: isBusy, className: STEP_TAB, children: t('benchmarksCreateBenchmarkModal.detailsTab') }), jsx(TabsTrigger, { value: "qa", disabled: isBusy || !hasName, className: STEP_TAB, children: t('benchmarksCreateBenchmarkModal.qaTab') })] }), jsxs("div", { className: EVALS_DIALOG.scrollBody, children: [jsxs(TabsContent, { value: "details", className: "mt-0 grid content-start gap-4", children: [jsxs("div", { className: "grid gap-1.5", children: [jsxs("div", { className: LABEL_ROW, children: [jsx(Label, { htmlFor: "benchmark-name", children: nameLabel }), jsx(FieldInfo, { label: nameLabel, text: t('benchmarksCreateBenchmarkModal.nameInfo') })] }), jsx(Input, { ref: nameInputRef, id: "benchmark-name", value: name, onChange: (event) => {
|
|
179
|
+
setName(event.target.value);
|
|
180
|
+
setNameError(null);
|
|
181
|
+
}, placeholder: t('benchmarksCreateBenchmarkModal.namePlaceholder'), maxLength: 255, disabled: isBusy || isCreated,
|
|
182
|
+
// Details is unmounted while Q&A shows. When the request has
|
|
183
|
+
// already ended, the effect above runs before Name is back.
|
|
184
|
+
autoFocus: nameError !== null, "aria-invalid": nameError ? true : undefined, "aria-describedby": nameError ? 'benchmark-name-error' : undefined, className: nameError ? 'border-red-500' : undefined }), nameError && (jsx("p", { id: "benchmark-name-error", role: "alert", className: EVALS_DIALOG.fieldError, children: nameError === 'taken'
|
|
185
|
+
? t('benchmarksCreateBenchmarkModal.nameTaken')
|
|
186
|
+
: t('benchmarksCreateBenchmarkModal.nameInvalid') }))] }), jsxs("div", { className: "grid gap-1.5", children: [jsxs("div", { className: LABEL_ROW, children: [jsx(Label, { htmlFor: "benchmark-description", children: descriptionLabel }), jsx(FieldInfo, { label: descriptionLabel, text: t('benchmarksCreateBenchmarkModal.descriptionInfo') })] }), jsx(Textarea, { id: "benchmark-description", value: description, onChange: (event) => setDescription(event.target.value), placeholder: t('benchmarksCreateBenchmarkModal.descriptionPlaceholder'), rows: 3, disabled: isBusy || isCreated })] })] }), jsxs(TabsContent, { value: "qa", forceMount: true, hidden: step !== 'qa', className: "mt-0 grid min-w-0 content-start gap-4 data-[state=inactive]:hidden", children: [jsxs("p", { "data-testid": "benchmark-qa-hint", className: "flex items-start gap-2 rounded-md border border-gray-200 bg-gray-50 p-3 text-xs text-gray-600", children: [jsx(Info, { className: "mt-px h-3.5 w-3.5 flex-none text-gray-500", "aria-hidden": "true" }), jsx("span", { children: t('benchmarksCreateBenchmarkModal.qaHint') })] }), jsx(QaForm, { form: qa, disabled: isBusy, idPrefix: "benchmark-" })] })] })] }), formError && (jsx("p", { role: "alert", className: `flex-none ${EVALS_DIALOG.fieldError}`, children: formError === 'qa'
|
|
187
|
+
? t('benchmarksCreateBenchmarkModal.qaError')
|
|
188
|
+
: t('benchmarksCreateBenchmarkModal.createError') })), jsxs(DialogFooter, { className: `flex-none ${EVALS_DIALOG.footer}`, children: [jsx(Button, { type: "button", variant: "outline", onClick: handleClose, disabled: isBusy, children: isCreated
|
|
189
|
+
? t('benchmarksCreateBenchmarkModal.close')
|
|
190
|
+
: t('benchmarksCreateBenchmarkModal.cancel') }), step === 'details' && !isCreated ? (jsx(Button, { type: "submit", disabled: isBusy || !hasName, className: EVALS_DIALOG.primaryButton, children: t('benchmarksCreateBenchmarkModal.next') }, "next")) : (jsxs(Button, { type: "submit", disabled: isBusy || !canSubmit,
|
|
191
|
+
// The second click of a double-click on Next lands here.
|
|
192
|
+
onClick: (event) => {
|
|
193
|
+
if (event.detail > 1)
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
}, className: EVALS_DIALOG.primaryButton, children: [isBusy && jsx(LoaderCircle, { className: EVALS_DIALOG.spinner }), isCreated
|
|
196
|
+
? t('benchmarksCreateBenchmarkModal.saveQa')
|
|
197
|
+
: t('benchmarksCreateBenchmarkModal.create')] }, "create"))] })] })] }) }));
|
|
52
198
|
}
|
|
53
199
|
|
|
54
200
|
export { CreateBenchmarkModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-benchmark-modal.js","sources":["../../../../../../../../src/components/profile/benchmarks/create-benchmark-modal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","Loader2"],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-benchmark-modal.js","sources":["../../../../../../../../src/components/profile/benchmarks/create-benchmark-modal.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","Loader2"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA;AACA;AACA,MAAM,gBAAgB,GAAG,UAAU;AAEnC,MAAM,SAAS,GAAG,6BAA6B;AAC/C;AACA,MAAM,QAAQ,GACZ,8NAA8N;AAChO,MAAM,iBAAiB,GAAG,wBAAwB;AAClD,MAAM,WAAW,GAAG,o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S,EAAE,YAAY,CAAC,aAAa,EAAA,QAAA,EAEpC,CAAC,CAAC,qCAAqC,CAAC,EAAA,EALrC,MAAM,CAMH,KAETC,IAAA,CAAC,MAAM,EAAA,EAEL,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,MAAM,IAAI,CAAC,SAAS;;AAE9B,oCAAA,OAAO,EAAE,CAAC,KAAK,KAAI;AACjB,wCAAA,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;4CAAE,KAAK,CAAC,cAAc,EAAE;AAC9C,oCAAA,CAAC,EACD,SAAS,EAAE,YAAY,CAAC,aAAa,aAEpC,MAAM,IAAID,IAACE,YAAO,EAAA,EAAC,SAAS,EAAE,YAAY,CAAC,OAAO,EAAA,CAAI,EACtD;AACC,8CAAE,CAAC,CAAC,uCAAuC;AAC3C,8CAAE,CAAC,CAAC,uCAAuC,CAAC,CAAA,EAAA,EAZ1C,QAAQ,CAaL,CACV,CAAA,EAAA,CACY,CAAA,EAAA,CACV,CAAA,EAAA,CACO,EAAA,CACT;AAEb;;;;"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { toast } from 'sonner';
|
|
3
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '../../ui/dialog.js';
|
|
3
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '../../ui/dialog.js';
|
|
4
4
|
import { Button } from '../../ui/button.js';
|
|
5
5
|
import { useDeleteEvalDatasetItemMutation } from '@iblai/data-layer';
|
|
6
6
|
import { useT } from '../../../i18n/context.js';
|
|
7
7
|
import '../../../packages/i18n/dist/index.esm.js';
|
|
8
|
+
import { EVALS_DIALOG } from './evals-ui.js';
|
|
9
|
+
import LoaderCircle from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/loader-circle.js';
|
|
8
10
|
|
|
9
|
-
function DeleteItemConfirm({ isOpen, onClose, tenantKey, username, datasetName, itemId, }) {
|
|
11
|
+
function DeleteItemConfirm({ isOpen, onClose, tenantKey, username, datasetName, itemId, onDeleted, }) {
|
|
10
12
|
const t = useT();
|
|
11
13
|
const [deleteItem, { isLoading }] = useDeleteEvalDatasetItemMutation();
|
|
12
14
|
const handleDelete = async () => {
|
|
13
|
-
var _a;
|
|
14
15
|
try {
|
|
15
16
|
await deleteItem({
|
|
16
17
|
org: tenantKey,
|
|
@@ -19,16 +20,16 @@ function DeleteItemConfirm({ isOpen, onClose, tenantKey, username, datasetName,
|
|
|
19
20
|
itemId,
|
|
20
21
|
}).unwrap();
|
|
21
22
|
toast.success(t('benchmarksDeleteItemConfirm.successToast'));
|
|
23
|
+
onDeleted === null || onDeleted === void 0 ? void 0 : onDeleted();
|
|
22
24
|
onClose();
|
|
23
25
|
}
|
|
24
|
-
catch (
|
|
25
|
-
|
|
26
|
-
toast.error(detail || t('benchmarksDeleteItemConfirm.errorToast'));
|
|
26
|
+
catch (_a) {
|
|
27
|
+
toast.error(t('benchmarksDeleteItemConfirm.errorToast'));
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
return (jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && !isLoading && onClose(), children: jsxs(DialogContent, { "aria-label": "delete-benchmark-item", className: "max-w-md
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
return (jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && !isLoading && onClose(), children: jsxs(DialogContent, { "aria-label": "delete-benchmark-item", className: "w-full max-w-md", children: [jsxs(DialogHeader, { className: "min-w-0", children: [jsx(DialogTitle, { children: t('benchmarksDeleteItemConfirm.title') }), jsx(DialogDescription, { className: "break-words", children: t('benchmarksDeleteItemConfirm.confirmation') })] }), jsxs(DialogFooter, { className: EVALS_DIALOG.footer, children: [jsx(Button, { type: "button", variant: "outline", onClick: onClose, disabled: isLoading, children: t('benchmarksDeleteItemConfirm.cancel') }), jsxs(Button, { type: "button", className: EVALS_DIALOG.primaryButton, onClick: handleDelete, disabled: isLoading, children: [isLoading && jsx(LoaderCircle, { className: EVALS_DIALOG.spinner }), isLoading
|
|
31
|
+
? t('benchmarksDeleteItemConfirm.deleting')
|
|
32
|
+
: t('benchmarksDeleteItemConfirm.delete')] })] })] }) }));
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export { DeleteItemConfirm };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-item-confirm.js","sources":["../../../../../../../../src/components/profile/benchmarks/delete-item-confirm.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete-item-confirm.js","sources":["../../../../../../../../src/components/profile/benchmarks/delete-item-confirm.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","Loader2"],"mappings":";;;;;;;;;;SA4BgB,iBAAiB,CAAC,EAChC,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EACX,MAAM,EACN,SAAS,GACH,EAAA;AACN,IAAA,MAAM,CAAC,GAAG,IAAI,EAAE;IAChB,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,gCAAgC,EAAE;AAEtE,IAAA,MAAM,YAAY,GAAG,YAAW;AAC9B,QAAA,IAAI;AACF,YAAA,MAAM,UAAU,CAAC;AACf,gBAAA,GAAG,EAAE,SAAS;AACd,gBAAA,MAAM,EAAE,QAAQ;gBAChB,WAAW;gBACX,MAAM;aACP,CAAC,CAAC,MAAM,EAAE;YACX,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC;AAC5D,YAAA,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,EAAI;AACb,YAAA,OAAO,EAAE;QACX;AAAE,QAAA,OAAA,EAAA,EAAM;YACN,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAwC,CAAC,C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;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Button } from '../../ui/button.js';
|
|
3
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '../../ui/tooltip.js';
|
|
4
|
+
import { cn } from '../../../lib/utils.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The runs table of the Evals tab (`evaluation-tab/index.tsx`) is the
|
|
8
|
+
* reference: these are its classes, so every evals table has one header row,
|
|
9
|
+
* cell padding, text style, hover and radius. Change them together with it.
|
|
10
|
+
*/
|
|
11
|
+
const EVALS_TABLE = {
|
|
12
|
+
frame: 'overflow-hidden rounded-md border',
|
|
13
|
+
headerRow: 'bg-muted/50 h-[45px] border-b',
|
|
14
|
+
head: 'p-3 text-left text-sm whitespace-nowrap text-[#646464] dark:text-gray-400',
|
|
15
|
+
actionsHead: 'w-[104px] p-3 text-right text-sm whitespace-nowrap text-[#646464] dark:text-gray-400',
|
|
16
|
+
row: 'text-sm hover:bg-blue-50 dark:hover:bg-gray-800',
|
|
17
|
+
cell: 'p-3 text-gray-700 dark:text-gray-300',
|
|
18
|
+
actionsCell: 'p-3 text-right',
|
|
19
|
+
/** Puts the icon's right edge on the ACTIONS heading's right edge. */
|
|
20
|
+
rowAction: '-mr-2',
|
|
21
|
+
};
|
|
22
|
+
const EVALS_DIALOG = {
|
|
23
|
+
footer: 'gap-2 sm:space-x-0',
|
|
24
|
+
primaryButton: 'bg-gradient-to-r from-[#2563EB] to-[#93C5FD] text-white hover:opacity-90',
|
|
25
|
+
spinner: 'h-4 w-4 animate-spin',
|
|
26
|
+
/** A title that carries a name: wraps instead of running under the close button. */
|
|
27
|
+
nameTitle: 'pr-6 leading-snug break-words',
|
|
28
|
+
/** The scrolling part of a tall dialog; the margins leave room for focus rings. */
|
|
29
|
+
scrollBody: '-mx-6 -my-1 min-h-0 flex-1 overflow-y-auto px-6 py-1',
|
|
30
|
+
loading: 'flex items-center justify-center py-10',
|
|
31
|
+
empty: 'py-10',
|
|
32
|
+
fieldError: 'text-xs text-red-500',
|
|
33
|
+
};
|
|
34
|
+
function IconAction({ label, tooltip, icon: Icon, destructive, disabled, onClick, className, }) {
|
|
35
|
+
return (jsxs(Tooltip, { delayDuration: 200, children: [jsx(TooltipTrigger, { asChild: true, children: jsx(Button, { type: "button", variant: "ghost", size: "icon", "aria-label": label, disabled: disabled, onClick: onClick, className: cn('h-8 w-8', destructive && 'hover:bg-red-50 hover:text-red-600', className), children: jsx(Icon, { className: "h-4 w-4", "aria-hidden": "true" }) }) }), jsx(TooltipContent, { className: "ibl-tooltip-content z-50", children: tooltip !== null && tooltip !== void 0 ? tooltip : label })] }));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { EVALS_DIALOG, EVALS_TABLE, IconAction };
|
|
39
|
+
//# sourceMappingURL=evals-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evals-ui.js","sources":["../../../../../../../../src/components/profile/benchmarks/evals-ui.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AAQA;;;;AAIG;AACI,MAAM,WAAW,GAAG;AACzB,IAAA,KAAK,EAAE,mCAAmC;AAC1C,IAAA,SAAS,EAAE,+BAA+B;AAC1C,IAAA,IAAI,EAAE,2EAA2E;AACjF,IAAA,WAAW,EACT,sFAAsF;AACxF,IAAA,GAAG,EAAE,iDAAiD;AACtD,IAAA,IAAI,EAAE,sCAAsC;AAC5C,IAAA,WAAW,EAAE,gBAAgB;;AAE7B,IAAA,SAAS,EAAE,OAAO;;AAGb,MAAM,YAAY,GAAG;AAC1B,IAAA,MAAM,EAAE,oBAAoB;AAC5B,IAAA,aAAa,EAAE,0EAA0E;AACzF,IAAA,OAAO,EAAE,sBAAsB;;AAE/B,IAAA,SAAS,EAAE,+BAA+B;;AAE1C,IAAA,UAAU,EAAE,sDAAsD;AAClE,IAAA,OAAO,EAAE,wCAAwC;AACjD,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,UAAU,EAAE,sBAAsB;;SAcpB,UAAU,CAAC,EACzB,KAAK,EACL,OAAO,EACP,IAAI,EAAE,IAAI,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,GACO,EAAA;AAChB,IAAA,QACEA,IAAA,CAAC,OAAO,EAAA,EAAC,aAAa,EAAE,GAAG,EAAA,QAAA,EAAA,CACzBC,GAAA,CAAC,cAAc,IAAC,OAAO,EAAA,IAAA,EAAA,QAAA,EACrBA,IAAC,MAAM,EAAA,EACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,EAAA,YAAA,EACC,KAAK,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,WAAW,IAAI,oCAAoC,EAAE,SAAS,CAAC,EAAA,QAAA,EAExFA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,SAAS,EAAA,aAAA,EAAa,MAAM,EAAA,CAAG,EAAA,CACxC,EAAA,CACM,EACjBA,IAAC,cAAc,EAAA,EAAC,SAAS,EAAC,0BAA0B,EAAA,QAAA,EAAE,OAAO,KAAA,IAAA,IAAP,OAAO,cAAP,OAAO,GAAI,KAAK,EAAA,CAAkB,CAAA,EAAA,CAChF;AAEd;;;;"}
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
import { jsxs, jsx
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useListEvalDatasetsQuery, evalTotalPages } from '@iblai/data-layer';
|
|
4
|
-
import {
|
|
4
|
+
import { Table, TableHeader, TableRow, TableHead, TableBody, TableCell } from '../../ui/table.js';
|
|
5
5
|
import { Button } from '../../ui/button.js';
|
|
6
6
|
import { Spinner } from '../../spinner/index.js';
|
|
7
7
|
import { AdvancedPagination } from '../../advance-pagination.js';
|
|
8
|
+
import { ActivityControlRow, ActivitySearchBox, ActivityControlActions, ACTIVITY_CONTROL } from '../../activity-tab/activity-layout.js';
|
|
9
|
+
import { ActivityEmptyState } from '../../activity-tab/activity-empty-state.js';
|
|
10
|
+
import '../../activity-tab/activity-phone.js';
|
|
11
|
+
import '../../ui/pagination.js';
|
|
8
12
|
import { formatDistanceToNow } from 'date-fns';
|
|
13
|
+
import 'rehype-parse';
|
|
14
|
+
import 'rehype-remark';
|
|
15
|
+
import 'remark-stringify';
|
|
16
|
+
import 'remark-html';
|
|
17
|
+
import 'remark';
|
|
18
|
+
import '../../../node_modules/.pnpm/dompurify@3.4.18/node_modules/dompurify/dist/purify.es.js';
|
|
9
19
|
import { useT } from '../../../i18n/context.js';
|
|
10
20
|
import '../../../packages/i18n/dist/index.esm.js';
|
|
21
|
+
import { useDateFnsLocale } from '../../../i18n/date-fns-locale.js';
|
|
11
22
|
import { parseEvalDate } from '../../modals/edit-mentor-modal/tabs/evaluation-tab/utils.js';
|
|
12
23
|
import { CreateBenchmarkModal } from './create-benchmark-modal.js';
|
|
13
24
|
import { BenchmarkItemsModal } from './benchmark-items-modal.js';
|
|
14
|
-
import
|
|
25
|
+
import { EVALS_DIALOG, EVALS_TABLE, IconAction } from './evals-ui.js';
|
|
15
26
|
import Plus from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js';
|
|
16
27
|
import Eye from '../../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/eye.js';
|
|
17
28
|
|
|
18
29
|
const PAGE_SIZE = 10;
|
|
19
|
-
function BenchmarksTab({ tenantKey, username, }) {
|
|
30
|
+
function BenchmarksTab({ tenantKey, username, onBenchmarkCreated, }) {
|
|
20
31
|
var _a;
|
|
21
32
|
const t = useT();
|
|
33
|
+
const dateLocale = useDateFnsLocale();
|
|
22
34
|
const [page, setPage] = useState(1);
|
|
23
35
|
const [searchQuery, setSearchQuery] = useState('');
|
|
24
36
|
const [showCreate, setShowCreate] = useState(false);
|
|
@@ -30,16 +42,23 @@ function BenchmarksTab({ tenantKey, username, }) {
|
|
|
30
42
|
limit: PAGE_SIZE,
|
|
31
43
|
});
|
|
32
44
|
const benchmarks = (_a = data === null || data === void 0 ? void 0 : data.results) !== null && _a !== void 0 ? _a : [];
|
|
33
|
-
const
|
|
45
|
+
const isSearching = searchQuery.trim().length > 0;
|
|
46
|
+
const filtered = isSearching
|
|
34
47
|
? benchmarks.filter((benchmark) => benchmark.name.toLowerCase().includes(searchQuery.toLowerCase()))
|
|
35
48
|
: benchmarks;
|
|
36
49
|
const totalPages = evalTotalPages(data === null || data === void 0 ? void 0 : data.count, PAGE_SIZE);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
const isWaiting = isLoading || (filtered.length === 0 && isFetching);
|
|
51
|
+
const createdOf = (value) => {
|
|
52
|
+
const created = parseEvalDate(value);
|
|
53
|
+
return created ? formatDistanceToNow(created, { addSuffix: true, locale: dateLocale }) : '—';
|
|
54
|
+
};
|
|
55
|
+
// A new benchmark is listed first, so show the page and the filter it is on.
|
|
56
|
+
const handleCreated = (name) => {
|
|
57
|
+
setPage(1);
|
|
58
|
+
setSearchQuery('');
|
|
59
|
+
onBenchmarkCreated === null || onBenchmarkCreated === void 0 ? void 0 : onBenchmarkCreated(name);
|
|
60
|
+
};
|
|
61
|
+
return (jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [jsxs(ActivityControlRow, { children: [jsx(ActivitySearchBox, { type: "text", value: searchQuery, onChange: (event) => setSearchQuery(event.target.value), placeholder: t('benchmarksIndex.searchPlaceholder'), "aria-label": t('benchmarksIndex.searchAriaLabel') }), jsx(ActivityControlActions, { children: jsxs(Button, { type: "button", onClick: () => setShowCreate(true), className: `cursor-pointer max-md:flex-1 ${ACTIVITY_CONTROL.primaryButton}`, children: [jsx(Plus, { className: "h-4 w-4" }), t('benchmarksIndex.newBenchmark')] }) })] }), isWaiting && (jsx("div", { className: EVALS_DIALOG.loading, children: jsx(Spinner, {}) })), !isWaiting && filtered.length === 0 && (jsx(ActivityEmptyState, { className: EVALS_DIALOG.empty, children: isSearching ? t('benchmarksIndex.empty') : t('benchmarksIndex.emptyNone') })), !isWaiting && filtered.length > 0 && (jsx("div", { className: EVALS_TABLE.frame, children: jsxs(Table, { className: "table-fixed", children: [jsx(TableHeader, { children: jsxs(TableRow, { className: EVALS_TABLE.headerRow, children: [jsx(TableHead, { className: EVALS_TABLE.head, children: t('benchmarksIndex.nameColumn') }), jsx(TableHead, { className: `hidden md:table-cell ${EVALS_TABLE.head}`, children: t('benchmarksIndex.descriptionColumn') }), jsx(TableHead, { className: `hidden w-[140px] sm:table-cell ${EVALS_TABLE.head}`, children: t('benchmarksIndex.createdColumn') }), jsx(TableHead, { className: EVALS_TABLE.actionsHead, children: t('benchmarksIndex.actionsColumn') })] }) }), jsx(TableBody, { children: filtered.map((benchmark) => (jsxs(TableRow, { className: EVALS_TABLE.row, children: [jsx(TableCell, { className: `font-medium break-words ${EVALS_TABLE.cell}`, children: benchmark.name }), jsx(TableCell, { className: `hidden md:table-cell ${EVALS_TABLE.cell}`, children: jsx("div", { className: "line-clamp-2 break-words", children: benchmark.description || '—' }) }), jsx(TableCell, { className: `hidden truncate sm:table-cell ${EVALS_TABLE.cell}`, children: createdOf(benchmark.created_at) }), jsx(TableCell, { className: EVALS_TABLE.actionsCell, children: jsx(IconAction, { label: t('benchmarksIndex.viewItemsAriaLabel', { name: benchmark.name }), tooltip: t('benchmarksIndex.viewItems'), icon: Eye, onClick: () => setViewBenchmark(benchmark.name), className: EVALS_TABLE.rowAction }) })] }, benchmark.name))) })] }) })), totalPages > 1 && (jsx(AdvancedPagination, { totalPages: totalPages, currentPage: page, onPageChange: setPage })), jsx(CreateBenchmarkModal, { isOpen: showCreate, onClose: () => setShowCreate(false), tenantKey: tenantKey, username: username, onCreated: handleCreated }), viewBenchmark && (jsx(BenchmarkItemsModal, { isOpen: !!viewBenchmark, onClose: () => setViewBenchmark(null), tenantKey: tenantKey, username: username, datasetName: viewBenchmark }))] }));
|
|
43
62
|
}
|
|
44
63
|
|
|
45
64
|
export { BenchmarksTab as default };
|