-
Couldn't load subscription status.
- Fork 2.4k
fix: provide fallback context window values for Ollama and LM Studio models #7676
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,17 +255,37 @@ function getSelectedModel({ | |
| case "ollama": { | ||
| const id = apiConfiguration.ollamaModelId ?? "" | ||
| const info = routerModels.ollama && routerModels.ollama[id] | ||
| // Provide fallback values when info is undefined to fix context window display | ||
| return { | ||
| id, | ||
| info: info || undefined, | ||
| info: | ||
| info || | ||
| (id | ||
| ? { | ||
| maxTokens: 8192, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 8192 the right default for all Ollama models? Some models support much larger context windows. Could we consider making this configurable or perhaps use a more generous default like 32768? |
||
| contextWindow: 8192, | ||
| supportsImages: false, | ||
| supportsPromptCache: true, | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback logic here is duplicated with the LM Studio case below. Could we extract this into a shared helper function to reduce duplication? Something like: |
||
| : undefined), | ||
| } | ||
| } | ||
| case "lmstudio": { | ||
| const id = apiConfiguration.lmStudioModelId ?? "" | ||
| const info = lmStudioModels && lmStudioModels[apiConfiguration.lmStudioModelId!] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The non-null assertion here could be avoided with better type checking. Consider: |
||
| // Provide fallback values when info is undefined to fix context window display | ||
| return { | ||
| id, | ||
| info: info || undefined, | ||
| info: | ||
| info || | ||
| (id | ||
| ? { | ||
| maxTokens: 8192, | ||
| contextWindow: 8192, | ||
| supportsImages: false, | ||
| supportsPromptCache: false, | ||
| } | ||
| : undefined), | ||
| } | ||
| } | ||
| case "vscode-lm": { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add test coverage for these fallback scenarios? I noticed there are no tests for Ollama or LM Studio providers in the test file. This would help ensure the fallback behavior works correctly and prevent regressions.