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

978 | Fix: Inputs not saved to Evaluation Scenario #979

Closed
wants to merge 2 commits into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Answer ONLY with one of the given grading or evaluation options.

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -276,19 +276,20 @@ Answer ONLY with one of the given grading or evaluation options.
if (evaluation_scenario_id) {
const data = {
outputs: [{variant_id: variants[0].variantId, variant_output: outputVariantX}],
inputs: rows[rowNumber].inputs,
}

const aiCritiqueScoreResponse = await evaluateAICritiqueForEvalScenario({
correct_answer: rows[rowNumber].correctAnswer,
llm_app_prompt_template: evaluation.llmAppPromptTemplate,
inputs: rows[rowNumber].inputs,
inputs: data.inputs,
outputs: data.outputs,
evaluation_prompt_template: evaluationPromptTemplate,
open_ai_key: getApikeys(),
})

try {
const responseData = await updateEvaluationScenario(
await updateEvaluationScenario(
evaluation.id,
evaluation_scenario_id,
{...data, score: aiCritiqueScoreResponse.data},
Expand Down Expand Up @@ -346,13 +347,16 @@ Answer ONLY with one of the given grading or evaluation options.
) {
return
}

if (text) return text

if (record.outputs && record.outputs.length > 0) {
const outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
)?.variant_output
return <div>{outputValue}</div>
}
return text
return ""
},
}
},
Expand Down Expand Up @@ -386,7 +390,7 @@ Answer ONLY with one of the given grading or evaluation options.
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const CustomCodeRunEvaluationTable: React.FC<CustomCodeEvaluationTableProps> = (

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -384,13 +384,14 @@ const CustomCodeRunEvaluationTable: React.FC<CustomCodeEvaluationTableProps> = (
</center>
)
}
if (text) return text
if (record.outputs && record.outputs.length > 0) {
const outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
)?.variant_output
return <div>{outputValue}</div>
}
return text
return ""
},
}
},
Expand Down Expand Up @@ -424,7 +425,7 @@ const CustomCodeRunEvaluationTable: React.FC<CustomCodeEvaluationTableProps> = (
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const ExactMatchEvaluationTable: React.FC<ExactMatchEvaluationTableProps> = ({

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -236,6 +236,7 @@ const ExactMatchEvaluationTable: React.FC<ExactMatchEvaluationTableProps> = ({
const data = {
score: isCorrect ? "correct" : "wrong",
outputs: [{variant_id: variants[0].variantId, variant_output: outputVariantX}],
inputs: rows[rowNumber].inputs,
}

updateEvaluationScenario(
Expand Down Expand Up @@ -286,13 +287,14 @@ const ExactMatchEvaluationTable: React.FC<ExactMatchEvaluationTableProps> = ({
key: columnKey,
width: "25%",
render: (text: any, record: ExactMatchEvaluationTableRow, rowIndex: number) => {
if (text) return text
if (record.outputs && record.outputs.length > 0) {
const outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
)?.variant_output
return <div>{outputValue}</div>
}
return text
return ""
},
}
},
Expand Down Expand Up @@ -326,7 +328,7 @@ const ExactMatchEvaluationTable: React.FC<ExactMatchEvaluationTableProps> = ({
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -241,6 +241,7 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({
{
score,
outputs: [{variant_id: variants[0].variantId, variant_output: result}],
inputs: rows[rowIndex].inputs,
},
evaluation.evaluationType,
)
Expand Down Expand Up @@ -296,7 +297,7 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({
render: (value: any, record: RegexEvaluationTableRow, ix: number) => {
if (loading[ix]) return "Loading..."

let outputValue = value
let outputValue
if (record.outputs && record.outputs.length > 0) {
outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
Expand All @@ -305,7 +306,7 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({

return (
<Highlighter
textToHighlight={outputValue}
textToHighlight={value || outputValue || ""}
searchWords={[settings.regexPattern]}
/>
)
Expand Down Expand Up @@ -342,7 +343,7 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const SimilarityMatchEvaluationTable: React.FC<SimilarityMatchEvaluationTablePro

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -237,6 +237,7 @@ const SimilarityMatchEvaluationTable: React.FC<SimilarityMatchEvaluationTablePro
{
score: isSimilar,
outputs: [{variant_id: variants[0].variantId, variant_output: result}],
inputs: rows[rowIndex].inputs,
},
evaluation.evaluationType,
)
Expand Down Expand Up @@ -287,14 +288,15 @@ const SimilarityMatchEvaluationTable: React.FC<SimilarityMatchEvaluationTablePro
width: "25%",
render: (text: any, record: SimilarityMatchEvaluationTableRow, ix: number) => {
if (loading[ix]) return "Loading..."
if (text) return text

if (record.outputs && record.outputs.length > 0) {
const outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
)?.variant_output
return <div>{outputValue}</div>
}
return text
return ""
},
}
},
Expand Down Expand Up @@ -328,7 +330,7 @@ const SimilarityMatchEvaluationTable: React.FC<SimilarityMatchEvaluationTablePro
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const WebhookEvaluationTable: React.FC<WebhookEvaluationTableProps> = ({

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement>,
rowIndex: any,
rowIndex: number,
inputFieldKey: number,
) => {
const newRows = [...rows]
Expand Down Expand Up @@ -223,6 +223,7 @@ const WebhookEvaluationTable: React.FC<WebhookEvaluationTableProps> = ({
{
score,
outputs: [{variant_id: variants[0].variantId, variant_output: result}],
inputs: rows[rowIndex].inputs,
},
evaluation.evaluationType,
)
Expand Down Expand Up @@ -273,14 +274,14 @@ const WebhookEvaluationTable: React.FC<WebhookEvaluationTableProps> = ({
render: (value: any, record: WebhookEvaluationTableRow, ix: number) => {
if (loading[ix]) return "Loading..."

let outputValue = value
let outputValue
if (record.outputs && record.outputs.length > 0) {
outputValue = record.outputs.find(
(output: any) => output.variant_id === variants[i].variantId,
)?.variant_output
}

return outputValue
return value || outputValue || ""
},
}
},
Expand Down Expand Up @@ -314,7 +315,7 @@ const WebhookEvaluationTable: React.FC<WebhookEvaluationTableProps> = ({
<Input
placeholder={input.input_name}
value={input.input_value}
onChange={(e) => handleInputChange(e, record.id, index)}
onChange={(e) => handleInputChange(e, rowIndex, index)}
/>
</div>
))}
Expand Down
Loading