Skip to content

Commit

Permalink
Merge pull request #1298 from Agenta-AI/issue-1230/-Improve-human-eva…
Browse files Browse the repository at this point in the history
…l-loading-state

Improve human evaluation loading state
  • Loading branch information
mmabrouk authored Jan 29, 2024
2 parents 3a51601 + 531f87f commit dd81133
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface EvaluationTableProps {
evaluation: Evaluation
columnsCount: number
evaluationScenarios: ABTestingEvaluationTableRow[]
isLoading: boolean
}

export type ABTestingEvaluationTableRow = EvaluationScenario & {
Expand Down Expand Up @@ -129,6 +130,7 @@ const useStyles = createUseStyles({
const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({
evaluation,
evaluationScenarios,
isLoading,
}) => {
const classes = useStyles()
const router = useRouter()
Expand Down Expand Up @@ -560,6 +562,7 @@ const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({
updateEvaluationScenarioData={updateEvaluationScenarioData}
evaluation={evaluation}
variantData={variantData}
isLoading={isLoading}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const {Title} = Typography
interface EvaluationTableProps {
evaluation: Evaluation
evaluationScenarios: SingleModelEvaluationRow[]
isLoading: boolean
}

export type SingleModelEvaluationRow = EvaluationScenario & {
Expand Down Expand Up @@ -170,6 +171,7 @@ export const ParamsFormWithRun = ({
const SingleModelEvaluationTable: React.FC<EvaluationTableProps> = ({
evaluation,
evaluationScenarios,
isLoading,
}) => {
const classes = useStyles()
const router = useRouter()
Expand Down Expand Up @@ -580,6 +582,7 @@ const SingleModelEvaluationTable: React.FC<EvaluationTableProps> = ({
updateEvaluationScenarioData={updateEvaluationScenarioData}
evaluation={evaluation}
variantData={variantData}
isLoading={isLoading}
/>
)}
</div>
Expand Down
18 changes: 15 additions & 3 deletions agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import {useQueryParam} from "@/hooks/useQuery"
import {ChatMessage, Evaluation, EvaluationScenario, Variant} from "@/lib/Types"
import {
LeftOutlined,
LoadingOutlined,
PlayCircleOutlined,
PushpinFilled,
PushpinOutlined,
QuestionCircleOutlined,
RightOutlined,
} from "@ant-design/icons"
import {Button, Empty, Form, Input, Space, Tooltip, Typography, theme} from "antd"
import {Button, Empty, Form, Input, Result, Space, Tooltip, Typography, theme} from "antd"
import React, {useCallback, useEffect, useMemo, useRef} from "react"
import {createUseStyles} from "react-jss"
import EvaluationVotePanel from "./EvaluationVotePanel"
Expand Down Expand Up @@ -123,6 +124,11 @@ const useStyles = createUseStyles({
minWidth: 240,
maxWidth: 500,
},
centeredItem: {
display: "grid",
placeItems: "center",
width: "100%",
},
})

interface Props {
Expand All @@ -134,6 +140,7 @@ interface Props {
updateEvaluationScenarioData: (id: string, data: Partial<EvaluationScenario>) => void
evaluation: Evaluation
variantData: ReturnType<typeof useVariants>
isLoading: boolean
}

const EvaluationCardView: React.FC<Props> = ({
Expand All @@ -145,6 +152,7 @@ const EvaluationCardView: React.FC<Props> = ({
updateEvaluationScenarioData,
evaluation,
variantData,
isLoading,
}) => {
const classes = useStyles()
const {token} = theme.useToken()
Expand All @@ -163,6 +171,8 @@ const EvaluationCardView: React.FC<Props> = ({
return {scenario: evaluationScenarios[scenarioIndex], scenarioIndex}
}, [scenarioId, evaluationScenarios])

// console.log(evaluationScenarios, isLoading)

const rootRef = useRef<HTMLDivElement>(null)
const opened = useRef(false)
const callbacks = useRef({
Expand Down Expand Up @@ -316,7 +326,9 @@ const EvaluationCardView: React.FC<Props> = ({

return (
<div className={classes.root} tabIndex={1} ref={rootRef}>
{scenario ? (
{isLoading ? (
<Result className={classes.centeredItem} icon={<LoadingOutlined />} />
) : scenario ? (
<>
<div className={classes.evaluation}>
<div className={classes.heading}>
Expand Down Expand Up @@ -492,7 +504,7 @@ const EvaluationCardView: React.FC<Props> = ({
</div>
</>
) : (
<Empty description="Evaluation not found" />
<Empty description="Evaluation not found" className={classes.centeredItem} />
)}
</div>
)
Expand Down
4 changes: 4 additions & 0 deletions agenta-web/src/components/Evaluations/Evaluations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export default function Evaluations() {
fetchData()
}, [appId])

useEffect(() => {
getAllProviderLlmKeys()
}, [])

useEffect(() => {
if (variants.length > 0) {
const fetchAndSetSchema = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useAppId} from "@/hooks/useAppId"
import {JSSTheme, Variant, LLMRunRateLimit, testset} from "@/lib/Types"
import {evaluatorConfigsAtom, evaluatorsAtom} from "@/lib/atoms/evaluation"
import {apiKeyObject, getAllProviderLlmKeys, redirectIfNoLLMKeys} from "@/lib/helpers/utils"
import {getAllProviderLlmKeys, apiKeyObject, redirectIfNoLLMKeys} from "@/lib/helpers/utils"
import {fetchTestsets, fetchVariants} from "@/lib/services/api"
import {CreateEvaluationData, createEvalutaiton} from "@/services/evaluations"
import {PlusOutlined, QuestionCircleOutlined} from "@ant-design/icons"
Expand Down Expand Up @@ -78,6 +78,10 @@ const NewEvaluationModal: React.FC<Props> = ({onSuccess, ...props}) => {
const [showRateLimitInputs, setShowRateLimitInputs] = useState(false)
const [form] = Form.useForm()

useEffect(() => {
getAllProviderLlmKeys()
}, [])

useEffect(() => {
setFetching(true)
form.resetFields()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ABTestingEvaluationTable from "@/components/EvaluationTable/ABTestingEval
import {Evaluation} from "@/lib/Types"
import {loadEvaluation, loadEvaluationsScenarios, loadTestset} from "@/lib/services/api"
import {useRouter} from "next/router"
import {useEffect} from "react"
import {useEffect, useState} from "react"
import {fetchVariants} from "@/lib/services/api"
import {useAtom} from "jotai"
import {evaluationAtom, evaluationScenariosAtom} from "@/lib/atoms/evaluation"
Expand All @@ -15,6 +15,7 @@ export default function Evaluation() {
: ""
const [evaluationScenarios, setEvaluationScenarios] = useAtom(evaluationScenariosAtom)
const [evaluation, setEvaluation] = useAtom(evaluationAtom)
const [isLoading, setIsLoading] = useState(true)
const appId = router.query.app_id as string
const columnsCount = 2

Expand All @@ -23,8 +24,13 @@ export default function Evaluation() {
return
}
const init = async () => {
const data = await loadEvaluationsScenarios(evaluationTableId, evaluation)
setEvaluationScenarios(data)
setIsLoading(true)
try {
const data = await loadEvaluationsScenarios(evaluationTableId, evaluation)
setEvaluationScenarios(data)
} finally {
setTimeout(() => setIsLoading(false), 1000)
}
}
init()
}, [evaluation])
Expand Down Expand Up @@ -64,6 +70,7 @@ export default function Evaluation() {
columnsCount={columnsCount}
evaluationScenarios={evaluationScenarios as any[]}
evaluation={evaluation}
isLoading={isLoading}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function Evaluation() {
? router.query.evaluation_id.toString()
: ""
const [evaluationScenarios, setEvaluationScenarios] = useState<EvaluationScenario[]>([])
const [isLoading, setIsLoading] = useState(true)
const [evaluation, setEvaluation] = useState<Evaluation>()
const appId = router.query.app_id as string

Expand All @@ -20,13 +21,18 @@ export default function Evaluation() {
return
}
const init = async () => {
const data = await loadEvaluationsScenarios(evaluationTableId, evaluation)
setEvaluationScenarios(
data.map((item: GenericObject) => {
const numericScore = parseInt(item.score)
return {...item, score: isNaN(numericScore) ? null : numericScore}
}),
)
setIsLoading(true)
try {
const data = await loadEvaluationsScenarios(evaluationTableId, evaluation)
setEvaluationScenarios(
data.map((item: GenericObject) => {
const numericScore = parseInt(item.score)
return {...item, score: isNaN(numericScore) ? null : numericScore}
}),
)
} finally {
setTimeout(() => setIsLoading(false), 1000)
}
}
init()
}, [evaluation])
Expand Down Expand Up @@ -65,6 +71,7 @@ export default function Evaluation() {
<SingleModelEvaluationTable
evaluationScenarios={evaluationScenarios as any[]}
evaluation={evaluation}
isLoading={isLoading}
/>
)}
</div>
Expand Down

0 comments on commit dd81133

Please sign in to comment.