: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
feat(aio): pick the eval method as cards and add a returns step (#129986)
Bernat Torresc4f70f0b8c53
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 0e737c603d3d..e95056db1b3c 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9219,25 +9219,25 @@ snapshots:scenes-app-ai-observability-instrumentation-checklist-card--warnings-with-a-dismissal--light:hash: v1.k794b7964.b0e06944ee7afe4af8cb39363280135111e71ba215aab56a3e410c79de62238b.WtW8suUOWanaTrvjxhV2Z_ANVDRmEW3bqHpTrTe5GoIscenes-app-ai-observability-new-evaluation--from-scratch--dark:- hash: v1.k794b7964.7ccaf69cf0e22860ac3c6b4f7f7f26701eafd010d5123e37c56fc848e6fe74a7.OpK0ahu9jaxpIlHEQ8mw1Sh7mdzqOONp4aw1LVbwzuA+ hash: v1.k794b7964.1623c532467fc2fb9021319640ab56552a83391fee86222a42627bb17667601b.nSDxQwNFpkX-6WGaA9yhItS9n2HoyhdGiqyEDOv1eX8scenes-app-ai-observability-new-evaluation--from-scratch--light:- hash: v1.k794b7964.816d9e830ebfeb8ac1303b3b59efe94150a1d2371cb78e3338153f176f521444.XhZKS15jlRkqnRcA2vpvX4Fs7ZEuvE23jm48lIAMqGE+ hash: v1.k794b7964.a3d8880f3f1cbf434a0c7a18914eb050b5d033574c89979d90945d04f1537ba5.9Th6uVg6fJ22ZWsbpTTGixJtC7pikKrioeL0YJ8vdY8scenes-app-ai-observability-new-evaluation--from-template--dark:- hash: v1.k794b7964.07380f3dfb3e23227666db25699716cb64a1ad87908c2f44ee8526d727195662.oibYuMDeIcQcBB8-xT_4kUNOi9WaFpEX734xD-sLBQY+ hash: v1.k794b7964.f9d9a09d9303c25bafcaaa20f59fd9628594e76e815539f2d7220fe5f96dcbc5.6hzX_X1xGupZ5Eatw5zyummoMJiz8rRAEHLPuK4cAokscenes-app-ai-observability-new-evaluation--from-template--light:- hash: v1.k794b7964.9c1d8e6148d26b50a85c618819388cc6108f52d5c6d71e40d661f6d403994e63.shdmDJxZKXSPIOJBz_AHBjJ-mDZgf3E0SJjRK7MP0VE+ hash: v1.k794b7964.54150a3b308abd9258f3eacbbb1194fce5cb6f429dac2ab8ca052e6180264fa8._bonOninP0AOBH3rqZ1MwCAGZxtS6SO7SGOa9gL_3DUscenes-app-ai-observability-new-evaluation--nothing-matches--dark:- hash: v1.k794b7964.8de1c6adc167189439f173be655c9ba621d431c569d490186e2edb21b5adab9a.y68wObiGXDm_gk9dpuMWLRhMgcLq9W8w2O3BR23qYzg+ hash: v1.k794b7964.396e08ce75fb2c312044909b41b1765deaca062000bbb525db0c321d9ace4516.QwHRq-3wwGDBXMGuGY33f6qntgpARIZDNbPC24WcMqYscenes-app-ai-observability-new-evaluation--nothing-matches--light:- hash: v1.k794b7964.19005b94e6654d7728de11e62a833dd04ca2232cf230a0ae15115a5ea803b631.DazOYwUIoHXTkv5XSJlVGspprGh0ALMDe_SxkhllWt8+ hash: v1.k794b7964.27310b4f90ce455265af48454939d09269e1cea8ea398a4e74ba4db951428767.bM2eMOm2joan81_iWeCnSovmnW-TCmWOYh7J35QfFuEscenes-app-ai-observability-new-evaluation--reports-open--dark:- hash: v1.k794b7964.7dd06c6e687d65fb2d75ed92dbc344ba3f9277ba17a0107d7f6eb410d31bd721.V9xJdZjH3bGMs9ZxKTtpZ5YJ58Mm1zzcz_UGRpjJZ3M+ hash: v1.k794b7964.5ad9bdae0566f15dcdc5238c62fffb399b9cdeaa1d5a02f1929b2cab5ca4dc52.XAeaho41k-IUXOFQWLIjcbw9CP5uZsS-DUuPk8xIGaUscenes-app-ai-observability-new-evaluation--reports-open--light:- hash: v1.k794b7964.7679f6ae83d3c6db477d8be83a813390bdeffda70944a9b2b3fd93d5c1220bed.mmWadDp5K9oYJGHsYiDnkfu5wDAXFYOqsPTqrgwYT7U+ hash: v1.k794b7964.2f347185de1abeeea3ac1cf1695f2d4ba31538107122355e8b85d0ef61ce927b.3eEJ2iM0k2Vzpd_A4wIFOV3VrZ5SsH3cX3WV97t3IWsscenes-app-ai-observability-new-evaluation--sentiment-evaluation--dark:- hash: v1.k794b7964.ac47d8aaeb570a78393cc59504adfa570a40a1a544ace57840c0dae235680603.4O7QEnavU1PIlLZw-fCCE7TO-6r3nrqU2WG0_02WyKc+ hash: v1.k794b7964.8c336b6ebde49b2757c37c13a6aa941963b43e634e95cb3e7a88c3cd12557442.CbHuQYy2RT5HfqU_87nmhziWlrb84bZryG-MXR9sNesscenes-app-ai-observability-new-evaluation--sentiment-evaluation--light:- hash: v1.k794b7964.69868b16ba3c403a48e038ee39dd0a2befa608feb9a3fc21375118ff54bb3e4e.TFLBq7ma7X2uapVb-eu18RUZakc5-WVt9OQ5QFiXwz8+ hash: v1.k794b7964.7111ca85011a30f773806bdcc42d96233c092103e3a16e9786da74a098cc354a.x0BG3GEY8hKgskXiUXY2VpX3JpOfdYKMy5xkJ4t2TtAscenes-app-ai-observability-offline-experiments-experiment--all-scorers--dark:hash: v1.k794b7964.5e999325599c0186b678a4aaba8423a09a578de4789220ddb18fbf7c64245764.9GJhQsDjcB9bKZSm5iX9O2RQApiIhl3KFVBhf1nv3_Iscenes-app-ai-observability-offline-experiments-experiment--all-scorers--light:diff --git a/products/ai_observability/frontend/e2e/evaluation-polarity.spec.ts b/products/ai_observability/frontend/e2e/evaluation-polarity.spec.tsindex fa30daa31de9..3003731e8588 100644--- a/products/ai_observability/frontend/e2e/evaluation-polarity.spec.ts+++ b/products/ai_observability/frontend/e2e/evaluation-polarity.spec.ts@@ -120,7 +120,7 @@ test.describe('AI observability boolean evaluation polarity', () => {const gotoConfiguration = async (): Promise<void> => {await page.goto(`/ai-evals/evaluations/${evaluationId}`)await page.getByTestId('llma-evaluation-configuration-tab').click()- await page.getByTestId('llma-evaluation-create-step-check').click()+ await page.getByTestId('llma-evaluation-create-step-output').click()}for (const option of [failOption, passOption]) {@@ -151,7 +151,7 @@ test.describe('AI observability boolean evaluation polarity', () => {await page.goto(`/ai-evals/evaluations/${legacy.evaluation_id}`)await page.getByTestId('llma-evaluation-configuration-tab').click()- await page.getByTestId('llma-evaluation-create-step-check').click()+ await page.getByTestId('llma-evaluation-create-step-output').click()await expect(page.getByTestId('llma-evaluation-true-is-pass')).toHaveClass(/LemonButton--primary/)})})@@ -275,7 +275,7 @@ test.describe('AI observability boolean evaluation polarity', () => {await page.goto(`/ai-evals/evaluations/${evalCId}`)await page.getByTestId('llma-evaluation-configuration-tab').click()- await page.getByTestId('llma-evaluation-create-step-check').click()+ await expect(page.getByTestId('llma-evaluation-create-step-output')).toHaveCount(0)await expect(page.getByTestId('llma-evaluation-true-is-failure')).toHaveCount(0)const sentimentEvents = buildSentimentRunEvents(diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.test.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.test.tsxindex a4255db2e4cd..0948ab5735ba 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.test.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.test.tsx@@ -54,18 +54,4 @@ describe('EvaluationCategoryEditor', () => {passing_rule: { categories: ['helpful'] },})})-- it('turning grading off drops the passing rule, so runs only get a category', () => {- const onChange = jest.fn()- const config: EvaluationOutputConfig = {- selection_mode: 'multiple',- options: [{ key: 'helpful', label: 'Helpful' }],- passing_rule: { categories: [] },- }- render(<EvaluationCategoryEditor config={config} onChange={onChange} showKeys={false} />)-- fireEvent.click(screen.getByLabelText('Grade runs as pass or fail'))-- expect(onChange).toHaveBeenCalledWith({ passing_rule: null })- })})diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.tsxindex 35653d7a4a3f..815c3402cfed 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryEditor.tsx@@ -1,15 +1,13 @@import { IconPlus, IconTrash } from '@posthog/icons'-import { LemonButton, LemonInput, LemonSwitch, Tooltip } from '@posthog/lemon-ui'--import { cn } from 'lib/utils/css-classes'+import { LemonButton, LemonInput, Tooltip } from '@posthog/lemon-ui'import { MAX_CATEGORICAL_OPTIONS } from '../constants'import type { EvaluationOutputConfig } from '../types'import { categoryKey } from './categoryKey'/**- * The categories of an evaluation. A new category's key follows its label. With grading on, the categories marked as a- * pass are the passing rule; with it off, runs get a category and no pass or fail.+ * The categories of an evaluation. A new category's key follows its label, and renaming or removing a category keeps+ * the passing rule pointing at the same categories.*/export function EvaluationCategoryEditor({config,@@ -26,7 +24,6 @@ export function EvaluationCategoryEditor({}): JSX.Element {const options = config.options ?? []const passing = config.passing_rule && 'categories' in config.passing_rule ? config.passing_rule.categories : []- const named = options.filter((option) => option.key)const grades = !!config.passing_ruleconst withPassing = (keys: string[]): EvaluationOutputConfig['passing_rule'] =>grades ? { categories: keys } : null@@ -99,62 +96,6 @@ export function EvaluationCategoryEditor({Add category</LemonButton></div>- {named.length > 0 && (- <div className="flex flex-col gap-2 pt-2">- <LemonSwitch- label="Grade runs as pass or fail"- checked={grades}- onChange={(on) => onChange({ passing_rule: on ? { categories: passing } : null })}- data-attr="llma-evaluation-create-category-grading"- />- {grades ? (- <div className="flex flex-col gap-1">- <span className="text-sm font-semibold">Which ones count as a pass?</span>- <div className="flex flex-wrap gap-1">- {named.map((option, index) => {- const passes = passing.includes(option.key)- return (- <button- key={`${index}-${option.key}`}- type="button"- aria-pressed={passes}- className={cn(- 'rounded border px-2 py-1 text-sm cursor-pointer transition-colors',- passes- ? 'bg-success-highlight border-success text-success font-semibold'- : 'bg-surface-primary hover:bg-fill-highlight-100'- )}- onClick={() =>- onChange({- passing_rule: withPassing(- passes- ? passing.filter((value) => value !== option.key)- : [...passing, option.key]- ),- })- }- data-attr="llma-evaluation-create-category-pass"- >- {option.label}- </button>- )- })}- </div>- <span className="text-xs text-secondary">- {passing.length > 0- ? 'Runs with any other category fail. Pass rates and reports use this.'- : config.selection_mode === 'multiple'- ? 'With none picked, only runs with no category pass.'- : 'Pick at least one category that counts as a pass.'}- </span>- </div>- ) : (- <span className="text-xs text-secondary">- Runs only get a category, with no pass rate or reports.- </span>- )}- </div>- )}</div>)}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.test.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.test.tsxnew file mode 100644index 000000000000..ad2a10e32c74--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.test.tsx@@ -0,0 +1,24 @@+import '@testing-library/jest-dom'++import { cleanup, fireEvent, render, screen } from '@testing-library/react'++import type { EvaluationOutputConfig } from '../types'+import { EvaluationCategoryPassing } from './EvaluationCategoryPassing'++describe('EvaluationCategoryPassing', () => {+ afterEach(cleanup)++ it('turning the pass rate off drops the passing rule, so runs only get a category', () => {+ const onChange = jest.fn()+ const config: EvaluationOutputConfig = {+ selection_mode: 'multiple',+ options: [{ key: 'helpful', label: 'Helpful' }],+ passing_rule: { categories: [] },+ }+ render(<EvaluationCategoryPassing config={config} onChange={onChange} />)++ fireEvent.click(screen.getByLabelText('Track a pass rate'))++ expect(onChange).toHaveBeenCalledWith({ passing_rule: null })+ })+})diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.tsxnew file mode 100644index 000000000000..f924514a415e--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCategoryPassing.tsx@@ -0,0 +1,60 @@+import { LemonCheckbox } from '@posthog/lemon-ui'++import type { EvaluationOutputConfig } from '../types'++export function EvaluationCategoryPassing({+ config,+ onChange,+}: {+ config: EvaluationOutputConfig+ onChange: (patch: EvaluationOutputConfig) => void+}): JSX.Element {+ // Rows that share a key are one category to the passing rule, so each key gets one checkbox.+ const options = (config.options ?? []).filter(+ (option, index, all) => option.key && all.findIndex((item) => item.key === option.key) === index+ )+ const passing = config.passing_rule && 'categories' in config.passing_rule ? config.passing_rule.categories : []+ const grades = !!config.passing_rule++ return (+ <div className="flex flex-col gap-2">+ <LemonCheckbox+ label="Track a pass rate"+ checked={grades}+ onChange={(on) => onChange({ passing_rule: on ? { categories: passing } : null })}+ data-attr="llma-evaluation-create-category-grading"+ />+ {grades && (+ <div className="flex flex-col gap-1 pl-6">+ <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-sm">+ <span className="text-secondary">Passing categories:</span>+ {options.map((option) => (+ <LemonCheckbox+ key={option.key}+ label={option.label}+ checked={passing.includes(option.key)}+ onChange={(on) =>+ onChange({+ passing_rule: {+ categories: on+ ? [...passing, option.key]+ : passing.filter((value) => value !== option.key),+ },+ })+ }+ data-attr="llma-evaluation-create-category-pass"+ />+ ))}+ </div>+ <span className="text-xs text-secondary">+ {passing.length > 0+ ? 'Runs with any other category fail.'+ : config.selection_mode === 'multiple'+ ? 'With none marked, only runs with no category pass.'+ : 'Mark at least one category that passes.'}+ </span>+ </div>+ )}+ </div>+ )+}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationChoiceCards.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationChoiceCards.tsxnew file mode 100644index 000000000000..0f7d72aed819--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/EvaluationChoiceCards.tsx@@ -0,0 +1,73 @@+import { IconCheckCircle } from '@posthog/icons'++import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { cn } from 'lib/utils/css-classes'++export interface EvaluationChoice<T extends string> {+ value: T+ label: string+ description: string+ icon: JSX.Element+ disabledReason?: string+}++export function EvaluationChoiceCards<T extends string>({+ label,+ value,+ options,+ onChange,+ dataAttr,+ stacked = false,+}: {+ label: string+ value: T+ options: EvaluationChoice<T>[]+ onChange: (value: T) => void+ dataAttr: string+ /** One card per row, for a narrow column next to other content. */+ stacked?: boolean+}): JSX.Element {+ return (+ <div+ role="radiogroup"+ aria-label={label}+ className={cn('grid grid-cols-1 gap-2', !stacked && '@min-[40rem]/evaluation:grid-cols-2')}+ data-attr={dataAttr}+ >+ {options.map((option) => {+ const selected = option.value === value+ return (+ <Tooltip key={option.value} title={option.disabledReason} openOnClick>+ <button+ type="button"+ role="radio"+ aria-checked={selected}+ // aria-disabled, not disabled, so the card stays focusable and its tooltip can say why.+ aria-disabled={!!option.disabledReason}+ onClick={() => {+ if (!option.disabledReason) {+ onChange(option.value)+ }+ }}+ className={cn(+ 'flex items-start gap-3 rounded p-3 text-left transition-colors motion-reduce:transition-none',+ selected+ ? 'border-2 border-accent bg-accent-highlight-light'+ : 'border border-primary bg-surface-primary hover:bg-fill-button-tertiary-hover',+ option.disabledReason ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'+ )}+ data-attr={`${dataAttr}-${option.value}`}+ >+ <span className="text-lg text-secondary shrink-0 mt-0.5">{option.icon}</span>+ <span className="flex flex-col gap-0.5 min-w-0 flex-1">+ <span className="text-sm font-semibold">{option.label}</span>+ <span className="text-xs text-secondary">{option.description}</span>+ </span>+ {selected && <IconCheckCircle className="text-accent text-base shrink-0" />}+ </button>+ </Tooltip>+ )+ })}+ </div>+ )+}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCreatePage.stories.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCreatePage.stories.tsxindex c3aebb6213d1..744b05bb4eac 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationCreatePage.stories.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCreatePage.stories.tsx@@ -77,7 +77,7 @@ export const ReportsOpen: Story = {}export const SentimentEvaluation: Story = {- parameters: { testOptions: { waitForSelector: '[data-attr="llma-evaluation-create-step-body-check"]' } },+ parameters: { testOptions: { waitForSelector: '[data-attr="llma-evaluation-create-step-body-name"]' } },decorators: [scene(1240)],play: async ({ canvasElement }) => {await openPart(canvasElement, 'method', 'Sentiment')diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationCreateReview.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationCreateReview.tsxindex 0b779ab0bc83..3ba7f2a48cc6 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationCreateReview.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationCreateReview.tsx@@ -20,7 +20,7 @@ export function EvaluationCreateReview({/** Goes to the step that sets an item. */onFix: (key: ChecklistKey) => void}): JSX.Element | null {- const { evaluation, canEnableReason, checkPastTraffic } = useValues(llmEvaluationLogic)+ const { evaluation, checkPastTraffic } = useValues(llmEvaluationLogic)const { setCheckPastTraffic } = useActions(llmEvaluationLogic)const { volume } = useValues(evaluationVolumeLogic)@@ -80,7 +80,7 @@ export function EvaluationCreateReview({)}{!evaluation.enabled && (<p className="mb-0 text-sm text-secondary">- {`It is created paused. ${canEnableReason ?? ''} Then turn it on from its page.`}+ It starts paused until you add a provider API key. Then turn it on from its page.</p>)}</div>diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationFormSteps.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationFormSteps.tsxindex ffb10944a7e0..5dc9e556f8fa 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationFormSteps.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationFormSteps.tsx@@ -5,6 +5,7 @@ import { Fragment } from 'react'import * as judgePng from '@posthog/brand/hoggies/png/judge'import * as magnifyingGlassPng from '@posthog/brand/hoggies/png/magnifying-glass'import * as officeWorkerPng from '@posthog/brand/hoggies/png/office-worker'+import * as organizedPng from '@posthog/brand/hoggies/png/organized'import * as reporterPng from '@posthog/brand/hoggies/png/reporter'import * as stampApprovedPng from '@posthog/brand/hoggies/png/stamp-approved'import { IconCheck } from '@posthog/icons'@@ -33,7 +34,7 @@ import { EvaluationVolumeEstimate } from './EvaluationVolumeEstimate'interface Step {// pinned: analytics property value, because the creation funnel reads it- key: 'name' | 'check' | 'traffic' | 'reports' | 'create'+ key: 'name' | 'output' | 'check' | 'traffic' | 'reports' | 'create'title: stringheading: string/** One paragraph per entry. */@@ -48,21 +49,30 @@ interface Step {const STEPS: Step[] = [{key: 'name',- title: 'Name',- heading: 'Name your evaluation',- description: ['People see this name on results and reports.'],+ title: 'Evaluate',+ heading: 'What it evaluates',+ description: ['Name it and choose how it decides.'],hoggie: pngHoggie(officeWorkerPng),- parts: [],+ parts: ['method'],checks: ['name'],},+ {+ key: 'output',+ title: 'Returns',+ heading: 'What it returns',+ description: ['Choose what each run returns, and which results count as a pass.'],+ hoggie: pngHoggie(organizedPng),+ parts: [],+ checks: ['result'],+ },{key: 'check',title: 'Check',- heading: 'What it checks',- description: ['Choose how each run gets checked, then write the instructions and pick what it returns.'],+ heading: 'How it checks',+ description: ['Write the prompt or the code that decides each result.'],hoggie: pngHoggie(judgePng),- parts: ['method', 'model'],- checks: ['criteria', 'result', 'model'],+ parts: ['model'],+ checks: ['criteria', 'model'],},{key: 'traffic',@@ -104,15 +114,20 @@ function StepContent({ step }: { step: Step['key'] }): JSX.Element | null {}switch (step) {case 'name':- return <EvaluationNameFields />- case 'check':return (<>+ <EvaluationNameFields /><EvaluationMethodPanel />+ </>+ )+ case 'output':+ return <EvaluationOutputFields />+ case 'check':+ return (+ <>{evaluation.evaluation_type === 'llm_judge' && <EvaluationModelPanel />}{evaluation.evaluation_type === 'llm_judge' && <EvaluationPromptEditor />}{evaluation.evaluation_type === 'hog' && <EvaluationCodeEditor />}- <EvaluationOutputFields /></>)case 'traffic':@@ -156,7 +171,12 @@ export function EvaluationFormSteps({if (!evaluation) {return null}- const steps = onCreate ? STEPS : STEPS.filter((candidate) => candidate.key !== 'create')+ // Sentiment has a fixed answer and no prompt, code, or model to set, so it skips those steps.+ const steps = STEPS.filter(+ (candidate) =>+ (onCreate || candidate.key !== 'create') &&+ (evaluation.evaluation_type !== 'sentiment' || (candidate.key !== 'check' && candidate.key !== 'output'))+ )const index = Math.max(0,steps.findIndex((candidate) => candidate.key === formStep)@@ -181,12 +201,12 @@ export function EvaluationFormSteps({<div className="flex flex-col gap-6"><EvaluationSentenceactiveParts={step.parts}- onPartClick={(part) =>- goTo(- STEPS.findIndex((candidate) => candidate.parts.includes(part)),- 'sentence'- )- }+ onPartClick={(part) => {+ const target = steps.findIndex((candidate) => candidate.parts.includes(part))+ if (target >= 0) {+ goTo(target, 'sentence')+ }+ }}/><nav className="flex flex-wrap items-center justify-center gap-2" aria-label="Steps">{steps.map((candidate, candidateIndex) => {diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationMethodPanel.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationMethodPanel.tsxindex 9138515109ff..79aee7d6d402 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationMethodPanel.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationMethodPanel.tsx@@ -1,29 +1,13 @@import { useActions, useValues } from 'kea'-import { LemonSegmentedButton, Link } from '@posthog/lemon-ui'+import { IconBolt, IconCode, IconEmoji, IconSparkles } from '@posthog/icons'import { modelPickerLogic } from '../../modelPickerLogic'import { llmEvaluationLogic } from '../llmEvaluationLogic'+import { EvaluationChoiceCards } from './EvaluationChoiceCards'type Method = 'llm_judge' | 'decision' | 'hog' | 'sentiment'-const METHOD_HINTS: Record<Method, React.ReactNode> = {- llm_judge: 'An LLM grades each run against your prompt and explains why, using your own AI provider key.',- decision:- 'A decision model answers your prompt with a probability and no written reasoning. It is faster and cheaper than an LLM judge.',- hog: (- <>- Deterministic{' '}- <Link to="https://posthog.com/docs/hog" target="_blank">- Hog code- </Link>{' '}- returns the result. It makes no LLM calls, and you can test it on recent generations.- </>- ),- sentiment:- "Classifies the user's last message as positive, neutral, or negative. Works for English only, so use an LLM judge for other languages.",-}-/** Who checks each run: an LLM judge with its model, a decision model, code, or the sentiment classifier. */export function EvaluationMethodPanel(): JSX.Element | null {const { evaluation, usesDecisionModel, isNewEvaluation } = useValues(llmEvaluationLogic)@@ -57,27 +41,46 @@ export function EvaluationMethodPanel(): JSX.Element | null {return (<div className="flex flex-col gap-2">- <div>- <LemonSegmentedButton- value={method}- onChange={setMethod}- options={[- { value: 'llm_judge', label: 'LLM judge', disabledReason: judgeDisabledReason },- { value: 'decision', label: 'Decision model', disabledReason: judgeDisabledReason },- { value: 'hog', label: 'Code' },- {- value: 'sentiment',- label: 'Sentiment',- disabledReason:- !isNewEvaluation && ['numeric', 'categorical'].includes(evaluation.output_type)- ? 'Create a new evaluation to change what it returns.'- : undefined,- },- ]}- data-attr="llma-evaluation-create-method"- />- </div>- <p className="mb-0 text-sm text-secondary">{METHOD_HINTS[method]}</p>+ <h4 className="mb-0 text-sm font-semibold">How it decides</h4>+ <EvaluationChoiceCards<Method>+ label="How it decides"+ value={method}+ onChange={setMethod}+ dataAttr="llma-evaluation-create-method"+ options={[+ {+ value: 'llm_judge',+ label: 'LLM judge',+ description: 'An AI model grades each run against your prompt and says why.',+ icon: <IconSparkles />,+ disabledReason: judgeDisabledReason,+ },+ {+ value: 'decision',+ label: 'Decision model',+ description:+ 'Answers your prompt with a probability and no explanation, faster and cheaper than an LLM judge.',+ icon: <IconBolt />,+ disabledReason: judgeDisabledReason,+ },+ {+ value: 'hog',+ label: 'Code',+ description: 'Your Hog code decides each result. It makes no AI calls.',+ icon: <IconCode />,+ },+ {+ value: 'sentiment',+ label: 'Sentiment',+ description: "Rates the user's last message as positive, neutral, or negative. English only.",+ icon: <IconEmoji />,+ disabledReason:+ !isNewEvaluation && ['numeric', 'categorical'].includes(evaluation.output_type)+ ? 'Create a new evaluation to change what it returns.'+ : undefined,+ },+ ]}+ /></div>)}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationOutputFields.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationOutputFields.tsxindex 5f83f44d8683..07f4470a31ca 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationOutputFields.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationOutputFields.tsx@@ -1,22 +1,25 @@import { useActions, useValues } from 'kea'-import { LemonCheckbox, LemonInput, LemonSegmentedButton, LemonSelect } from '@posthog/lemon-ui'+import { IconList, IconListCheck, IconStar, IconThumbsUp } from '@posthog/icons'+import { LemonCheckbox, LemonInput, LemonSegmentedButton, LemonTag } from '@posthog/lemon-ui'import { DecisionThresholdInput } from '../components/DecisionThresholdInput'import { booleanOutputConfigError, decisionModelHint } from '../constants'import { llmEvaluationLogic } from '../llmEvaluationLogic'import { EvaluationCategoryEditor } from './EvaluationCategoryEditor'+import { EvaluationCategoryPassing } from './EvaluationCategoryPassing'+import { EvaluationChoiceCards } from './EvaluationChoiceCards'+import { EvaluationPassRatePreview } from './EvaluationPassRatePreview'import { EvaluationScoreOutput } from './EvaluationScoreOutput'type ReturnShape = 'boolean' | 'numeric' | 'categorical' | 'categorical_multiple'-/** What each run returns, read as one sentence, and which answers count as a pass. */export function EvaluationOutputFields(): JSX.Element | null {const { evaluation, originalEvaluation, numericBoundsRequired, usesDecisionModel, isNewEvaluation } =useValues(llmEvaluationLogic)const { setOutputType, patchOutputConfig, setAllowsNA, setTrueIsFailure } = useActions(llmEvaluationLogic)- // Sentiment always returns positive, neutral, or negative, which the method hint already says.+ // Sentiment always returns positive, neutral, or negative, which its method card already says.if (!evaluation || evaluation.evaluation_type === 'sentiment') {return null}@@ -35,6 +38,11 @@ export function EvaluationOutputFields(): JSX.Element | null {patchOutputConfig({ selection_mode: next === 'categorical_multiple' ? 'multiple' : 'single' })}}+ // Past results keep their type, so a saved evaluation can only switch between category modes.+ const lockedReason = (value: ReturnShape): string | undefined =>+ !isNewEvaluation && (value === 'categorical_multiple' ? 'categorical' : value) !== outputType+ ? 'Create a new evaluation to change what it returns.'+ : undefinedconst usesThreshold = evaluation.evaluation_type === 'llm_judge' && usesDecisionModel && outputType === 'boolean'const bound = (field: 'min' | 'max'): JSX.Element => (<LemonInput@@ -50,89 +58,128 @@ export function EvaluationOutputFields(): JSX.Element | null {)return (- <div className="flex flex-col gap-3">- <div className="flex flex-wrap items-center gap-2 text-sm">- <span className="font-semibold">Return</span>- <LemonSelect<ReturnShape>- size="small"- value={shape}- onChange={setShape}- options={(- [- { value: 'boolean', label: 'true or false' },- { value: 'numeric', label: 'a score' },- { value: 'categorical', label: 'one category' },- { value: 'categorical_multiple', label: 'several categories' },- ] as const- ).map((option) => ({- ...option,- // Past results keep their type, so a saved evaluation can only switch between category modes.- disabledReason:- !isNewEvaluation &&- (option.value === 'categorical_multiple' ? 'categorical' : option.value) !== outputType- ? 'Create a new evaluation to change what it returns.'- : undefined,- }))}- data-attr="llma-evaluation-output-type"- />- {outputType === 'boolean' && (- <>- <span>where true counts as a</span>- <LemonSegmentedButton- size="small"- value={config.true_is_failure ? 'fail' : 'pass'}- onChange={(value) => setTrueIsFailure(value === 'fail')}- options={[- { value: 'pass', label: 'Pass', 'data-attr': 'llma-evaluation-true-is-pass' },- { value: 'fail', label: 'Fail', 'data-attr': 'llma-evaluation-true-is-failure' },- ]}- />- </>+ <div className="flex flex-col gap-6">+ <EvaluationChoiceCards<ReturnShape>+ label="What it returns"+ value={shape}+ onChange={setShape}+ dataAttr="llma-evaluation-output-type"+ options={[+ {+ value: 'boolean',+ label: 'True or false',+ description: 'A yes or no, like whether the answer cites a source.',+ icon: <IconThumbsUp />,+ disabledReason: lockedReason('boolean'),+ },+ {+ value: 'numeric',+ label: 'Score',+ description: 'A number in a range you set, like 1 to 5.',+ icon: <IconStar />,+ disabledReason: lockedReason('numeric'),+ },+ {+ value: 'categorical',+ label: 'One category',+ description: 'One label from your list, like Resolved or Handed off.',+ icon: <IconList />,+ disabledReason: lockedReason('categorical'),+ },+ {+ value: 'categorical_multiple',+ label: 'Several categories',+ description: 'Every label from your list that fits the run.',+ icon: <IconListCheck />,+ disabledReason: lockedReason('categorical_multiple'),+ },+ ]}+ />+ <div className="flex flex-col gap-3 empty:hidden">+ {usesThreshold && (+ <div className="flex flex-col gap-1">+ <div className="flex flex-wrap items-center gap-2 text-sm">+ <span>It returns true when the probability is at least</span>+ <DecisionThresholdInput />+ </div>+ {booleanOutputConfigError(config) && (+ <span className="text-xs text-danger">{booleanOutputConfigError(config)}</span>+ )}+ </div>)}{outputType === 'numeric' && (- <>- <span>from</span>+ <div className="flex flex-wrap items-center gap-2 text-sm">+ <span>Scores go from</span>{bound('min')}<span>to</span>{bound('max')}- </>+ </div>+ )}+ {outputType === 'categorical' && (+ <EvaluationCategoryEditor+ config={config}+ onChange={patchOutputConfig}+ showKeys={evaluation.evaluation_type === 'hog'}+ storedKeys={+ isNewEvaluation+ ? []+ : (originalEvaluation?.output_config.options ?? []).map((option) => option.key)+ }+ />+ )}+ {usesDecisionModel && evaluation.evaluation_type === 'llm_judge' && (+ <p className="mb-0 text-xs text-secondary">{decisionModelHint(outputType)}</p>)}</div>- {usesThreshold && (- <div className="flex flex-col gap-1">- <div className="flex flex-wrap items-center gap-2 text-sm">- <span>Answer true when the probability is at least</span>- <DecisionThresholdInput />+ <div className="flex flex-col gap-0.5">+ <LemonCheckbox+ label={'Accept a "doesn\'t apply" answer'}+ checked={config.allows_na ?? false}+ onChange={setAllowsNA}+ data-attr="llma-evaluation-create-allows-na"+ />+ <span className="text-xs text-secondary pl-6">+ Runs it can't judge then count as neither a pass nor a fail.+ </span>+ </div>+ <div className="grid grid-cols-1 items-start gap-4 border-t pt-6 @min-[40rem]/evaluation:grid-cols-2">+ <div className="flex flex-col gap-3 min-w-0">+ <div className="flex flex-col gap-1">+ <h4 className="mb-0 flex items-center gap-2 text-sm font-semibold">+ Pass rate+ {outputType !== 'boolean' && (+ <LemonTag size="small" type="muted">+ Optional+ </LemonTag>+ )}+ </h4>+ <p className="mb-0 text-xs text-secondary">+ Choose which results pass. The results page charts the share of runs that pass, and reports+ tell you when it changes.+ </p></div>- {booleanOutputConfigError(config) && (- <span className="text-xs text-danger">{booleanOutputConfigError(config)}</span>+ {outputType === 'boolean' && (+ <div className="flex flex-wrap items-center gap-2 text-sm">+ <span>A run passes when it returns</span>+ <LemonSegmentedButton+ size="small"+ value={config.true_is_failure ? 'false' : 'true'}+ onChange={(value) => setTrueIsFailure(value === 'false')}+ options={[+ // pinned: data-attr values, because autocapture insights read them+ { value: 'true', label: 'true', 'data-attr': 'llma-evaluation-true-is-pass' },+ { value: 'false', label: 'false', 'data-attr': 'llma-evaluation-true-is-failure' },+ ]}+ />+ </div>+ )}+ {outputType === 'numeric' && <EvaluationScoreOutput config={config} onChange={patchOutputConfig} />}+ {outputType === 'categorical' && (+ <EvaluationCategoryPassing config={config} onChange={patchOutputConfig} />)}</div>- )}- {outputType === 'numeric' && <EvaluationScoreOutput config={config} onChange={patchOutputConfig} />}- {outputType === 'categorical' && (- <EvaluationCategoryEditor- config={config}- onChange={patchOutputConfig}- showKeys={evaluation.evaluation_type === 'hog'}- storedKeys={- isNewEvaluation- ? []- : (originalEvaluation?.output_config.options ?? []).map((option) => option.key)- }- />- )}- {usesDecisionModel && evaluation.evaluation_type === 'llm_judge' && (- <p className="mb-0 text-xs text-secondary">{decisionModelHint(outputType)}</p>- )}- <LemonCheckbox- label={`${- evaluation.evaluation_type === 'hog' ? 'The code' : 'The judge'- } can answer not applicable, when the check does not apply to a run`}- checked={config.allows_na ?? false}- onChange={setAllowsNA}- data-attr="llma-evaluation-create-allows-na"- />+ <EvaluationPassRatePreview outputType={outputType} config={config} />+ </div></div>)}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationPassRatePreview.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationPassRatePreview.tsxnew file mode 100644index 000000000000..29a381d81cdb--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/EvaluationPassRatePreview.tsx@@ -0,0 +1,68 @@+import { LemonTag } from '@posthog/lemon-ui'++import { LemonProgress } from 'lib/lemon-ui/LemonProgress'++import type { EvaluationOutputConfig, EvaluationOutputType } from '../types'+import { passRatePreview } from './passRatePreview'++export function EvaluationPassRatePreview({+ outputType,+ config,+}: {+ outputType: EvaluationOutputType+ config: EvaluationOutputConfig+}): JSX.Element {+ const runs = passRatePreview(outputType, config)+ const graded = runs.every((run) => run.passes !== null)+ const passed = runs.filter((run) => run.passes).length++ return (+ <div className="flex flex-col gap-1" aria-label="Example results">+ <span className="text-xs text-secondary">Example results</span>+ <div className="flex flex-col rounded border border-primary bg-surface-primary p-1">+ {runs.map((run, index) => (+ <div key={index} className="flex items-center gap-2 px-1.5 py-0.5 text-xs">+ <span className="w-10 shrink-0 text-secondary">{`Run ${index + 1}`}</span>+ {run.fill !== undefined && (+ // LemonProgress fills its parent, so this span sets its width.+ <span className="w-16 shrink-0">+ <LemonProgress+ percent={run.fill * 100}+ strokeColor={+ run.passes === null+ ? 'var(--border-bold)'+ : run.passes+ ? 'var(--success)'+ : 'var(--danger)'+ }+ />+ </span>+ )}+ <code className="min-w-0 flex-1 truncate">{run.value}</code>+ {run.passes !== null && (+ <LemonTag size="small" type={run.passes ? 'success' : 'danger'}>+ {run.passes ? 'Pass' : 'Fail'}+ </LemonTag>+ )}+ </div>+ ))}+ <div className="mt-1 border-t px-1.5 pt-1.5 pb-0.5 text-xs">+ {graded ? (+ <>+ {/* Each changing number sits in its own element, so page translation can't leave it stale. */}+ <span className="font-semibold">+ Pass rate <span>{`${Math.round((passed / runs.length) * 100)}%`}</span>+ </span>+ <span className="text-secondary">+ {' · '}+ <span>{`${passed} of ${runs.length} runs`}</span>+ </span>+ </>+ ) : (+ <span className="text-secondary">No pass rate. Each run records only what it returns.</span>+ )}+ </div>+ </div>+ </div>+ )+}diff --git a/products/ai_observability/frontend/evaluations/create/EvaluationScoreOutput.tsx b/products/ai_observability/frontend/evaluations/create/EvaluationScoreOutput.tsxindex 89f84fd92db6..0e6dd08ac4b1 100644--- a/products/ai_observability/frontend/evaluations/create/EvaluationScoreOutput.tsx+++ b/products/ai_observability/frontend/evaluations/create/EvaluationScoreOutput.tsx@@ -16,6 +16,13 @@ export function EvaluationScoreOutput({// The direction is kept here until a passing score exists, because a rule needs both.const [pendingOperator, setPendingOperator] = useState<'gte' | 'lte'>('gte')const operator = rule?.operator ?? pendingOperator+ const min = config.min ?? null+ const max = config.max ?? null+ const unreachable =+ !!rule &&+ min !== null &&+ max !== null &&+ (rule.operator === 'gte' ? rule.threshold > max : rule.threshold < min)return (<div className="flex flex-col gap-1"><div className="flex flex-wrap items-center gap-2 text-sm">@@ -50,9 +57,13 @@ export function EvaluationScoreOutput({data-attr="llma-evaluation-numeric-threshold"/></div>- <span className="text-xs text-secondary">- Leave the passing score empty to keep scores without a pass or fail. Pass rates and reports need one.- </span>+ {unreachable ? (+ <span className="text-xs text-warning">+ Scores go from {min} to {max}, so no run can pass this.+ </span>+ ) : (+ <span className="text-xs text-secondary">Leave it empty to record scores without a pass rate.</span>+ )}</div>)}diff --git a/products/ai_observability/frontend/evaluations/create/creationChecklist.test.ts b/products/ai_observability/frontend/evaluations/create/creationChecklist.test.tsindex c939d1fb193b..b94569197936 100644--- a/products/ai_observability/frontend/evaluations/create/creationChecklist.test.ts+++ b/products/ai_observability/frontend/evaluations/create/creationChecklist.test.ts@@ -51,8 +51,8 @@ describe('creationChecklist', () => {} as EvaluationConfigexpect(creationChecklist(input({ evaluation })).map((item) => item.summary)).toEqual(['Helpfulness',- 'Is it helpful?','Pass or fail',+ 'Is it helpful?','gpt-5-mini','100% of all generations',])diff --git a/products/ai_observability/frontend/evaluations/create/creationChecklist.ts b/products/ai_observability/frontend/evaluations/create/creationChecklist.tsindex 4d59a0424a56..7d7acead9bab 100644--- a/products/ai_observability/frontend/evaluations/create/creationChecklist.ts+++ b/products/ai_observability/frontend/evaluations/create/creationChecklist.ts@@ -45,6 +45,15 @@ export function creationChecklist(input: ChecklistInput): ChecklistItem[] {summary: evaluation.name.trim(),},]+ if (evaluation.evaluation_type !== 'sentiment') {+ items.push({+ key: 'result',+ label: 'Result',+ done: input.resultError === null,+ todo: input.resultError ?? '',+ summary: templateOutputText(evaluation),+ })+ }if (evaluation.evaluation_type === 'llm_judge' || evaluation.evaluation_type === 'hog') {const content =evaluation.evaluation_type === 'llm_judge'@@ -60,15 +69,6 @@ export function creationChecklist(input: ChecklistInput): ChecklistItem[] {...CRITERIA[evaluation.evaluation_type],})}- if (evaluation.evaluation_type !== 'sentiment') {- items.push({- key: 'result',- label: 'Result',- done: input.resultError === null,- todo: input.resultError ?? '',- summary: templateOutputText(evaluation),- })- }if (input.modelSelectionRequired) {items.push({key: 'model',diff --git a/products/ai_observability/frontend/evaluations/create/evaluationSummary.ts b/products/ai_observability/frontend/evaluations/create/evaluationSummary.tsindex 29b41d771b39..41d153ee1249 100644--- a/products/ai_observability/frontend/evaluations/create/evaluationSummary.ts+++ b/products/ai_observability/frontend/evaluations/create/evaluationSummary.ts@@ -60,10 +60,9 @@ export function reportsUnavailableReason(evaluation: EvaluationConfig, isReportaif (isReportable) {return null}- const instructions = evaluation.evaluation_type === 'hog' ? 'code' : 'prompt'return evaluation.output_type === 'numeric'- ? `Reports need a pass rate. Below the ${instructions}, set the score a run needs to pass.`+ ? 'Reports need a pass rate. In the Returns step, set the score a run needs to pass.': evaluation.output_type === 'categorical'- ? `Reports need a pass rate. Below the ${instructions}, pick which categories count as a pass.`+ ? 'Reports need a pass rate. In the Returns step, pick which categories count as a pass.': 'Reports are not available for this kind of evaluation.'}diff --git a/products/ai_observability/frontend/evaluations/create/passRatePreview.test.ts b/products/ai_observability/frontend/evaluations/create/passRatePreview.test.tsnew file mode 100644index 000000000000..18e2e49048e0--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/passRatePreview.test.ts@@ -0,0 +1,48 @@+import type { EvaluationOutputConfig, EvaluationOutputType } from '../types'+import { passRatePreview } from './passRatePreview'++describe('passRatePreview', () => {+ it.each<[string, EvaluationOutputType, EvaluationOutputConfig, (boolean | null)[]]>([+ ['true passes', 'boolean', {}, [true, true, false, true]],+ ['false passes', 'boolean', { true_is_failure: true }, [false, false, true, false]],+ [+ 'scores at least 3 pass',+ 'numeric',+ { min: 1, max: 5, passing_rule: { operator: 'gte', threshold: 3 } },+ [true, true, true, false],+ ],+ ['a score with no passing score is ungraded', 'numeric', { min: 1, max: 5 }, [null, null, null, null]],+ [+ 'only marked categories pass',+ 'categorical',+ {+ options: [+ { key: 'resolved', label: 'Resolved' },+ { key: 'unresolved', label: 'Unresolved' },+ ],+ passing_rule: { categories: ['resolved'] },+ },+ [true, false, true, true],+ ],+ ])('%s', (_name, outputType, config, expected) => {+ expect(passRatePreview(outputType, config).map((run) => run.passes)).toEqual(expected)+ })++ it.each<[string, EvaluationOutputConfig, string[]]>([+ [+ 'a fractional range keeps its decimals',+ { min: 0.1, max: 0.5 },+ ['0.5 / 0.5', '0.4 / 0.5', '0.3 / 0.5', '0.2 / 0.5'],+ ],+ [+ 'a range of thousandths',+ { min: 0.001, max: 0.005 },+ ['0.005 / 0.005', '0.004 / 0.005', '0.003 / 0.005', '0.002 / 0.005'],+ ],+ ['a range with only a lowest score', { min: 10 }, ['14 / 14', '13 / 14', '12 / 14', '11 / 14']],+ ])('example scores stay inside %s', (_name, config, expected) => {+ const runs = passRatePreview('numeric', config)+ expect(runs.map((run) => run.value)).toEqual(expected)+ expect(runs.every((run) => run.fill !== undefined && run.fill >= 0 && run.fill <= 1)).toBe(true)+ })+})diff --git a/products/ai_observability/frontend/evaluations/create/passRatePreview.ts b/products/ai_observability/frontend/evaluations/create/passRatePreview.tsnew file mode 100644index 000000000000..589741a77196--- /dev/null+++ b/products/ai_observability/frontend/evaluations/create/passRatePreview.ts@@ -0,0 +1,67 @@+import type { EvaluationOutputConfig, EvaluationOutputType } from '../types'++export interface PreviewRun {+ value: string+ /** Null when there is no passing rule, so the run only records its value. */+ passes: boolean | null+ /** Where a score sits in its range, from 0 to 1. Only scores have one. */+ fill?: number+}++const SCORE_POSITIONS = [1, 0.75, 0.5, 0.25]+const DEFAULT_SCORE_SPAN = 4++/** The configured score range, filling a missing end so a one-sided or empty range still gives sensible examples. */+function scoreRange(config: EvaluationOutputConfig): [number, number] {+ const min = config.min ?? null+ const max = config.max ?? null+ if (min !== null && max !== null) {+ return [min, max]+ }+ if (min !== null) {+ return [min, min + DEFAULT_SCORE_SPAN]+ }+ if (max !== null) {+ return [max - DEFAULT_SCORE_SPAN, max]+ }+ return [1, 1 + DEFAULT_SCORE_SPAN]+}++/** Four made-up runs graded by the current passing rule, to show what the rule does before any real result exists. */+export function passRatePreview(outputType: EvaluationOutputType, config: EvaluationOutputConfig): PreviewRun[] {+ const rule = config.passing_rule ?? null+ if (outputType === 'boolean') {+ return [true, true, false, true].map((value) => ({+ value: String(value),+ passes: value !== !!config.true_is_failure,+ }))+ }+ if (outputType === 'numeric') {+ const [min, max] = scoreRange(config)+ // Whole-number ranges get whole-number examples. A fractional range keeps three significant digits, which+ // holds for any scale, and the clamp keeps rounding from stepping outside the range.+ const whole = Number.isInteger(min) && Number.isInteger(max)+ const threshold = rule && 'threshold' in rule ? rule : null+ return SCORE_POSITIONS.map((position) => {+ const exact = min + position * (max - min)+ const rounded = whole ? Math.round(exact) : Number(exact.toPrecision(3))+ const score = Math.min(max, Math.max(min, rounded))+ return {+ value: `${score} / ${max}`,+ fill: max > min ? (score - min) / (max - min) : 1,+ passes: threshold+ ? threshold.operator === 'gte'+ ? score >= threshold.threshold+ : score <= threshold.threshold+ : null,+ }+ })+ }+ const named = (config.options ?? []).filter((option) => option.key)+ const options = named.length > 0 ? named : [{ key: '', label: 'Category' }]+ const categories = rule && 'categories' in rule ? rule.categories : null+ return [0, 1, 0, 2].map((index) => {+ const option = options[index % options.length]+ return { value: option.label, passes: categories ? categories.includes(option.key) : null }+ })+}diff --git a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.tsindex 955b7be8e340..d48ac3368473 100644--- a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts+++ b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.ts@@ -547,7 +547,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([actions.requestEstimate()}} catch (error) {- const message = backfillErrorMessage(error, 'Couldn’t load backfills. Try again.')+ const message = backfillErrorMessage(error, "Couldn't load backfills. Try again.")actions.loadBackfillsFailure(message)if (!background) {// A poll fails on its own in the background, where the inline error is enough.@@ -608,7 +608,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([} catch (error) {breakpoint()// No toast: the count reruns on every edit, and `estimateError` shows inline.- actions.requestEstimateFailure(backfillErrorMessage(error, 'Couldn’t count this range. Try again.'))+ actions.requestEstimateFailure(backfillErrorMessage(error, "Couldn't count this range. Try again."))}},createBackfill: async () => {@@ -634,7 +634,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([lemonToast.success('Backfill started', { autoClose: 15000 })actions.loadBackfills()} catch (error) {- lemonToast.error(backfillErrorMessage(error, 'Couldn’t start the backfill. Try again.'))+ lemonToast.error(backfillErrorMessage(error, "Couldn't start the backfill. Try again."))// A concurrent backfill can be the cause (only one may run at a time), so refresh// the table to show it.actions.loadBackfills(true)@@ -650,7 +650,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([actions.loadBackfills(true)}} catch (error) {- lemonToast.error(backfillErrorMessage(error, 'Couldn’t cancel the backfill. Try again.'))+ lemonToast.error(backfillErrorMessage(error, "Couldn't cancel the backfill. Try again."))} finally {actions.transitionBackfillDone(id)}@@ -689,7 +689,7 @@ export const evaluationBackfillsLogic = kea<evaluationBackfillsLogicType>([cache.recountWhenIdle = truelemonToast.success('Retry started. Existing results will be kept.')} catch (error) {- lemonToast.error(backfillErrorMessage(error, 'Couldn’t retry this backfill. Try again.'))+ lemonToast.error(backfillErrorMessage(error, "Couldn't retry this backfill. Try again."))} finally {cache.retryingBackfill = falseactions.transitionBackfillDone(id)diff --git a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.tsindex e456266aafab..9ce846cb8961 100644--- a/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts+++ b/products/ai_observability/frontend/evaluations/llmEvaluationLogic.ts@@ -1577,7 +1577,7 @@ export const llmEvaluationLogic = kea<llmEvaluationLogicType>([lemonToast.error(evaluationErrorMessage(error,- enabled ? 'Couldn’t turn on this evaluation.' : 'Couldn’t pause this evaluation.'+ enabled ? "Couldn't turn on this evaluation." : "Couldn't pause this evaluation."))actions.saveEnabledFailure()