From e313a2ea45314f2e33a55d84ae9769758e357504 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 4 Feb 2025 12:31:48 -0800 Subject: [PATCH] feat: Update kwargs to include num_ctx for ollama if not set --- aider/models.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aider/models.py b/aider/models.py index 7e8a8ec9d..b1f454def 100644 --- a/aider/models.py +++ b/aider/models.py @@ -560,9 +560,8 @@ class Model(ModelSettings): kwargs["tool_choice"] = {"type": "function", "function": {"name": function["name"]}} if self.extra_params: kwargs.update(self.extra_params) - - # if is_ollama and kwargs[num_ctx] isn't set: num_ctx = token_count(messages) * 1.5 ai! - + if self.is_ollama() and "num_ctx" not in kwargs: + kwargs["num_ctx"] = int(self.token_count(messages) * 1.5) key = json.dumps(kwargs, sort_keys=True).encode() # dump(kwargs) hash_object = hashlib.sha1(key)