-
Notifications
You must be signed in to change notification settings - Fork 231
feat: support custom model info overrides #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
everyoneexe
wants to merge
15
commits into
Zoo-Code-Org:main
Choose a base branch
from
everyoneexe:feat/custom-model-info-override
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
61bca0d
docs: add design spec for custom model settings override
everyoneexe 3f7641f
feat: support custom model info overrides
everyoneexe e382bfe
fix: address custom model metadata review feedback
everyoneexe ee085a2
chore: remove internal design spec from PR
everyoneexe 546ddf4
fix: harden tests and improve code clarity across custom model info
everyoneexe b1ea608
merge: integrate main into feat/custom-model-info-override
everyoneexe 13ce7f0
fix: address maintainer review feedback on custom model info
everyoneexe eac42d6
test: add Playwright CT baseline screenshots for CustomModelInfoSettings
everyoneexe 9ee1405
fix: allow minor pixel diff in Playwright CT visual comparisons
everyoneexe fabea64
Merge branch 'main' into feat/custom-model-info-override
everyoneexe 63e6ce4
merge: resolve conflict with main (clearAllMocks helper migration)
everyoneexe 879e403
Merge branch 'feat/custom-model-info-override' of github.com:everyone…
everyoneexe 667fd5e
Merge branch 'main' into feat/custom-model-info-override
everyoneexe 505c50a
Merge branch 'main' into feat/custom-model-info-override
everyoneexe 854e816
fix(webview): fix useSelectedModel.spec.ts after merge conflict resol…
everyoneexe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { applyCustomModelInfo, customModelInfoSchema, type ModelInfo } from "../model.js" | ||
| import { providerIdentifiers, providerSettingsSchemaDiscriminated } from "../index.js" | ||
|
|
||
| describe("custom model info", () => { | ||
| it("overlays only supported metadata and preserves provider-owned fields", () => { | ||
| const model: ModelInfo = { | ||
| maxTokens: 4096, | ||
| contextWindow: 8192, | ||
| supportsImages: false, | ||
| supportsPromptCache: false, | ||
| inputPrice: 0.1, | ||
| outputPrice: 0.2, | ||
| description: "Provider metadata", | ||
| } | ||
|
|
||
| expect( | ||
| applyCustomModelInfo(model, { | ||
| customModelInfo: { | ||
| contextWindow: 128_000, | ||
| maxTokens: 16_384, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| }, | ||
| }), | ||
| ).toEqual({ | ||
| ...model, | ||
| contextWindow: 128_000, | ||
| maxTokens: 16_384, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| }) | ||
| }) | ||
|
|
||
| it("does not synthesize model info without a valid context window", () => { | ||
| expect( | ||
| applyCustomModelInfo(undefined, { | ||
| customModelInfo: { | ||
| contextWindow: 0, | ||
| maxTokens: -1, | ||
| supportsImages: true, | ||
| }, | ||
| }), | ||
| ).toBeUndefined() | ||
| }) | ||
|
|
||
| it("synthesizes safe defaults when only a context window is supplied", () => { | ||
| expect( | ||
| applyCustomModelInfo(undefined, { | ||
| customModelInfo: { contextWindow: 64_000, supportsImages: true }, | ||
| }), | ||
| ).toEqual({ | ||
| maxTokens: undefined, | ||
| contextWindow: 64_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: false, | ||
| }) | ||
| }) | ||
|
|
||
| it("rejects unsupported pricing fields in the persisted override schema", () => { | ||
| expect(customModelInfoSchema.safeParse({ contextWindow: 64_000, inputPrice: 1 }).success).toBe(false) | ||
| expect( | ||
| providerSettingsSchemaDiscriminated.safeParse({ | ||
| apiProvider: providerIdentifiers.openrouter, | ||
| customModelInfo: { contextWindow: 64_000, outputPrice: 1 }, | ||
| }).success, | ||
| ).toBe(false) | ||
| }) | ||
|
|
||
| it("rejects unsafe integer overrides", () => { | ||
| const unsafeInteger = Number.MAX_SAFE_INTEGER + 1 | ||
|
|
||
| expect(customModelInfoSchema.safeParse({ contextWindow: unsafeInteger }).success).toBe(false) | ||
| expect(customModelInfoSchema.safeParse({ maxTokens: unsafeInteger }).success).toBe(false) | ||
| }) | ||
| }) |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.