fix: allow Ollama to connect to external servers without model validation blocking

- Modified validation logic to only validate Ollama models when there are more than 1 model in the list
- This prevents blocking users from connecting to external Ollama servers where model discovery might not work properly
- Fixes issue #6589 where users could not connect to non-localhost Ollama instances
This commit is contained in:
Roo Code 2025-08-02 07:48:48 +00:00
parent 8513263a67
commit 892c3ae202

View file

@ -259,7 +259,19 @@ export function validateModelId(apiConfiguration: ProviderSettings, routerModels
const models = routerModels?.[provider]
if (models && Object.keys(models).length > 1 && !Object.keys(models).includes(modelId)) {
// For Ollama, we should not validate against the model list if it's empty or has only one model
// This allows users to connect to external Ollama servers where model discovery might not work
if (provider === "ollama") {
// Only validate if we have a substantial list of models (more than 1)
// This prevents blocking users from using custom models on external servers
if (models && Object.keys(models).length > 1 && !Object.keys(models).includes(modelId)) {
return i18next.t("settings:validation.modelAvailability", { modelId })
}
return undefined
}
// For other providers, validate if we have any models in the list
if (models && Object.keys(models).length > 0 && !Object.keys(models).includes(modelId)) {
return i18next.t("settings:validation.modelAvailability", { modelId })
}