From 7a4e8d1da22ec44e0ebb239a542ee5b4222880f4 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Fri, 12 Apr 2024 23:34:28 +0100 Subject: [PATCH 1/5] hide latency and cost columns on filter --- .../pages/evaluations/evaluationCompare/EvaluationCompare.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx index 6e7607f41b..a613825a09 100644 --- a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx @@ -221,6 +221,7 @@ const EvaluationCompareMode: React.FC = () => { }) variants.forEach((variant, vi) => { + const isHidden = evalIds.includes(variant.evaluationId) colDefs.push({ headerComponent: (props: any) => ( @@ -230,6 +231,7 @@ const EvaluationCompareMode: React.FC = () => { ), + hide: !isHidden, minWidth: 120, flex: 1, valueGetter: (params) => { @@ -243,6 +245,7 @@ const EvaluationCompareMode: React.FC = () => { }) variants.forEach((variant, vi) => { + const isHidden = evalIds.includes(variant.evaluationId) colDefs.push({ headerComponent: (props: any) => ( @@ -253,6 +256,7 @@ const EvaluationCompareMode: React.FC = () => { ), minWidth: 120, + hide: !isHidden, flex: 1, valueGetter: (params) => { const cost = params.data?.variants.find( From 5fcc65e0e189bd597aca15dcf20a8ad909290074 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Sun, 14 Apr 2024 11:34:57 +0100 Subject: [PATCH 2/5] added icon to dropdown, fixed cost and latency filters and improved dropdown triggers --- .../evaluationResults/EvaluationResults.tsx | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/agenta-web/src/components/pages/evaluations/evaluationResults/EvaluationResults.tsx b/agenta-web/src/components/pages/evaluations/evaluationResults/EvaluationResults.tsx index ddca3a2bf3..4280f9a2bf 100644 --- a/agenta-web/src/components/pages/evaluations/evaluationResults/EvaluationResults.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluationResults/EvaluationResults.tsx @@ -3,10 +3,11 @@ import {AgGridReact} from "ag-grid-react" import {useAppTheme} from "@/components/Layout/ThemeContextProvider" import {ColDef} from "ag-grid-community" import {createUseStyles} from "react-jss" -import {Button, Dropdown, Space, Spin, Tag, Tooltip, theme} from "antd" +import {Button, Dropdown, DropdownProps, Space, Spin, Tag, Tooltip, theme} from "antd" import { CheckOutlined, DeleteOutlined, + DownOutlined, PlusCircleOutlined, SlidersOutlined, SwapOutlined, @@ -85,6 +86,7 @@ const EvaluationResults: React.FC = () => { const {token} = theme.useToken() const gridRef = useRef() const [hiddenCols, setHiddenCols] = useState([]) + const [filterColsDropdown, setFilterColsDropdown] = useState(false) const runningEvaluationIds = useMemo( () => @@ -279,6 +281,7 @@ const EvaluationResults: React.FC = () => { flex: 1, field: "average_latency", headerName: "Latency", + hide: hiddenCols.includes("Latency"), minWidth: 120, ...getFilterParams("number"), valueGetter: (params) => getTypedValue(params?.data?.average_latency), @@ -287,6 +290,7 @@ const EvaluationResults: React.FC = () => { flex: 1, field: "average_cost", headerName: "Cost", + hide: hiddenCols.includes("Cost"), minWidth: 120, ...getFilterParams("number"), valueGetter: (params) => getTypedValue(params?.data?.average_cost), @@ -338,6 +342,12 @@ const EvaluationResults: React.FC = () => { [colDefs], ) + const handleOpenChange: DropdownProps["onOpenChange"] = (nextOpen, info) => { + if (info.source === "trigger" || nextOpen) { + setFilterColsDropdown(nextOpen) + } + } + return ( <> {!fetching && !evaluations.length ? ( @@ -384,6 +394,8 @@ const EvaluationResults: React.FC = () => { ({ @@ -395,11 +407,16 @@ const EvaluationResults: React.FC = () => { ), })), - onClick: ({key}) => onToggleEvaluatorVisibility(key), + onClick: ({key}) => { + onToggleEvaluatorVisibility(key) + setFilterColsDropdown(true) + }, className: classes.dropdownMenu, }} > - + From a085846aefdb68abddf8c1b6fee57716d459bf2a Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Tue, 16 Apr 2024 14:59:07 +0100 Subject: [PATCH 3/5] added multiselect filtering in comparison view --- .../evaluationCompare/EvaluationCompare.tsx | 109 +++++++++++------- 1 file changed, 67 insertions(+), 42 deletions(-) diff --git a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx index a613825a09..cc180c2161 100644 --- a/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx +++ b/agenta-web/src/components/pages/evaluations/evaluationCompare/EvaluationCompare.tsx @@ -11,12 +11,12 @@ import { import {fetchAllComparisonResults} from "@/services/evaluations" import {ColDef} from "ag-grid-community" import {AgGridReact} from "ag-grid-react" -import {Button, Space, Spin, Switch, Tag, Tooltip, Typography} from "antd" +import {Button, Dropdown, DropdownProps, Space, Spin, Switch, Tag, Tooltip, Typography} from "antd" import React, {useEffect, useMemo, useRef, useState} from "react" import {createUseStyles} from "react-jss" import {getFilterParams, getTypedValue} from "@/lib/helpers/evaluate" import {getColorFromStr, getRandomColors} from "@/lib/helpers/colors" -import {CloseCircleOutlined, DownloadOutlined, UndoOutlined} from "@ant-design/icons" +import {CheckOutlined, DownOutlined, DownloadOutlined} from "@ant-design/icons" import {getAppValues} from "@/contexts/app.context" import {useQueryParam} from "@/hooks/useQuery" import {LongTextCellRenderer} from "../cellRenderers/cellRenderers" @@ -49,6 +49,21 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({ }, }, }, + dropdownMenu: { + "&>.ant-dropdown-menu-item": { + "& .anticon-check": { + display: "none", + }, + }, + "&>.ant-dropdown-menu-item-selected": { + "&:not(:hover)": { + backgroundColor: "transparent !important", + }, + "& .anticon-check": { + display: "inline-flex !important", + }, + }, + }, })) interface Props {} @@ -58,7 +73,7 @@ const EvaluationCompareMode: React.FC = () => { const classes = useStyles() const {appTheme} = useAppTheme() const [evaluationIdsStr = ""] = useQueryParam("evaluations") - const [evalIds, setEvalIds] = useState(evaluationIdsStr.split(",").filter((item) => !!item)) + const [evalIds] = useState(evaluationIdsStr.split(",").filter((item) => !!item)) const [hiddenVariants, setHiddenVariants] = useState([]) const [showDiff, setShowDiff] = useLocalStorage("showDiff", "show") const [fetching, setFetching] = useState(false) @@ -66,6 +81,13 @@ const EvaluationCompareMode: React.FC = () => { const [testset, setTestset] = useState() const [evaluators] = useAtom(evaluatorsAtom) const gridRef = useRef>() + const [filterColsDropdown, setFilterColsDropdown] = useState(false) + + const handleOpenChange: DropdownProps["onOpenChange"] = (nextOpen, info) => { + if (info.source === "trigger" || nextOpen) { + setFilterColsDropdown(nextOpen) + } + } const variants = useMemo(() => { return rows[0]?.variants || [] @@ -116,8 +138,6 @@ const EvaluationCompareMode: React.FC = () => { }) variants.forEach((variant, vi) => { - const isHidden = evalIds.includes(variant.evaluationId) - colDefs.push({ headerComponent: (props: any) => ( @@ -131,7 +151,7 @@ const EvaluationCompareMode: React.FC = () => { flex: 1, field: `variants.${vi}.output` as any, ...getFilterParams("text"), - hide: !isHidden, + hide: hiddenVariants.includes(variant.evaluationId), cellRenderer: (params: any) => { return ( <> @@ -183,7 +203,6 @@ const EvaluationCompareMode: React.FC = () => { Object.entries(confgisMap).forEach(([_, configs]) => { configs.forEach(({config, variant, color}) => { - const isHidden = evalIds.includes(variant.evaluationId) colDefs.push({ flex: 1, minWidth: 200, @@ -206,7 +225,7 @@ const EvaluationCompareMode: React.FC = () => { }, field: "variants.0.evaluatorConfigs.0.result" as any, ...getFilterParams("text"), - hide: !isHidden, + hide: hiddenVariants.includes(variant.evaluationId), valueGetter: (params) => { return getTypedValue( params.data?.variants @@ -221,7 +240,6 @@ const EvaluationCompareMode: React.FC = () => { }) variants.forEach((variant, vi) => { - const isHidden = evalIds.includes(variant.evaluationId) colDefs.push({ headerComponent: (props: any) => ( @@ -231,7 +249,7 @@ const EvaluationCompareMode: React.FC = () => { ), - hide: !isHidden, + hide: hiddenVariants.includes(variant.evaluationId), minWidth: 120, flex: 1, valueGetter: (params) => { @@ -245,7 +263,6 @@ const EvaluationCompareMode: React.FC = () => { }) variants.forEach((variant, vi) => { - const isHidden = evalIds.includes(variant.evaluationId) colDefs.push({ headerComponent: (props: any) => ( @@ -256,7 +273,7 @@ const EvaluationCompareMode: React.FC = () => { ), minWidth: 120, - hide: !isHidden, + hide: hiddenVariants.includes(variant.evaluationId), flex: 1, valueGetter: (params) => { const cost = params.data?.variants.find( @@ -269,7 +286,7 @@ const EvaluationCompareMode: React.FC = () => { }) return colDefs - }, [rows, showDiff, evalIds]) + }, [rows, showDiff, hiddenVariants]) const fetcher = () => { setFetching(true) @@ -297,15 +314,21 @@ const EvaluationCompareMode: React.FC = () => { }, [appId, evaluationIdsStr]) const handleToggleVariantVisibility = (evalId: string) => { - if (hiddenVariants.includes(evalId)) { - setHiddenVariants(hiddenVariants.filter((item) => item !== evalId)) - setEvalIds([...evalIds, evalId]) - } else { + if (!hiddenVariants.includes(evalId)) { setHiddenVariants([...hiddenVariants, evalId]) - setEvalIds(evalIds.filter((val) => val !== evalId)) + } else { + setHiddenVariants(hiddenVariants.filter((item) => item !== evalId)) } } + const shownCols = useMemo( + () => + evalIds + .map((item) => item) + .filter((item) => item !== undefined && !hiddenVariants.includes(item)) as string[], + [hiddenVariants], + ) + const onExport = () => { if (!gridRef.current) return const {currentApp} = getAppValues() @@ -341,30 +364,6 @@ const EvaluationCompareMode: React.FC = () => { ? 0.4 : 1, }} - icon={ - evalIds.length < 2 && - evalIds.includes( - v.evaluationId, - ) ? null : evalIds.includes(v.evaluationId) ? ( - - handleToggleVariantVisibility( - v.evaluationId, - ) - } - style={{cursor: "pointer"}} - /> - ) : ( - - handleToggleVariantVisibility( - v.evaluationId, - ) - } - style={{cursor: "pointer"}} - /> - ) - } > = () => { onClick={() => setShowDiff(showDiff === "show" ? "hide" : "show")} /> + ({ + key: configs.evaluationId as string, + label: ( + + + <>{configs.variantName} + + ), + })), + onClick: ({key}) => { + handleToggleVariantVisibility(key) + setFilterColsDropdown(true) + }, + className: classes.dropdownMenu, + }} + > + +