From 26c82fa740bee4232ac159ba996cb1a9c9f2a1ab Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 17 Jan 2024 12:20:20 +0100 Subject: [PATCH 1/5] added positive votes to backend --- .../agenta_backend/services/results_service.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agenta-backend/agenta_backend/services/results_service.py b/agenta-backend/agenta_backend/services/results_service.py index d33a1c419f..9881d62aca 100644 --- a/agenta-backend/agenta_backend/services/results_service.py +++ b/agenta-backend/agenta_backend/services/results_service.py @@ -47,10 +47,23 @@ async def _compute_stats_for_human_a_b_testing_evaluation(evaluation_scenarios: results = {} results["variants_votes_data"] = {} results["flag_votes"] = {} + results["positive_votes"] = {} flag_votes_nb = [ scenario for scenario in evaluation_scenarios if scenario.vote == "0" ] + + positive_votes_nb = [ + scenario for scenario in evaluation_scenarios if scenario.vote == "1" + ] + + results["positive_votes"]["number_of_votes"] = len(positive_votes_nb) + results["positive_votes"]["percentage"] = ( + round(len(positive_votes_nb) / len(evaluation_scenarios) * 100, 2) + if len(evaluation_scenarios) + else 0 + ) + results["flag_votes"]["number_of_votes"] = len(flag_votes_nb) results["flag_votes"]["percentage"] = ( round(len(flag_votes_nb) / len(evaluation_scenarios) * 100, 2) From 6a44b6f1d3e11b42ce65a2da60662ab0852848b5 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 17 Jan 2024 12:20:40 +0100 Subject: [PATCH 2/5] updated EvaluationResult to add positive vote type --- agenta-web/src/lib/Types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agenta-web/src/lib/Types.ts b/agenta-web/src/lib/Types.ts index e3634fbfbd..acd09728e3 100644 --- a/agenta-web/src/lib/Types.ts +++ b/agenta-web/src/lib/Types.ts @@ -106,6 +106,10 @@ export interface EvaluationResult { number_of_votes: number percentage: number } + positive_votes: { + number_of_votes: number + percentage: number + } variants: string[] variant_names: string[] variants_votes_data: { From 797e02c6b5b1b57065e47d563b679314ae65df49 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 17 Jan 2024 12:21:19 +0100 Subject: [PATCH 3/5] added and styled button for positive votes --- .../EvaluationTable/ABTestingEvaluationTable.tsx | 12 ++++++++++-- .../EvaluationCardView/EvaluationVotePanel.tsx | 14 ++++++++++++++ .../Evaluations/EvaluationCardView/index.tsx | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx index 1d5651738f..6c556e7cbd 100644 --- a/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/ABTestingEvaluationTable.tsx @@ -15,7 +15,7 @@ import {exportABTestingEvaluationData} from "@/lib/helpers/evaluate" import SecondaryButton from "../SecondaryButton/SecondaryButton" import {useQueryParam} from "@/hooks/useQuery" import EvaluationCardView, {VARIANT_COLORS} from "../Evaluations/EvaluationCardView" -import {Evaluation, EvaluationScenario, KeyValuePair, Variant} from "@/lib/Types" +import {Evaluation, EvaluationResult, EvaluationScenario, KeyValuePair, Variant} from "@/lib/Types" import {EvaluationTypeLabels, batchExecute, camelToSnake} from "@/lib/helpers/utils" import {testsetRowToChatMessages} from "@/lib/helpers/testset" import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel" @@ -105,11 +105,12 @@ const ABTestingEvaluationTable: React.FC = ({ const [rows, setRows] = useState([]) const [evaluationStatus, setEvaluationStatus] = useState(evaluation.status) - const [evaluationResults, setEvaluationResults] = useState(null) + const [evaluationResults, setEvaluationResults] = useState(null) const [viewMode, setViewMode] = useQueryParam("viewMode", "card") let num_of_rows = evaluationResults?.votes_data.nb_of_rows || 0 let flag_votes = evaluationResults?.votes_data.flag_votes?.number_of_votes || 0 + let positive_votes = evaluationResults?.votes_data.positive_votes.number_of_votes || 0 let appVariant1 = evaluationResults?.votes_data?.variants_votes_data?.[evaluation.variants[0]?.variantId] ?.number_of_votes || 0 @@ -423,6 +424,13 @@ const ABTestingEvaluationTable: React.FC = ({ className={classes.statWrong} /> + + + diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx index d36d84c072..a15fe2ef7c 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx @@ -3,6 +3,7 @@ import {Button, ConfigProvider, InputNumber, Spin, Typography, theme} from "antd import React from "react" import {createUseStyles} from "react-jss" import {VARIANT_COLORS} from "." +import {v4 as uuidv4} from "uuid" const useStyles = createUseStyles({ root: { @@ -76,6 +77,7 @@ const ComparisonVote: React.FC = ({variants, onChange, valu const classes = useStyles() const {token} = theme.useToken() const badId = "0" + const goodId = "1" const getOnClick = (variantId: string) => () => { onChange(variantId) @@ -111,6 +113,18 @@ const ComparisonVote: React.FC = ({variants, onChange, valu > Both are bad + + + + ) } diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx index a437d6c430..7009bd0091 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx @@ -26,6 +26,7 @@ import {useVariants} from "@/lib/hooks/useVariant" export const VARIANT_COLORS = [ "#297F87", // "#722ed1", "#F6D167", //"#13c2c2", + "#4caf50" ] const useStyles = createUseStyles({ From 38b966b8f4b318a6eaf8ae8e113db556f9eea902 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 17 Jan 2024 12:22:39 +0100 Subject: [PATCH 4/5] fixed prettier --- .../src/components/Evaluations/EvaluationCardView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx index 7009bd0091..19f17ca1c2 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx @@ -26,7 +26,7 @@ import {useVariants} from "@/lib/hooks/useVariant" export const VARIANT_COLORS = [ "#297F87", // "#722ed1", "#F6D167", //"#13c2c2", - "#4caf50" + "#4caf50", ] const useStyles = createUseStyles({ From f388f373eb5555b6bb1eb2357bfeffaf4b420200 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 17 Jan 2024 20:06:35 +0100 Subject: [PATCH 5/5] fixed prettier --- agenta-web/cypress/tsconfig.json | 4 ++-- agenta-web/tsconfig.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agenta-web/cypress/tsconfig.json b/agenta-web/cypress/tsconfig.json index dc618360a0..1235d8c20f 100644 --- a/agenta-web/cypress/tsconfig.json +++ b/agenta-web/cypress/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es5", "lib": ["es5", "dom"], - "types": ["cypress", "node"] + "types": ["cypress", "node"], }, - "include": ["**/*.ts"] + "include": ["**/*.ts"], } diff --git a/agenta-web/tsconfig.json b/agenta-web/tsconfig.json index 73b324e040..db62be51b5 100644 --- a/agenta-web/tsconfig.json +++ b/agenta-web/tsconfig.json @@ -15,9 +15,9 @@ "jsx": "preserve", "incremental": true, "paths": { - "@/*": ["./src/*"] - } + "@/*": ["./src/*"], + }, }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "cypress.config.ts", "cypress/**/*"] + "exclude": ["node_modules", "cypress.config.ts", "cypress/**/*"], }