From 0d0ac4f61f736aef4dc15dd441aa38be5c0277b9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 22 Jul 2023 10:32:32 -0300 Subject: [PATCH] works --- aider/history.py | 14 +++++++++----- aider/prompts.py | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/aider/history.py b/aider/history.py index 560c3c9b4..214198f96 100644 --- a/aider/history.py +++ b/aider/history.py @@ -25,6 +25,7 @@ class ChatSummary: sized.append((tokens, msg)) total += tokens + dump(total, self.max_tokens) if total <= self.max_tokens: return messages @@ -37,6 +38,7 @@ class ChatSummary: head = messages[:num] tail = messages[num:] + print("=" * 20) summary = self.summarize_all(head) tail_tokens = sum(tokens for tokens, msg in sized[num:]) @@ -59,15 +61,12 @@ class ChatSummary: if not content.endswith("\n"): content += "\n" - dump(content) - messages = [ dict(role="system", content=prompts.summarize), dict(role="user", content=content), ] summary = simple_send_with_retries(model=models.GPT35.name, messages=messages) - dump(summary) return [dict(role="user", content=summary)] @@ -87,14 +86,19 @@ def main(): continue if line.startswith(">"): continue + if line.startswith("#### /"): + continue if line.startswith("#### "): if assistant: assistant = "".join(assistant) - messages.append(dict(role="assistant", content=assistant)) + if assistant.strip(): + messages.append(dict(role="assistant", content=assistant)) assistant = [] - messages.append(dict(role="user", content=line[5:])) + content = line[5:] + if content.strip() and content.strip() != "": + messages.append(dict(role="user", content=line[5:])) continue assistant.append(line) diff --git a/aider/prompts.py b/aider/prompts.py index c66d868e7..fd1a56d59 100644 --- a/aider/prompts.py +++ b/aider/prompts.py @@ -28,8 +28,13 @@ And got this output: # CHAT HISTORY summarize = """*Briefly* summarize this partial conversation about programming. Include less detail about older parts and more detail about the most recent messages. +Start a new paragraph every time the topic changes! + This is only part of a longer conversation so *DO NOT* conclude the summary with language like "Finally, ...". Because the conversation continues after the summary. -It's *very important* to include relevant code identifiers, file names, etc since this is a conversation about programming. +The summary *MUST* include the function names, libraries, packages that are being discussed. +The summary *MUST* include the filenames that are being referenced by the assistant inside the ```...``` fenced code blocks! +The summaries *MUST NOT* include ```...``` fenced code blocks! + Phrase the summary with the USER in first person, telling the ASSISTANT about the conversation. Write *as* the user. The user should refer to the assistant as *you*.