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

feat: rerun single button in ai critics #1076

Merged
merged 1 commit into from
Dec 19, 2023
Merged
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
@@ -1,6 +1,6 @@
import {useState, useEffect} from "react"
import type {ColumnType} from "antd/es/table"
import {LineChartOutlined} from "@ant-design/icons"
import {CaretRightOutlined, LineChartOutlined} from "@ant-design/icons"
import {
Button,
Card,
Expand Down Expand Up @@ -141,6 +141,15 @@ const useStyles = createUseStyles({
color: "#3f8600",
},
},
inputTestBtn: {
width: "100%",
display: "flex",
justifyContent: "flex-end",
"& button": {
marginLeft: 10,
},
marginTop: "0.75rem",
},
})

const AICritiqueEvaluationTable: React.FC<AICritiqueEvaluationTableProps> = ({
Expand Down Expand Up @@ -235,35 +244,54 @@ Answer ONLY with one of the given grading or evaluation options.
}

const runEvaluation = async (rowIndex: number) => {
const inputParamsDict = rows[rowIndex].inputs.reduce((acc: {[key: string]: any}, item) => {
acc[item.input_name] = item.input_value
return acc
}, {})

const columnsDataNames = ["columnData0"]
let idx = 0
for (const columnName of columnsDataNames) {
setRowValue(rowIndex, "evaluationFlow", EvaluationFlow.COMPARISON_RUN_STARTED)

let result = await callVariant(
inputParamsDict,
variantData[idx].inputParams!,
variantData[idx].optParams!,
appId || "",
variants[idx].baseId || "",
variantData[idx].isChatVariant
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
try {
setEvaluationStatus(EvaluationFlow.EVALUATION_STARTED)
bekossy marked this conversation as resolved.
Show resolved Hide resolved

const inputParamsDict = rows[rowIndex].inputs.reduce(
(acc: {[key: string]: any}, item) => {
acc[item.input_name] = item.input_value
return acc
},
{},
)
if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

setRowValue(rowIndex, columnName as any, result)
await evaluate(rowIndex)
setShouldFetchResults(true)
if (rowIndex === rows.length - 1) {
message.success("Evaluation Results Saved")
const columnsDataNames = ["columnData0"]
let idx = 0

for (const columnName of columnsDataNames) {
setRowValue(rowIndex, "evaluationFlow", EvaluationFlow.COMPARISON_RUN_STARTED)

let result = await callVariant(
inputParamsDict,
variantData[idx].inputParams!,
variantData[idx].optParams!,
appId || "",
variants[idx].baseId || "",
variantData[idx].isChatVariant
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)

if (variantData[idx].isChatVariant) {
result = contentToChatMessageString(result)
}

setRowValue(rowIndex, columnName as any, result)
await evaluate(rowIndex)
setShouldFetchResults(true)

if (rowIndex === rows.length - 1) {
message.success("Evaluation Results Saved")
}

idx++
}
idx++

setEvaluationStatus(EvaluationFlow.EVALUATION_FINISHED)
bekossy marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
console.error("Error during evaluation:", error)
setEvaluationStatus(EvaluationFlow.EVALUATION_FAILED)
bekossy marked this conversation as resolved.
Show resolved Hide resolved
message.error("Failed to run evaluation")
}
}

Expand Down Expand Up @@ -391,6 +419,15 @@ Answer ONLY with one of the given grading or evaluation options.
}
/>
)}

<div className={classes.inputTestBtn}>
<Button
onClick={() => runEvaluation(rowIndex)}
icon={<CaretRightOutlined />}
>
Run
</Button>
</div>
</div>
),
},
Expand Down
Loading