Skip to content

Use personal model table for catalog refreshes - #106

Merged
maiphucgiang merged 1 commit into
mainfrom
feature/personal-models-endpoint
Oct 29, 2026
Merged

maiphucgiang merged 1 commit into
mainfrom
feature/personal-models-endpoint

Conversation

@maiphucgiang

@maiphucgiang maiphucgiang commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Use the richer /v2/enterprises/personal/models table for personal-account catalog refreshes, preserving credits, context-window and media metadata in the existing picker/root cache.
  • Keep enterprise accounts on /v3/config, and fall back to the established catalog route for older deployments that do not expose the personal endpoint.
  • Add preview simulation, catalog regression coverage and English/Chinese model-catalog documentation.

Tests

  • for s in tests/test_*.py; do uv run python -B "$s"; done — passed.
  • Personal model table, catalog scope, preview, credits, catalog probe and region-routing regression files — passed.
  • git diff --check — passed.

Summary by Sourcery

Prefer the personal model catalog for personal-account refreshes while preserving compatibility with enterprise accounts and older deployments.

New Features:

  • Use the richer personal model endpoint for personal-account catalog refreshes, preserving expanded model metadata across picker and account catalogs.

Bug Fixes:

  • Fall back to the established catalog endpoint when personal model catalogs are unavailable on older deployments.

Enhancements:

  • Keep enterprise accounts on the existing enterprise catalog path and add preview support for the personal model endpoint.

Documentation:

  • Document personal catalog selection, enterprise behavior, fallback handling, and retained metadata in English and Chinese.

Tests:

  • Add regression coverage for personal catalog parsing, metadata preservation, endpoint fallback, enterprise routing, and preview responses.

- Fetch the richer /v2/enterprises/personal/models table for personal accounts, preserving credits, context-window and media metadata.
- Keep enterprise accounts on /v3/config and fall back for older deployments without the personal route.
- Add preview coverage, catalog regression tests and English/Chinese catalog documentation.

Tests:
- for s in tests/test_*.py; do uv run python -B "$s"; done
- git diff --check
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Sorry @maiphucgiang, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 29 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Personal catalog refreshes now prefer /v2/enterprises/personal/models for personal accounts to retain richer model metadata, while enterprise and older deployments continue using /v3/config; preview simulation, regression tests, and bilingual documentation cover the new routing and fallback behavior.

Sequence diagram for personal catalog refresh routing

sequenceDiagram
    participant Refresh as CatalogRefresh
    participant Fetch as fetch_model_scopes
    participant Personal as PersonalModelsAPI
    participant Config as ConfigAPI
    participant Cache as PickerAndRootCache

    Refresh->>Fetch: fetch_model_scopes(prefer_personal=True)
    alt personal account
        Fetch->>Personal: GET /v2/enterprises/personal/models
        alt endpoint available
            Personal-->>Fetch: picker and account catalog metadata
        else HTTP 404, 405, or 501
            Fetch->>Config: GET /v3/config
            Config-->>Fetch: picker and account catalog
        end
    else enterprise account
        Fetch->>Config: GET /v3/config
        Config-->>Fetch: picker and account catalog
    end
    Fetch->>Cache: cache models and serves
Loading

File-Level Changes

Change Details Files
Route personal-account catalog refreshes through the richer personal model endpoint while preserving the existing picker and account-root cache contract.
  • Added personal-endpoint constants, request headers, response parsing, and unavailable-endpoint handling.
  • Preserved rich credits, context-window, media, and related model metadata while deriving picker/account scopes.
  • Added an opt-in personal lookup path with fallback to /v3/config; enterprise accounts bypass the personal endpoint.
  • Enabled the new preference in converter catalog refreshes.
app/credits.py
converter.py
Extended preview behavior to simulate the personal model endpoint for non-enterprise accounts.
  • Registered the personal endpoint in the preview upstream router.
  • Returned catalog data with endpoint, merge strategy, and default video-model metadata.
  • Rejected enterprise requests to the personal route.
preview/upstream.py
Added regression coverage for endpoint selection, metadata preservation, fallback, account scoping, and preview availability.
  • Tested rich fields and required request headers on the personal endpoint.
  • Tested fallback to /v3/config for unavailable personal routes and enterprise bypass behavior.
  • Added an HTTP-level preview test for the personal model table.
tests/test_personal_models.py
tests/test_preview.py
Documented personal catalog routing and compatibility behavior in English and Chinese.
  • Explained personal endpoint preference, enterprise /v3/config behavior, and legacy fallback.
  • Documented continued picker/root caching and filtering semantics.
docs/advanced.md
docs/advanced.zh-CN.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@maiphucgiang
maiphucgiang merged commit e37936a into main Oct 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant