Spaces:
Running
Running
Resolve merged benchmarks in the eval OG-image route
Browse filesMerged all-sources pages (single-segment ids, spec F2) live in
merged_evals_view, so getEvalSummaryById returned nothing and the card
fell back to the generic "Benchmark" frame while the page's text
metadata resolved fine. Branch on isMergedEvalId exactly like
app/evals/[...id]/layout.tsx and surface display_name, models_count,
and the producer's best_result on the card.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
app/api/og/evals/[...id]/route.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import { ImageResponse } from "next/og"
|
| 2 |
|
| 3 |
import { OG_CONTENT_TYPE, OG_SIZE, ellipsize, resolveBrandLogoUrl } from "@/app/api/og/_shared"
|
| 4 |
-
import { getEvalSummaryById } from "@/lib/data-backend"
|
| 5 |
-
import { routeIdFromSegments } from "@/lib/utils"
|
| 6 |
|
| 7 |
export const runtime = "nodejs"
|
| 8 |
|
|
@@ -35,18 +35,30 @@ export async function GET(
|
|
| 35 |
let unit: string | null = null
|
| 36 |
|
| 37 |
try {
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
} catch {
|
| 52 |
// Fall through to the generic card.
|
|
|
|
| 1 |
import { ImageResponse } from "next/og"
|
| 2 |
|
| 3 |
import { OG_CONTENT_TYPE, OG_SIZE, ellipsize, resolveBrandLogoUrl } from "@/app/api/og/_shared"
|
| 4 |
+
import { getEvalSummaryById, getMergedBenchmarkSummary } from "@/lib/data-backend"
|
| 5 |
+
import { isMergedEvalId, routeIdFromSegments } from "@/lib/utils"
|
| 6 |
|
| 7 |
export const runtime = "nodejs"
|
| 8 |
|
|
|
|
| 35 |
let unit: string | null = null
|
| 36 |
|
| 37 |
try {
|
| 38 |
+
// Single-segment ids are merged all-sources benchmark pages (spec
|
| 39 |
+
// F2); their identity lives in merged_evals_view, not evals_view.
|
| 40 |
+
// Mirrors the branch in app/evals/[...id]/layout.tsx.
|
| 41 |
+
const merged = isMergedEvalId(evalId) ? await getMergedBenchmarkSummary(evalId) : null
|
| 42 |
+
if (merged) {
|
| 43 |
+
evalName = merged.display_name
|
| 44 |
+
modelsCount = merged.models_count ?? null
|
| 45 |
+
topModelName = merged.best_result?.model_name ?? null
|
| 46 |
+
topScore = merged.best_result?.score_canonical ?? merged.best_result?.score ?? null
|
| 47 |
+
unit = merged.preferred_metric_display_name ?? null
|
| 48 |
+
} else {
|
| 49 |
+
const summary = await getEvalSummaryById(evalId)
|
| 50 |
+
if (summary) {
|
| 51 |
+
evalName =
|
| 52 |
+
summary.canonical_display_name ??
|
| 53 |
+
summary.evaluation_name ??
|
| 54 |
+
summary.composite_display_name ??
|
| 55 |
+
evalName
|
| 56 |
+
category = summary.derived_tags?.[0] ?? null
|
| 57 |
+
modelsCount = summary.models_count ?? null
|
| 58 |
+
topModelName = summary.best_model?.name ?? null
|
| 59 |
+
topScore = summary.best_model?.score ?? null
|
| 60 |
+
unit = summary.metric_config?.unit ?? null
|
| 61 |
+
}
|
| 62 |
}
|
| 63 |
} catch {
|
| 64 |
// Fall through to the generic card.
|