From ff41f9bd9a29585176c16445d2064f426864ec7c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 4 Jan 2025 06:18:12 -0800 Subject: [PATCH] refactor: adjust max_chat_history_tokens calculation based on max_input_tokens --- aider/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aider/models.py b/aider/models.py index cef4503fa..256a1918f 100644 --- a/aider/models.py +++ b/aider/models.py @@ -920,10 +920,13 @@ class Model(ModelSettings): self.keys_in_environment = res.get("keys_in_environment") max_input_tokens = self.info.get("max_input_tokens") or 0 - if max_input_tokens < 32 * 1024: - self.max_chat_history_tokens = 1024 - else: + # generalize this with division. ai! + if max_input_tokens < 16 * 1024: + self.max_chat_history_tokens = 1 * 1024 + elif max_input_tokens < 32 * 1024: self.max_chat_history_tokens = 2 * 1024 + else: + self.max_chat_history_tokens = 4 * 1024 self.configure_model_settings(model) if weak_model is False: