mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14: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))
|
||||
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() != "<blank>":
|
||||
messages.append(dict(role="user", content=line[5:]))
|
||||
continue
|
||||
|
||||
assistant.append(line)
|
||||
|
|
|
@ -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*.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue