mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
refactored summarize_chat_history_markdown
This commit is contained in:
parent
3bb237bdc1
commit
cd84cc0d3e
1 changed files with 33 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from aider import prompts
|
from aider import models, prompts
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.sendchat import simple_send_with_retries
|
from aider.sendchat import simple_send_with_retries
|
||||||
|
|
||||||
|
@ -90,15 +90,7 @@ class ChatSummary:
|
||||||
|
|
||||||
return [dict(role="user", content=summary)]
|
return [dict(role="user", content=summary)]
|
||||||
|
|
||||||
|
def summarize_chat_history_markdown(self, text):
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("filename", help="Markdown file to parse")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
with open(args.filename, "r") as f:
|
|
||||||
text = f.read()
|
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
assistant = []
|
assistant = []
|
||||||
for line in text.splitlines(keepends=True):
|
for line in text.splitlines(keepends=True):
|
||||||
|
@ -123,8 +115,22 @@ def main():
|
||||||
|
|
||||||
assistant.append(line)
|
assistant.append(line)
|
||||||
|
|
||||||
summarizer = ChatSummary("gpt-3.5-turbo", weak_model=False)
|
summary = self.summarize(messages[-40:])
|
||||||
summary = summarizer.summarize(messages[-40:])
|
return summary
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("filename", help="Markdown file to parse")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
model = models.Model("gpt-3.5-turbo")
|
||||||
|
summarizer = ChatSummary(model)
|
||||||
|
|
||||||
|
with open(args.filename, "r") as f:
|
||||||
|
text = f.read()
|
||||||
|
|
||||||
|
summary = summarizer.summarize_chat_history_markdown(text)
|
||||||
dump(summary)
|
dump(summary)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue