Skip to content

Commit

Permalink
Merge pull request #1453 from Agenta-AI/issue-1450/-expand-evaluation…
Browse files Browse the repository at this point in the history
…-output-on-result-overflow

We can't see the full output value in evaluations scenarios
  • Loading branch information
aakrem authored Mar 25, 2024
2 parents a567db7 + f77f150 commit c313cb9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({
},
}))

export function LongTextCellRenderer(params: ICellRendererParams) {
export function LongTextCellRenderer(params: ICellRendererParams, output?: any) {
const {value, api, node} = params
const [expanded, setExpanded] = useState(
node.rowHeight !== api.getSizesForCurrentTheme().rowHeight,
Expand All @@ -95,11 +95,11 @@ export function LongTextCellRenderer(params: ICellRendererParams) {
cellsArr.forEach((cell) => {
cell.setAttribute(
"style",
"overflow: visible; white-space: pre-wrap; text-overflow: unset;",
"overflow: visible; white-space: pre-wrap; text-overflow: unset; line-height: 2.5em;",
)
})
const height = Math.max(...cellsArr.map((cell) => cell.scrollHeight))
node.setRowHeight(height <= defaultHeight ? defaultHeight * 2 : height)
node.setRowHeight(height <= defaultHeight ? defaultHeight * 2 : height + 10)
} else {
cellsArr.forEach((cell) => {
cell.setAttribute(
Expand All @@ -121,9 +121,9 @@ export function LongTextCellRenderer(params: ICellRendererParams) {
return (
<div
className={classes.longCell}
style={expanded ? {textWrap: "wrap", lineHeight: "2em", paddingTop: 6.5} : undefined}
style={expanded ? {textWrap: "wrap", paddingTop: 6.5} : undefined}
>
{value}
{output ? output : value}
<Space align="center" size="middle">
{expanded ? (
<FullscreenExitOutlined onClick={onExpand} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const EvaluationCompareMode: React.FC<Props> = () => {
field: `inputs.${ix}.value` as any,
...getFilterParams("text"),
pinned: "left",
cellRenderer: LongTextCellRenderer,
cellRenderer: (params: any) => LongTextCellRenderer(params),
})
})

Expand All @@ -108,7 +108,7 @@ const EvaluationCompareMode: React.FC<Props> = () => {
field: "correctAnswer",
...getFilterParams("text"),
pinned: "left",
cellRenderer: LongTextCellRenderer,
cellRenderer: (params: any) => LongTextCellRenderer(params),
})

variants.forEach((variant, vi) => {
Expand All @@ -128,25 +128,28 @@ const EvaluationCompareMode: React.FC<Props> = () => {
cellRenderer: (params: any) => {
return (
<>
{showDiff === "show" ? (
<span>
<CompareOutputDiff
variantOutput={getTypedValue(
params.data?.variants.find(
(item: any) =>
item.evaluationId === variant.evaluationId,
)?.output?.result,
)}
expectedOutput={params.data?.correctAnswer}
/>
</span>
) : (
getTypedValue(
params.data?.variants.find(
(item: any) => item.evaluationId === variant.evaluationId,
)?.output?.result,
)
)}
{showDiff === "show"
? LongTextCellRenderer(
params,
<CompareOutputDiff
variantOutput={getTypedValue(
params.data?.variants.find(
(item: any) =>
item.evaluationId === variant.evaluationId,
)?.output?.result,
)}
expectedOutput={params.data?.correctAnswer}
/>,
)
: LongTextCellRenderer(
params,
getTypedValue(
params.data?.variants.find(
(item: any) =>
item.evaluationId === variant.evaluationId,
)?.output?.result,
),
)}
</>
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const EvaluationScenarios: React.FC<Props> = () => {
valueGetter: (params) => {
return getTypedValue(params.data?.inputs[index])
},
cellRenderer: LongTextCellRenderer,
cellRenderer: (params: any) => LongTextCellRenderer(params),
})
})
colDefs.push({
Expand All @@ -83,7 +83,7 @@ const EvaluationScenarios: React.FC<Props> = () => {
valueGetter: (params) => {
return params.data?.correct_answer?.toString() || ""
},
cellRenderer: LongTextCellRenderer,
cellRenderer: (params: any) => LongTextCellRenderer(params),
})
evalaution?.variants.forEach((_, index) => {
colDefs.push({
Expand All @@ -97,14 +97,15 @@ const EvaluationScenarios: React.FC<Props> = () => {
if (result && result.type == "error") {
return `${result?.error?.message}\n${result?.error?.stacktrace}`
}
return showDiff === "show" ? (
<CompareOutputDiff
variantOutput={result?.value}
expectedOutput={params.data?.correct_answer}
/>
) : (
result?.value
)
return showDiff === "show"
? LongTextCellRenderer(
params,
<CompareOutputDiff
variantOutput={result?.value}
expectedOutput={params.data?.correct_answer}
/>,
)
: LongTextCellRenderer(params)
},
valueGetter: (params) => {
const result = params.data?.outputs[index].result
Expand Down

0 comments on commit c313cb9

Please sign in to comment.