Skip to content

feat(modeldata): support model-list aliases in metadata lookup#175

Merged
SantiagoDePolonia merged 1 commit intomainfrom
chore/models-aliases
Mar 25, 2026
Merged

feat(modeldata): support model-list aliases in metadata lookup#175
SantiagoDePolonia merged 1 commit intomainfrom
chore/models-aliases

Conversation

@SantiagoDePolonia
Copy link
Copy Markdown
Contributor

@SantiagoDePolonia SantiagoDePolonia commented Mar 25, 2026

Summary

  • add support for models[*].aliases when resolving metadata from the external ai-model-list
  • accept upstream provider_model_id while keeping compatibility with legacy custom_model_id
  • keep /v1/models tied to upstream provider model IDs and use aliases only for internal metadata enrichment

Testing

  • go test ./internal/modeldata
  • go test ./internal/providers

Summary by CodeRabbit

  • New Features
    • Models now support aliases, including provider-qualified aliases (e.g., provider/model-name), for flexible model references.
    • Improved model resolution to correctly handle alias mapping and enrichment without creating duplicate synthetic models.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 65d5fc9e-08b5-47c4-b7ce-f2137b9e1b0a

📥 Commits

Reviewing files that changed from the base of the PR and between c966585 and 0db92d7.

📒 Files selected for processing (5)
  • internal/modeldata/fetcher_test.go
  • internal/modeldata/merger.go
  • internal/modeldata/merger_test.go
  • internal/modeldata/types.go
  • internal/providers/registry_test.go

📝 Walkthrough

Walkthrough

The pull request introduces alias resolution functionality for models by adding an Aliases field to ModelEntry, a new ProviderModelID field to ProviderModelEntry, and refactoring the Resolve function to handle alias-to-model lookups with candidate scoring. A reverse-index (aliasTargetsByID) is built during model list initialization to map aliases to their canonical models.

Changes

Cohort / File(s) Summary
Schema & Indexing
internal/modeldata/types.go
Added Aliases field to ModelEntry and ProviderModelID field to ProviderModelEntry. Introduced aliasTarget struct and aliasTargetsByID map to ModelList. Implemented buildReverseIndex() to populate alias-to-target mappings and compute provider "actual model id" via new ProviderModelEntry.actualModelID() method.
Resolution Logic Refactoring
internal/modeldata/merger.go
Refactored Resolve into helper functions (resolveEntries, resolveDirect, resolveReverseProviderModelID, resolveAlias, selectAliasModelRef, aliasTargetScore, resolveModelRef). New flow adds explicit alias-resolution stage with scoring-based candidate selection after direct and reverse lookups.
Test Coverage
internal/modeldata/fetcher_test.go, internal/modeldata/merger_test.go, internal/providers/registry_test.go
Updated fixture to include openai provider and gpt-4o model with aliases. Added test cases validating alias resolution with provider-specific enrichment and ambiguity detection. Added registry test confirming aliases enrich upstream models without creating synthetic entries.

Sequence Diagram

sequenceDiagram
    participant Caller as Caller
    participant Resolve as Resolve()
    participant Direct as Direct Lookup
    participant Reverse as Reverse Lookup
    participant Alias as Alias Resolution<br/>(aliasTargetsByID)
    participant Score as Score Candidates
    participant ModelRef as Resolve ModelRef

    Caller->>Resolve: Resolve(list, providerType, modelID)
    Resolve->>Direct: Try providerType + modelID
    Direct-->>Resolve: Found or Not
    alt Not Found
        Resolve->>Reverse: Try reverse lookup<br/>via providerModelByActualID
        Reverse-->>Resolve: Found or Not
        alt Still Not Found
            Resolve->>Alias: Check aliasTargetsByID[modelID]
            Alias-->>Resolve: List of alias targets
            alt Has Targets
                Resolve->>Score: Score candidates by<br/>ProviderType match
                Score-->>Resolve: Scored targets
                Resolve->>ModelRef: Select highest-scoring<br/>ModelRef
                ModelRef-->>Resolve: ModelRef + ProviderType
            end
        end
    end
    Resolve-->>Caller: ModelRef or nil
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • PR #82: Extends internal/modeldata (types.go, merger.go, fetcher_test.go) with alias handling and provider_model_id preference, directly modifying the same ModelList/Resolve implementation and reverse-index logic.
  • PR #160: Touches provider-qualified model lookup and registry enrichment behavior, including tests in internal/providers/registry_test.go that validate alias-based model registration.

Poem

🐰 Aliases bloom in the model meadow bright,
Reverse indices guide us through the night,
With scoring and logic we pick just the best,
No ambiguity clouds our quest!
Provider-qualified models now dance with glee,
A cleaner resolution, wild and free! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding support for model-list aliases in metadata lookup, which aligns with the core functionality changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/models-aliases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SantiagoDePolonia SantiagoDePolonia merged commit 142ba20 into main Mar 25, 2026
16 checks passed
@SantiagoDePolonia SantiagoDePolonia deleted the chore/models-aliases branch April 4, 2026 11:36
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