:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { BuiltLogic, useValues } from 'kea'
import { LemonTable, Link } from '@posthog/lemon-ui'
import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { urls } from 'scenes/urls'
import { llmEvaluationsLogic } from '../evaluations/llmEvaluationsLogic'
import { EvaluationRun } from '../evaluations/types'
import type { generationEvaluationRunsLogicType } from '../generationEvaluationRunsLogic'
import { EvaluationExplanation } from './EvaluationExplanation'
import { EvaluationResultTag, compareEvaluationResults } from './EvaluationResultTag'
import { EvaluationRunTargetCell } from './EvaluationRunTargetCell'
import { EvaluationRunTimestampCell } from './EvaluationRunTimestampCell'
export function GenerationEvalRunsTable({
generationRunsLogic,
}: {
generationRunsLogic: BuiltLogic<generationEvaluationRunsLogicType>
}): JSX.Element {
const { generationEvaluationRuns, generationEvaluationRunsLoading } = useValues(generationRunsLogic)
const { detectorEvaluationIds, evaluations } = useValues(llmEvaluationsLogic)
const columns: LemonTableColumns<EvaluationRun> = [
{
title: 'Timestamp',
key: 'timestamp',
render: (_, run) => <EvaluationRunTimestampCell run={run} />,
sorter: (a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
},
{
title: 'Evaluation',
key: 'evaluation',
render: (_, run) => (
<Link to={urls.aiObservabilityEvaluation(run.evaluation_id)} className="text-primary font-medium">
{run.evaluation_name}
</Link>
),
},
{
title: 'Target',
key: 'target',
render: (_, run) => <EvaluationRunTargetCell run={run} />,
},
{
title: 'Result',
key: 'result',
render: (_, run) => (
<EvaluationResultTag
run={run}
categoryOptions={
evaluations?.find((evaluation) => evaluation.id === run.evaluation_id)?.output_config.options
}
passingRule={
evaluations?.find((evaluation) => evaluation.id === run.evaluation_id)?.output_config
.passing_rule
}
trueIsFailure={detectorEvaluationIds.includes(run.evaluation_id)}
/>
),
sorter: (a, b) =>
compareEvaluationResults(
b,
a,
{ trueIsFailure: detectorEvaluationIds.includes(b.evaluation_id) },
{ trueIsFailure: detectorEvaluationIds.includes(a.evaluation_id) }
),
},
{
title: 'Details',
key: 'reasoning',
render: (_, run) => <EvaluationExplanation reasoning={run.reasoning} probability={run.probability} />,
},
]
return (
<div>
<LemonTable
columns={columns}
dataSource={generationEvaluationRuns}
loading={generationEvaluationRunsLoading}
rowKey="id"
pagination={{
pageSize: 20,
}}
emptyState={
<div className="text-center py-8">
<div className="text-muted mb-2">No evaluations run yet</div>
<div className="text-sm text-muted">
Evaluation runs for this trace and its generations will appear here.
</div>
</div>
}
/>
</div>
)
}