aider: Add tqdm progress bar to summarize_chat_history_markdown loop.

# Aider chat conversation:

USER: add a tqdm to `summarize_chat_history_markdown` loop

ASSISTANT: ```diff
--- aider/history.py
+++ aider/history.py
@@ ... @@
 from aider.sendchat import simple_send_with_retries
+from tqdm import tqdm

 class ChatSummary:
     def __init__(self, model=None, max_tokens=1024):
@@ ... @@
     def summarize_chat_history_markdown(self, text):
         messages = []
         assistant = []
+        lines = text.splitlines(keepends=True)
+        for line in tqdm(lines, desc="Summarizing chat history"):
-        for line in text.splitlines(keepends=True):
             if line.startswith("# "):
                 continue
             if line.startswith(">"):
                 continue
             if line.startswith("#### /"):
                 continue

             if line.startswith("#### "):
                 if assistant:
                     assistant = "".join(assistant)
                     if assistant.strip():
                         messages.append(dict(role="assistant", content=assistant))
                     assistant = []

                 content = line[5:]
                 if content.strip() and content.strip() != "<blank>":
                     messages.append(dict(role="user", content=line[5:]))
                 continue

             assistant.append(line)

         summary = self.summarize(messages[-40:])
         return summary
```

This diff adds the `tqdm` progress bar to the `summarize_chat_history_markdown` method in the `aider/history.py` file. It wraps the loop that processes the chat history lines with `tqdm`, providing a description for the progress bar.
This commit is contained in:
Paul Gauthier 2024-05-06 09:31:32 -07:00
parent 64470955d4
commit e51e0219ee

View file

@ -4,6 +4,7 @@ from aider import models, prompts
from aider.dump import dump # noqa: F401
from aider.sendchat import simple_send_with_retries
from tqdm import tqdm
class ChatSummary:
def __init__(self, model=None, max_tokens=1024):
@ -93,7 +94,8 @@ class ChatSummary:
def summarize_chat_history_markdown(self, text):
messages = []
assistant = []
for line in text.splitlines(keepends=True):
lines = text.splitlines(keepends=True)
for line in tqdm(lines, desc="Summarizing chat history"):
if line.startswith("# "):
continue
if line.startswith(">"):