feat: catalog model detail pages with examples, schema tables, and UI#29202
Open
superhighfives wants to merge 12 commits intocloudflare:productionfrom
Open
feat: catalog model detail pages with examples, schema tables, and UI#29202superhighfives wants to merge 12 commits intocloudflare:productionfrom
superhighfives wants to merge 12 commits intocloudflare:productionfrom
Conversation
Add infrastructure to auto-generate Workers AI model documentation from the unified catalog API, running alongside the existing legacy system. - New catalog-models content collection with schema matching unified catalog - Fetch script supporting both API fetch and local JSON import - Model resolver that merges catalog and legacy sources (catalog wins) - Updated [name].astro to display catalog-specific content (code snippets, examples) - New CodeSnippets.astro component for rendering code examples - Graceful handling of models without JSON schemas - Fixed author extraction for both @cf/author/model and author/model formats - Split into model-types.ts, model-helpers.ts, model-resolver.ts for server/client boundary
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- add [...name].astro page using resolver for both catalog and legacy models - add ExampleCard component with side-by-side code tabs + output image - add 97 redirects for old model slug -> full model ID migration - use full model ID as slug (preserves @cf/@hf prefix) - remove getModelSlug (identity function) - remove dead exports from resolver - fix zod schema: astro/zod import, record key types, code_snippets on examples - fix division by zero, null checks, description whitespace - trim name/description in fetch script - add TODO.md for staging URL and pricing unit edge cases
- rewrite fetch script to list model IDs then fetch individual details - add CF_API_BASE_URL env var for staging/production switching - add concurrency control (5 parallel requests) - fix SchemaRow crash: optional chain on node.annotations and node.validations
…e image, 200 badge
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “catalog model” data source (local JSON synced from an external catalog API) and updates the Workers AI model listing/detail pages to render richer, catalog-specific UI (examples + schema tables), while keeping legacy models working via a unified ResolvedModel type.
Changes:
- Introduces
catalog-modelscontent collection + Zod schema, plus resolver utilities to merge catalog + legacy into a unifiedResolvedModel[]. - Updates
/workers-ai/modelslisting and[...name]detail pages to use resolved models and render new catalog UI (ExampleCard,CatalogSchemaTable). - Adds scripts for syncing/comparing catalog models locally and adds redirects for the new model URL scheme.
Reviewed changes
Copilot reviewed 21 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/model-types.ts | Adds unified ResolvedModel type used across catalog + legacy models |
| src/util/model-resolver.ts | Resolves/merges catalog + legacy models; normalizes pricing units |
| src/util/model-helpers.ts | Adds client-safe helper for extracting model author/provider |
| src/schemas/index.ts | Re-exports new catalog schema module |
| src/schemas/catalog-models.ts | Adds Zod schema/types for catalog model JSON |
| src/content.config.ts | Adds catalog-models content collection |
| src/pages/workers-ai/models/index.astro | Switches model list page to use getResolvedModels() |
| src/pages/workers-ai/models/[...name].astro | Adds catalog branching for Usage/Examples/Parameters rendering |
| src/components/ModelCatalog.tsx | Allows listing to accept ResolvedModel and updates model links/authors |
| src/components/models/ModelInfo.tsx | Updates author derivation to support both ID formats |
| src/components/models/ModelFeatures.tsx | Allows rendering with ResolvedModel union type |
| src/components/models/ModelBadges.tsx | Allows rendering with ResolvedModel union type |
| src/components/models/SchemaRow.astro | Makes schema annotations/validations access null-safe |
| src/components/models/SchemaParamName.astro | Adds nested parameter name indentation + array/object suffixes |
| src/components/models/CatalogSchemaTable.astro | New schema table renderer with nested property flattening |
| src/components/models/ExampleCard.astro | New example UI with stacked/side-by-side layouts and sticky response image |
| src/components/models/CodeSnippets.astro | Adds snippet tab renderer (currently not referenced) |
| src/content/catalog-models/google-nano-banana.json | Adds example catalog model JSON (with examples + schema) |
| src/content/catalog-models/flux-2-klein-9b.json | Adds example catalog model JSON |
| src/content/catalog-models/black-forest-labs-flux-2-klein-9b.json | Adds another catalog model JSON (appears duplicative) |
| src/content/catalog-models/.gitkeep | Ensures directory is tracked |
| public/__redirects | Adds redirects for legacy model slugs to full model IDs |
| bin/fetch-catalog-models.ts | Script to sync catalog models from API or file export |
| bin/compare-model-sources.ts | Script to compare legacy vs catalog coverage/migration progress |
Comments suppressed due to low confidence (1)
src/pages/workers-ai/models/[...name].astro:66
- The catalog Usage detection only checks
firstExample.code_snippets, butResolvedModelalso exposes top-levelcodeSnippets(frommodel.code_snippets) and that field is currently unused. If the catalog API returns snippets at the model level (or the first example lacks snippets), the page will render no Usage section even though snippets exist. Consider treatingmodel.codeSnippetsas a fallback forhasCatalogUsageand passing it intoExampleCardviafallbackSnippets.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ncKey, remove dead code and duplicate model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds fully-featured model detail pages for catalog models (models sourced from an external catalog API rather than the Workers AI registry), with rich UI for examples and parameter schemas.
CatalogSchemaTablecomponent renders input/output parameter tables (Name / Type / Default / Description) with nested property support, required badges, and array/object suffixesExampleCardcomponent withstackandside-by-sidelayouts — Usage section stacks vertically, Examples show code + response image side by side; response image is sticky so it stays in view while scrolling tall code blocks[...name].astrobranches ondataSource— catalog models use the new components, legacy models fall back to existingSchemaViewermodel-resolver.tsconverts catalog model JSON to the sharedResolvedModeltype;normalizePricingUnithandles keys withoutper_prefix correctlydefault_examplemarked nullable in the Zod schema to match API realitybin/fetch-catalog-models.tsscript for syncing catalog model JSON locally