Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions aider/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,13 @@ def get_io(pretty):
analytics.event("exit", reason="Invalid lint command format")
return 1

if main_model.ollama_error and args.exit:
io.tool_error(
f"Cannot connect to Ollama: {main_model.ollama_error}\n"
"Aborting because --exit (batch mode) was specified."
)
return 1

if args.show_model_warnings:
problem = models.sanity_check_models(io, main_model)
if problem:
Expand Down
11 changes: 10 additions & 1 deletion aider/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ def get_model_info(self, model):
try:
litellm_info = litellm.get_model_info(model)
except Exception as ex:
if str(ex).startswith("OllamaError:"):
raise
if "model_prices_and_context_window.json" not in str(ex):
print(str(ex))

Expand Down Expand Up @@ -327,6 +329,7 @@ def __init__(
self.max_chat_history_tokens = 1024
self.weak_model = None
self.editor_model = None
self.ollama_error = None

# Find the extra settings
self.extra_model_settings = next(
Expand Down Expand Up @@ -357,7 +360,13 @@ def __init__(
self.get_editor_model(editor_model, editor_edit_format)

def get_model_info(self, model):
return model_info_manager.get_model_info(model)
try:
return model_info_manager.get_model_info(model)
except Exception as ex:
if str(ex).startswith("OllamaError:"):
self.ollama_error = ex
return {}
raise

def _copy_fields(self, source):
"""Helper to copy fields from a ModelSettings instance to self"""
Expand Down