diff --git a/src/api/providers/fetchers/ollama.ts b/src/api/providers/fetchers/ollama.ts index 4bf43b6faf..0e36c6606e 100644 --- a/src/api/providers/fetchers/ollama.ts +++ b/src/api/providers/fetchers/ollama.ts @@ -89,7 +89,14 @@ export async function getOllamaModels( { headers }, ) .then((ollamaModelInfo) => { - models[ollamaModel.name] = parseOllamaModel(ollamaModelInfo.data) + const modelInfo = parseOllamaModel(ollamaModelInfo.data) + // Store with original name + models[ollamaModel.name] = modelInfo + // Also store with lowercase name for case-insensitive lookup + const lowerName = ollamaModel.name.toLowerCase() + if (lowerName !== ollamaModel.name) { + models[lowerName] = modelInfo + } }), ) } diff --git a/src/api/providers/native-ollama.ts b/src/api/providers/native-ollama.ts index 83a5c7b36e..af1ba50f24 100644 --- a/src/api/providers/native-ollama.ts +++ b/src/api/providers/native-ollama.ts @@ -274,9 +274,16 @@ export class NativeOllamaHandler extends BaseProvider implements SingleCompletio override getModel(): { id: string; info: ModelInfo } { const modelId = this.options.ollamaModelId || "" + // Try exact match first, then lowercase for case-insensitive lookup + let modelInfo = this.models[modelId] + if (!modelInfo && modelId) { + // Try case-insensitive lookup + const lowerModelId = modelId.toLowerCase() + modelInfo = this.models[lowerModelId] + } return { id: modelId, - info: this.models[modelId] || openAiModelInfoSaneDefaults, + info: modelInfo || openAiModelInfoSaneDefaults, } } diff --git a/webview-ui/src/components/ui/hooks/useSelectedModel.ts b/webview-ui/src/components/ui/hooks/useSelectedModel.ts index 3df7236713..24f23eece9 100644 --- a/webview-ui/src/components/ui/hooks/useSelectedModel.ts +++ b/webview-ui/src/components/ui/hooks/useSelectedModel.ts @@ -281,7 +281,13 @@ function getSelectedModel({ } case "ollama": { const id = apiConfiguration.ollamaModelId ?? "" - const info = ollamaModels && ollamaModels[apiConfiguration.ollamaModelId!] + // Try exact match first, then lowercase for case-insensitive lookup + let info = ollamaModels && ollamaModels[apiConfiguration.ollamaModelId!] + if (!info && ollamaModels && apiConfiguration.ollamaModelId) { + // Try case-insensitive lookup + const lowerModelId = apiConfiguration.ollamaModelId.toLowerCase() + info = ollamaModels[lowerModelId] + } const adjustedInfo = info?.contextWindow &&