Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions webview-ui/src/components/ui/hooks/useSelectedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

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.

return {
id,
info: info || undefined,
info:
info ||
(id
? {
maxTokens: 8192,
Copy link
Author

Choose a reason for hiding this comment

The 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,
}
Copy link
Author

Choose a reason for hiding this comment

The 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!]
Copy link
Author

Choose a reason for hiding this comment

The 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": {
Expand Down
Loading