From af29e633b2c070ff41e16e31048b469d00ec351f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 2 Jul 2024 19:42:31 -0300 Subject: [PATCH] Handle max_input_tokens set with None #757 --- aider/history.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aider/history.py b/aider/history.py index e80b80e1c..3615235c4 100644 --- a/aider/history.py +++ b/aider/history.py @@ -61,7 +61,11 @@ class ChatSummary: sized.reverse() keep = [] total = 0 - model_max_input_tokens = self.model.info.get("max_input_tokens", 4096) - 512 + + # These sometimes come set with value = None + model_max_input_tokens = self.model.info.get("max_input_tokens") or 4096 + model_max_input_tokens -= 512 + for i in range(split_index): total += sized[i][0] if total > model_max_input_tokens: