From 028477f34d19e6c41dc0c1e955d9e9bd261972f4 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 4 Feb 2025 11:25:04 -0800 Subject: [PATCH] refactor: Prevent overwriting existing num_ctx for Ollama models --- aider/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aider/models.py b/aider/models.py index bdf01da3b..1efa59b7c 100644 --- a/aider/models.py +++ b/aider/models.py @@ -257,9 +257,10 @@ 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) + if model.startswith("ollama/") or model.startswith("ollama_chat/"): + if not (self.extra_params and "num_ctx" in self.extra_params): + self.extra_params = dict(num_ctx=8 * 1024) + dump(self.extra_params) # Apply override settings last if they exist