From 6725c9e3cdd6ae25d433d4aecbec0dd3e89504c2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 4 Feb 2025 11:25:02 -0800 Subject: [PATCH] feat: Add Ollama model context size configuration in model settings --- aider/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/models.py b/aider/models.py index 9ab80a8f2..bdf01da3b 100644 --- a/aider/models.py +++ b/aider/models.py @@ -257,6 +257,11 @@ class Model(ModelSettings): if not exact_match: self.apply_generic_model_settings(model) + if model.startswith("ollama/") or model.startswith("ollama_chat/"): # and num_ctx isn't already set ai! + self.extra_params = dict(num_ctx=8 * 1024) + dump(self.extra_params) + + # Apply override settings last if they exist if self.extra_model_settings and self.extra_model_settings.extra_params: # Initialize extra_params if it doesn't exist @@ -357,8 +362,6 @@ class Model(ModelSettings): self.edit_format = "diff" self.editor_edit_format = "editor-diff" self.use_repo_map = True - if model.startswith("ollama/") or model.startswith("ollama_chat/"): - self.extra_params = dict(num_ctx=8 * 1024) return # <-- # use the defaults