From 41772ccef681b496147f3b3b8f26bdfba7c30e75 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 30 Jul 2024 20:37:30 -0300 Subject: [PATCH] Ensure ChatSummary has at least one model available and use the first model's max input tokens for summarization --- aider/history.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aider/history.py b/aider/history.py index 5cd41151b..131cf4b31 100644 --- a/aider/history.py +++ b/aider/history.py @@ -26,6 +26,9 @@ class ChatSummary: return sized def summarize(self, messages, depth=0): + if not self.models: + raise ValueError("No models available for summarization") + sized = self.tokenize(messages) total = sum(tokens for tokens, _msg in sized) if total <= self.max_tokens and depth == 0: @@ -65,7 +68,7 @@ class ChatSummary: total = 0 # These sometimes come set with value = None - model_max_input_tokens = self.model.info.get("max_input_tokens") or 4096 + model_max_input_tokens = self.models[0].info.get("max_input_tokens") or 4096 model_max_input_tokens -= 512 for i in range(split_index):