mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
works
This commit is contained in:
parent
133c82528e
commit
0d0ac4f61f
2 changed files with 15 additions and 6 deletions
|
@ -25,6 +25,7 @@ class ChatSummary:
|
||||||
sized.append((tokens, msg))
|
sized.append((tokens, msg))
|
||||||
total += tokens
|
total += tokens
|
||||||
|
|
||||||
|
dump(total, self.max_tokens)
|
||||||
if total <= self.max_tokens:
|
if total <= self.max_tokens:
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ class ChatSummary:
|
||||||
head = messages[:num]
|
head = messages[:num]
|
||||||
tail = messages[num:]
|
tail = messages[num:]
|
||||||
|
|
||||||
|
print("=" * 20)
|
||||||
summary = self.summarize_all(head)
|
summary = self.summarize_all(head)
|
||||||
|
|
||||||
tail_tokens = sum(tokens for tokens, msg in sized[num:])
|
tail_tokens = sum(tokens for tokens, msg in sized[num:])
|
||||||
|
@ -59,15 +61,12 @@ class ChatSummary:
|
||||||
if not content.endswith("\n"):
|
if not content.endswith("\n"):
|
||||||
content += "\n"
|
content += "\n"
|
||||||
|
|
||||||
dump(content)
|
|
||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
dict(role="system", content=prompts.summarize),
|
dict(role="system", content=prompts.summarize),
|
||||||
dict(role="user", content=content),
|
dict(role="user", content=content),
|
||||||
]
|
]
|
||||||
|
|
||||||
summary = simple_send_with_retries(model=models.GPT35.name, messages=messages)
|
summary = simple_send_with_retries(model=models.GPT35.name, messages=messages)
|
||||||
dump(summary)
|
|
||||||
|
|
||||||
return [dict(role="user", content=summary)]
|
return [dict(role="user", content=summary)]
|
||||||
|
|
||||||
|
@ -87,14 +86,19 @@ def main():
|
||||||
continue
|
continue
|
||||||
if line.startswith(">"):
|
if line.startswith(">"):
|
||||||
continue
|
continue
|
||||||
|
if line.startswith("#### /"):
|
||||||
|
continue
|
||||||
|
|
||||||
if line.startswith("#### "):
|
if line.startswith("#### "):
|
||||||
if assistant:
|
if assistant:
|
||||||
assistant = "".join(assistant)
|
assistant = "".join(assistant)
|
||||||
messages.append(dict(role="assistant", content=assistant))
|
if assistant.strip():
|
||||||
|
messages.append(dict(role="assistant", content=assistant))
|
||||||
assistant = []
|
assistant = []
|
||||||
|
|
||||||
messages.append(dict(role="user", content=line[5:]))
|
content = line[5:]
|
||||||
|
if content.strip() and content.strip() != "<blank>":
|
||||||
|
messages.append(dict(role="user", content=line[5:]))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assistant.append(line)
|
assistant.append(line)
|
||||||
|
|
|
@ -28,8 +28,13 @@ And got this output:
|
||||||
# CHAT HISTORY
|
# CHAT HISTORY
|
||||||
summarize = """*Briefly* summarize this partial conversation about programming.
|
summarize = """*Briefly* summarize this partial conversation about programming.
|
||||||
Include less detail about older parts and more detail about the most recent messages.
|
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.
|
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.
|
Phrase the summary with the USER in first person, telling the ASSISTANT about the conversation.
|
||||||
Write *as* the user.
|
Write *as* the user.
|
||||||
The user should refer to the assistant as *you*.
|
The user should refer to the assistant as *you*.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue