Skip to content

automation script to pull models.yml#9635

Merged
Light2Dark merged 9 commits into
mainfrom
sham/automate-models-yml-scrape
May 29, 2026
Merged

automation script to pull models.yml#9635
Light2Dark merged 9 commits into
mainfrom
sham/automate-models-yml-scrape

Conversation

@Light2Dark

@Light2Dark Light2Dark commented May 21, 2026

Copy link
Copy Markdown
Member

📝 Summary

image
  • Models.yml is used to populate our models list. We manually updated this. This PR introduces a script to automate, although not perfect.
  • Add automation script that needs to be run manually to pull latest models data. By default pulls latest 10 models from each provider. We can pass params to control this.
  • Enriched the models data with more info (cost, capabilities)
  • Ive changed the data structure of models.yml to be more readable and collapsible by provider. Else, we could have duplicates under the previous model. Models are grouped under provider and sorted by release date.
  • Adds a skill to write descriptions.

Pulling this data from https://models.dev. It has an open-source API. Considered openrouter as well, but it has a slightly different structure. Anyway, easy to changeover if needed.

Some models don't exist on the API, maybe we can cross-check. I've removed them manually for now (eg. gpt-5.5-codex-spark)

We could put this into a github actions workflow in the future.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 28, 2026 8:38am

Request Review

@cubic-dev-ai

cubic-dev-ai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR is large and would use a significant portion of your monthly review quota. Comment @cubic-dev-ai review this to confirm that you want cubic to review it.

@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 17.01kB (0.07%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 25.28MB 17.01kB (0.07%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/JsonOutput-*.js -2.22kB 554.42kB -0.4%
assets/index-*.js -105 bytes 431.27kB -0.02%
assets/index-*.css 708 bytes 367.61kB 0.19%
assets/edit-*.js -35 bytes 325.13kB -0.01%
assets/ai-*.js 14.66kB 271.93kB 5.7% ⚠️
assets/reveal-*.js -33 bytes 249.55kB -0.01%
assets/add-*.js 268 bytes 202.26kB 0.13%
assets/layout-*.js -35 bytes 198.7kB -0.02%
assets/file-*.js -36 bytes 47.0kB -0.08%
assets/input-*.js 126 bytes 60.6kB 0.21%
assets/dates-*.js 338 bytes 38.67kB 0.88%
assets/chat-*.js 32 bytes 15.26kB 0.21%
assets/chat-*.js 563 bytes 15.22kB 3.84%
assets/useNotebookActions-*.js -35 bytes 29.95kB -0.12%
assets/MarimoErrorOutput-*.js 2.9kB 26.64kB 12.22% ⚠️
assets/react-*.browser.esm-CV8-hvjx.js (New) 25.64kB 25.64kB 100.0% 🚀
assets/session-*.js 1 bytes 25.04kB 0.0%
assets/vega-*.browser-C8wT63Va.js (New) 24.8kB 24.8kB 100.0% 🚀
assets/command-*.js 3 bytes 18.34kB 0.02%
assets/download-*.js 374 bytes 9.85kB 3.95%
assets/useCellActionButton-*.js -35 bytes 9.45kB -0.37%
assets/react-*.esm-BNzu6e7h.js (New) 8.37kB 8.37kB 100.0% 🚀
assets/readonly-*.js 1 bytes 4.68kB 0.02%
assets/emotion-*.esm-C59xfSYt.js (New) 4.37kB 4.37kB 100.0% 🚀
assets/mermaid-*.core-CMygPhv_.js (New) 2.38kB 2.38kB 100.0% 🚀
assets/react-*.browser.esm-Ce2ksurd.js (Deleted) -25.64kB 0 bytes -100.0% 🗑️
assets/vega-*.browser-xq8miGHn.js (Deleted) -24.8kB 0 bytes -100.0% 🗑️
assets/react-*.esm--O4lBTlZ.js (Deleted) -8.37kB 0 bytes -100.0% 🗑️
assets/emotion-*.esm-Dangy3Bv.js (Deleted) -4.37kB 0 bytes -100.0% 🗑️
assets/mermaid-*.core-867JpRcd.js (Deleted) -2.38kB 0 bytes -100.0% 🗑️
assets/eye-*.js (Deleted) -430 bytes 0 bytes -100.0% 🗑️

Files in assets/ai-*.js:

  • ./src/components/ai/ai-model-dropdown.tsx → Total Size: 17.95kB

  • ./src/core/ai/model-registry.ts → Total Size: 4.9kB

  • ./src/components/app-config/ai-config.tsx → Total Size: 76.68kB

@cubic-dev-ai

cubic-dev-ai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR is large and would use a significant portion of your monthly review quota. Comment @cubic-dev-ai review this to confirm that you want cubic to review it.

@cubic-dev-ai

cubic-dev-ai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR is large and would use a significant portion of your monthly review quota. Comment @cubic-dev-ai review this to confirm that you want cubic to review it.

@Light2Dark Light2Dark requested a review from mscolnick May 21, 2026 02:19
@Light2Dark Light2Dark marked this pull request as ready for review May 21, 2026 02:25
Copilot AI review requested due to automatic review settings May 21, 2026 02:25
@Light2Dark Light2Dark requested a review from manzt May 21, 2026 02:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a manual sync workflow for packages/llm-info/data/models.yml from the public models.dev catalog, restructures the model catalog to be provider-keyed, and updates codegen + frontend consumption to match the new schema (capabilities, modalities, pricing, release dates).

Changes:

  • Add a pnpm sync-models script + implementation to fetch models.dev/api.json and append/replace entries in models.yml while preserving curated entries/comments.
  • Change the llm-info model schema and data layout to a top-level provider map, enriching entries with capabilities, modalities, release dates, and cost.
  • Update codegen/tests and frontend model registry + UI “thinking” indicator to use the new structure.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/llm-info/src/sync-models.ts CLI entrypoint + YAML-preserving append/replace writer for models.yml.
packages/llm-info/src/cli.ts Parses sync-models CLI flags (mode, providers filter, per-provider cap).
packages/llm-info/src/sources/models-dev.ts Fetches/parses models.dev API response with Zod validation and warnings.
packages/llm-info/src/sources/merge.ts Merges models.dev data into local provider buckets with trimming/sorting.
packages/llm-info/src/index.ts Updates exported types (capabilities, modalities, provider-keyed structure).
packages/llm-info/src/generate.ts Updates codegen validation + JSON structure to provider-keyed models.
packages/llm-info/src/tests/sync-models.test.ts Adds comprehensive tests for merge + sync behavior and YAML formatting preservation.
packages/llm-info/src/tests/schema.test.ts Updates schema tests for new model entry shape + provider-keyed YAML.
packages/llm-info/src/tests/json-structure.test.ts Updates JSON shape expectations (models is a provider-keyed map).
packages/llm-info/data/models.yml Converts catalog to provider-keyed sections and adds enriched fields.
packages/llm-info/package.json Adds sync-models script.
packages/llm-info/README.md Documents pnpm sync-models usage examples.
packages/llm-info/skills/SKILL.md Adds a documented workflow for backfilling empty descriptions (Cursor skill).
.cursor/skills/fill-model-descriptions/SKILL.md Same skill doc mirrored under .cursor/skills.
frontend/src/core/ai/model-registry.ts Updates frontend registry to consume provider-keyed models + rehydrate dates + provider field.
frontend/src/core/ai/tests/model-registry.test.ts Updates mocks/expectations for provider-keyed models and provider-owned entries.
frontend/src/components/app-config/ai-config.tsx Switches “thinking” badge to capabilities.includes("thinking").
frontend/src/components/ai/ai-model-dropdown.tsx Switches “thinking” indicators to capabilities.includes("thinking").
frontend/src/components/ai/tests/ai-utils.test.ts Updates models.json mock to provider-keyed format + new fields.
Comment thread packages/llm-info/data/models.yml
Comment thread packages/llm-info/data/models.yml Outdated
Comment thread packages/llm-info/src/sources/merge.ts
Comment thread packages/llm-info/src/index.ts Outdated
Comment thread packages/llm-info/src/index.ts Outdated
Comment thread packages/llm-info/src/sync-models.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 issues found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/llm-info/src/cli.ts">

<violation number="1" location="packages/llm-info/src/cli.ts:35">
P2: `--mode replace` is ignored. Use `getFlag()` here so the spaced form does not fall back to append mode.</violation>

<violation number="2" location="packages/llm-info/src/cli.ts:73">
P1: Empty provider list should fail. In `--replace` mode, a typo can rewrite `models.yml` from an empty result set.</violation>
</file>

<file name="packages/llm-info/src/sync-models.ts">

<violation number="1" location="packages/llm-info/src/sync-models.ts:237">
P2: Cap is not per final provider. `google` can get trimmed entries from both `google` and `google-vertex`, so `-n 5` can still append 10 models. Trim after merging into one bucket.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant CLI as Sync Script (cli.ts)
    participant Sync as sync-models.ts
    participant Merge as sources/merge.ts
    participant ModelsDev as sources/models-dev.ts
    participant API as models.dev API
    participant YAML as data/models.yml
    participant Codegen as generate.ts
    participant JSON as data/generated/models.json
    participant Frontend as Frontend Components
    participant Registry as model-registry.ts

    Note over CLI,Registry: Model Sync and Consumption Flow

    CLI->>Sync: pnpm sync-models [--replace] [-n 10] [-p openai,google]
    Sync->>ModelsDev: fetchModelsDev()
    ModelsDev->>API: GET https://models.dev/api.json
    API-->>ModelsDev: JSON response
    ModelsDev->>ModelsDev: parseModelsDev() – validate with Zod schema
    ModelsDev-->>Sync: ModelsDevApi object

    Sync->>YAML: readFileSync(models.yml)
    YAML-->>Sync: YAML text
    Sync->>Sync: parseExistingModels() – extract provider-model pairs

    Sync->>Merge: mergeModels(existing, modelsDev, options)
    Merge->>Merge: For each provider in PROVIDER_MAP:
    Merge->>Merge:   - Build AiModel entries from API data
    Merge->>Merge:   - Derive roles, capabilities, cost, modalities
    Merge->>Merge:   - Sort newest-first, cap at maxPerProvider
    Merge->>Merge:   - Skip models that already exist locally
    Merge-->>Sync: MergeSummary (newEntries, preservedCount)

    alt mode === "append"
        Sync->>Sync: appendIntoDocument() – append new entries to existing YAML
    else mode === "replace"
        Sync->>Sync: renderFresh() – generate entirely new YAML
    end

    Sync->>YAML: writeFileSync(models.yml)

    Note over Codegen: Codegen runs separately
    Codegen->>YAML: readFileSync + parse
    Codegen->>Codegen: Validate with ModelsByProviderSchema
    Codegen->>JSON: writeFileSync(models.json)

    Note over Frontend: Runtime consumption
    Frontend->>JSON: import models.json
    JSON-->>Frontend: { models: { providerId: AiModel[] } }
    Frontend->>Registry: getKnownModelMaps()
    Registry->>Registry: Flatten per-provider arrays into single Map
    Registry->>Registry: Each model gets its own provider field
    Registry-->>Frontend: QualifiedModelId → AiModel

    alt User opens model dropdown
        Frontend->>Registry: getModelsByProvider(provider)
        Registry-->>Frontend: AiModel[]
        Frontend->>Frontend: Check model.capabilities.includes("thinking")
    end

    Note over Registry: Key schema changes
    Note over Registry: providers: string[] → provider: string (single)
    Note over Registry: thinking: boolean → capabilities: string[]
    Note over Registry: New fields: input_types, output_types, release_date, cost
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/llm-info/src/cli.ts
Comment thread packages/llm-info/src/sync-models.ts Outdated
Comment thread packages/llm-info/src/index.ts Outdated
Comment thread packages/llm-info/src/cli.ts Outdated
Comment thread packages/llm-info/src/sync-models.ts
Comment thread frontend/src/core/ai/model-registry.ts Outdated
Comment thread packages/llm-info/src/sources/merge.ts Outdated
Comment thread packages/llm-info/src/sources/merge.ts Outdated
Comment thread packages/llm-info/data/models.yml

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 9 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/llm-info/src/sync-models.ts">

<violation number="1" location="packages/llm-info/src/sync-models.ts:237">
P2: Cap is not per final provider. `google` can get trimmed entries from both `google` and `google-vertex`, so `-n 5` can still append 10 models. Trim after merging into one bucket.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/llm-info/src/sources/merge.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/llm-info/src/sources/merge.ts
@Light2Dark Light2Dark force-pushed the sham/automate-models-yml-scrape branch from b199bb0 to 21e909d Compare May 25, 2026 06:57
## 📝 Summary

<!--
If this PR closes any issues, list them here by number (e.g., Closes
#123).

Detail the specific changes made in this pull request. Explain the
problem addressed and how it was resolved. If applicable, provide before
and after comparisons, screenshots, or any relevant details to help
reviewers understand the changes easily.
-->
Closes #

## 📋 Pre-Review Checklist
<!-- These checks need to be completed before a PR is reviewed -->

- [ ] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [ ] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [ ] Video or media evidence is provided for any visual changes
(optional). <!-- PR is more likely to be merged if evidence is provided
for changes made -->

## ✅ Merge Checklist

- [ ] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [ ] Documentation has been updated where applicable, including
docstrings for API changes.
- [ ] Tests have been added for the changes made.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Light2Dark Light2Dark marked this pull request as ready for review May 28, 2026 08:38

export type ModelsDevApi = Record<string, ModelsDevProvider>;

const DEFAULT_URL = "https://models.dev/api.json";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most providers have their own urls which might have most up to date info. It might be worth it just maintain those urls instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also how much work would it be to fetch this live? i.e instead of reading from models.json, make this query

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it doesn't have the full information we need like cost and capability. Different providers give a different structure. So, this is more unified.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirangadhave kirangadhave left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 This is good. Should we have a job that run this periodically and opens a PR? Say weekly or monthly?

@Light2Dark

Copy link
Copy Markdown
Member Author

🚀 This is good. Should we have a job that run this periodically and opens a PR? Say weekly or monthly?

Yeah, I can follow-up on that. Thanks!

@Light2Dark Light2Dark merged commit 9a9c8cc into main May 29, 2026
33 checks passed
@Light2Dark Light2Dark deleted the sham/automate-models-yml-scrape branch May 29, 2026 04:35
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.9-dev22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants