feat: filter discovered models via includeModels/excludeModels - #27
Merged
Merged
Conversation
Per-provider glob filters (only `*`, everything else literal) let one LiteLLM proxy be split across several OpenCode providers without hand-maintained model lists. includeModels is evaluated first, excludeModels always wins, and empty/omitted arrays mean no filtering. Based on #21 by Cleverson Sacramento, with two changes for the post-v1.0 architecture: the filter is applied inside discoverModels() rather than at merge time, so the SWR cache and background refresh write the same filtered view instead of the filter silently lapsing after the first refresh; and the dead V2-schema path it also touched no longer exists. Co-authored-by: Cleverson Sacramento <cleverson.sacramento@gmail.com>
|
Warning Review limit reachedNext included review available in 37 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
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. Comment |
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.
Summary
Implements #21's feature on top of the post-v1.0 codebase. Per-provider
includeModels/excludeModelsglob options let one LiteLLM proxy be split across several OpenCode providers (e.g. one provider per naming prefix or environment) without hand-maintaining a model list.Credit and a big thank-you to @zyc (Cleverson Sacramento) — the design, the minimal
*-only glob implementation, and the option semantics are all theirs. This PR carries their work forward with two adaptations and lands it as a clean rebase was no longer practical after #24/#26 rewrote the surrounding code.Behavior
includeModelsevaluated first — only ids matching at least one pattern are kept; omit it to keep everything.excludeModelsevaluated after and always wins.*; everything else matches literally (dots ingpt-4.1need no escaping).Why applied in
discoverModels()instead of at merge time (the #21 review follow-up)In #21 the filter ran in the cold discovery path only. On the current architecture that silently lapses:
backgroundRefresh()writes an unfiltered result into the SWR cache, and the next startup's cache-hit path merges it without filtering. Here the filter runs insidediscoverModels(), so cold discovery and background refresh persist the same filtered view, and each provider's cache (already keyedproviderId@baseURL) holds exactly its own slice.Type of change
Checklist
npm run typecheckpassesnpm test— 35 tests pass, including 7 newpassesModelFiltercases (include/exclude/precedence, empty arrays, literal metacharacters, mid-pattern stars, case sensitivity)Co-authored-bytrailer)Closes #21