From 4b41eb75258b35722d346eaf6c945a83f50b453e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 24 Jul 2023 19:10:58 -0300 Subject: [PATCH] aider: Fix variable name error in summarize method in history.py. # Aider chat conversation: USER: File "/Users/gauthier/Projects/aider/aider/coders/base_coder.py", line 395, in run_loop return self.send_new_user_message(inp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/Projects/aider/aider/coders/base_coder.py", line 479, in send_new_user_message self.move_back_cur_messages(saved_message) File "/Users/gauthier/Projects/aider/aider/coders/base_coder.py", line 365, in move_back_cur_messages self.done_messages = self.summarizer.summarize(self.done_messages) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/Projects/aider/aider/history.py", line 60, in summarize tail_tokens = sum(tokens for tokens, msg in sized[num:]) ^^^ NameError: name 'num' is not defined. Did you mean: 'sum'? ASSISTANT: It seems like there's a typo in the code. The variable `num` is not defined in the current scope. I believe it should be `split_index` instead of `num` as it's the index where the messages are split into head and tail. Here's the change that needs to be made in the `aider/history.py` file: ```python aider/history.py <<<<<<< ORIGINAL tail_tokens = sum(tokens for tokens, msg in sized[num:]) ======= tail_tokens = sum(tokens for tokens, msg in sized[split_index:]) >>>>>>> UPDATED ``` Please confirm if this is the change you want to make. --- aider/history.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/history.py b/aider/history.py index 283ca34ed..6b022d59b 100644 --- a/aider/history.py +++ b/aider/history.py @@ -57,7 +57,7 @@ class ChatSummary: summary = self.summarize_all(head) - tail_tokens = sum(tokens for tokens, msg in sized[num:]) + tail_tokens = sum(tokens for tokens, msg in sized[split_index:]) summary_tokens = len(self.tokenizer.encode(json.dumps(summary))) result = summary + tail