[AI Gateway] Surface ZDR on AI model catalog#31309
Conversation
Threads the Zero Data Retention flag from the catalog API through
the docs site so /ai/models cards display a Zero data retention
badge when a model supports it. The catalog JSON files on disk
already carry zdr and zdr_comment (the API returns them natively),
but the zod schema was silently dropping both fields at content-
collection load time.
Changes:
- src/schemas/catalog-models.ts: declare optional zdr and
zdr_comment so Astro stops stripping them at load time
- src/util/model-resolver.ts: in catalogToResolved, push
{ property_id: 'zdr', value: 'true' } when model.zdr === true
and surface zdr_comment as zdrComment on the resolved model
- src/util/model-properties.ts: register zdr in
CAPABILITY_PROPERTIES with the model category (gray default
variant) so ModelBadges, the sidebar filters, and the badge
list pick it up automatically
- src/components/models/ModelBadges.tsx: read zdrComment off the
model when present and attach it as the HTML title attribute on
the ZDR badge span — tooltip on hover when the catalog row
carries a comment, bare badge otherwise. Preserves the existing
providerBadge (Cloudflare-hosted vs Third-party) row.
- src/util/model-types.ts: extend ResolvedModel and ModelCardData
with optional zdrComment so the resolver -> card -> badge data
flow is type-safe end-to-end
- bin/fetch-catalog-models.ts: declare zdr and zdr_comment on the
local CatalogModel interface so future refreshes keep round-trip
type safety with the upstream API
Backwards-compatible: older catalog rows without zdr are treated
the same as zdr=false (badge stays hidden). Legacy Workers AI
models never set zdrComment so their badge rendering is unchanged.
Ref: https://jira.cfdata.org/browse/AIG-1205
Review✅ No style-guide issues found in commit CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
There was a problem hiding this comment.
Pull request overview
This PR threads the catalog API’s Zero Data Retention (ZDR) fields (zdr, zdr_comment) through the docs site’s model pipeline so /ai/models can display a “Zero data retention” badge, optionally with a tooltip sourced from zdr_comment. This fits into the existing model catalog ingestion/resolution flow (Astro content collections → resolved models → card data → React badges/filters).
Changes:
- Extend the catalog Zod schema to retain
zdr/zdr_commentduring content collection loading. - Surface ZDR as a boolean capability property (
property_id: "zdr") and propagatezdr_commentaszdrCommentthroughResolvedModel→ModelCardData. - Update
ModelBadgesto attachzdrCommentas an HTMLtitletooltip on the ZDR badge when present.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/schemas/catalog-models.ts |
Adds optional zdr and zdr_comment to the catalog schema so Astro doesn’t strip them. |
src/util/model-resolver.ts |
Converts zdr into a "zdr" capability property and carries zdr_comment through as zdrComment into card data. |
src/util/model-properties.ts |
Registers zdr in CAPABILITY_PROPERTIES so badge/filter logic can pick it up. |
src/components/models/ModelBadges.tsx |
Adds optional title support on badges and applies it to the ZDR badge using zdrComment. |
src/util/model-types.ts |
Adds optional zdrComment to ResolvedModel and ModelCardData for end-to-end type safety. |
bin/fetch-catalog-models.ts |
Updates the local CatalogModel interface to include optional zdr / zdr_comment for type-safe refreshes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No issues found. |
|
Verdict: No issues found. Code changes are clean and ready to merge. Labels applied: What this PR changes:
Issues flagged: None. The type changes are consistent, the merge integration with the existing |
|
Preview URL: https://b7e1034c.preview.developers.cloudflare.com |
Ref: https://jira.cfdata.org/browse/AIG-1205
Threads the Zero Data Retention flag from the catalog API through the docs site so
/ai/modelscards display a "Zero data retention" badge when a model supports it. The catalog JSON files on disk already carryzdrandzdr_comment(the API returns them natively), but the zod schema was silently dropping both fields at content-collection load time.Changes
src/schemas/catalog-models.ts— declare optionalzdrandzdr_commentso Astro stops stripping them at content-collection load time.src/util/model-resolver.ts— incatalogToResolved, push{ property_id: "zdr", value: "true" }whenmodel.zdr === true, and surfacezdr_commentaszdrCommenton the resolved model. Also propagated throughtoModelCardDataso the slimmed card data carries it.src/util/model-properties.ts— registerzdrinCAPABILITY_PROPERTIESwith themodelcategory (graydefaultvariant) soModelBadges, the sidebar filters, and the badge list pick it up automatically alongside Function calling / Reasoning / Vision.src/components/models/ModelBadges.tsx— readzdrCommentoff the model when present and attach it as the HTMLtitleattribute on the ZDR badge span (tooltip on hover when the catalog row carries a comment, bare badge otherwise). Preserves the existingproviderBadgerow introduced after the original work was prepared.src/util/model-types.ts— extendResolvedModelandModelCardDatawith optionalzdrCommentso the resolver → card → badge data flow is type-safe end-to-end.bin/fetch-catalog-models.ts— declarezdrandzdr_commenton the localCatalogModelinterface so future refreshes keep round-trip type safety with the upstream API.Backwards compatibility
Older catalog rows that omit
zdrentirely are treated the same aszdr: false— the badge stays hidden. Legacy Workers AI models never setzdrComment, so their badge rendering is unchanged.Validation (run locally on the prior worktree before the canonical clone was migrated to this repo)
pnpm run sync✓ — Astro types regenerated for the schema additionspnpm run check✓ — 362 files, 0 errors, 0 warningspnpm run lint✓pnpm run format:core:check✓ — "All matched files use Prettier code style"pnpm run test✓ — 40 passing across the Node + Astro suites; one pre-existingworker/index.worker.test.tsfailure on theproductionbranch is unrelated to this PR (reproduces with no changes).The
ModelBadges.tsxmerge that combines the newproviderBadgeblock with the ZDR tooltip wiring was prepared by diffing the worktree version against the latestproductionand folding both into a single file. Both branches are preserved; theBadgetype was lifted out so it can carry the optionaltitlefield without union noise at the JSX site.