Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to mark both as correct in A\B testing human evaluation #1216

Closed
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
13 changes: 13 additions & 0 deletions agenta-backend/agenta_backend/services/results_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions agenta-web/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
"types": ["cypress", "node"],
},
"include": ["**/*.ts"]
"include": ["**/*.ts"],
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -105,11 +105,12 @@ const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({

const [rows, setRows] = useState<ABTestingEvaluationTableRow[]>([])
const [evaluationStatus, setEvaluationStatus] = useState<EvaluationFlow>(evaluation.status)
const [evaluationResults, setEvaluationResults] = useState<any>(null)
const [evaluationResults, setEvaluationResults] = useState<EvaluationResult | null>(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
Expand Down Expand Up @@ -423,6 +424,13 @@ const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({
className={classes.statWrong}
/>
</Col>
<Col span={4}>
<Statistic
title="Both are good:"
value={`${positive_votes} out of ${num_of_rows}`}
className={classes.statCorrect}
/>
</Col>
</Row>
</Card>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -76,6 +77,7 @@ const ComparisonVote: React.FC<ComparisonVoteProps> = ({variants, onChange, valu
const classes = useStyles()
const {token} = theme.useToken()
const badId = "0"
const goodId = "1"

const getOnClick = (variantId: string) => () => {
onChange(variantId)
Expand Down Expand Up @@ -111,6 +113,18 @@ const ComparisonVote: React.FC<ComparisonVoteProps> = ({variants, onChange, valu
>
Both are bad
</Button>

<ConfigProvider theme={{token: {colorError: VARIANT_COLORS[2]}}}>
<Button
danger
type={value === goodId ? "primary" : undefined}
key={goodId}
onClick={getOnClick(goodId)}
data-cy="evaluation-vote-panel-comparison-both-good-vote-button-button"
>
Both are good
</Button>
</ConfigProvider>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {useVariants} from "@/lib/hooks/useVariant"
export const VARIANT_COLORS = [
"#297F87", // "#722ed1",
"#F6D167", //"#13c2c2",
"#4caf50",
]

const useStyles = createUseStyles({
Expand Down
4 changes: 4 additions & 0 deletions agenta-web/src/lib/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
6 changes: 3 additions & 3 deletions agenta-web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"],
}
Loading