Added /clear cmd

This commit is contained in:
Paul Gauthier 2023-06-05 11:31:47 -07:00
parent c30b302363
commit c17e454608
2 changed files with 11 additions and 1 deletions

View file

@ -72,7 +72,6 @@ class Coder:
else:
self.console = Console(force_terminal=True, no_color=True)
self.commands = Commands(self.io, self)
if not self.check_model_availability(main_model):
main_model = Models.GPT35.value
@ -89,6 +88,8 @@ class Coder:
self.show_diffs = show_diffs
self.commands = Commands(self.io, self)
self.set_repo(fnames)
if self.repo:

View file

@ -4,6 +4,7 @@ import subprocess
import sys
import git
import tiktoken
from prompt_toolkit.completion import Completion
from aider import prompts
@ -14,6 +15,7 @@ class Commands:
def __init__(self, io, coder):
self.io = io
self.coder = coder
self.tokenizer = tiktoken.encoding_for_model(coder.main_model)
def is_command(self, inp):
if inp[0] == "/":
@ -76,6 +78,13 @@ class Commands:
commit_message = args.strip()
self.coder.commit(message=commit_message, which="repo_files")
def cmd_clear(self, args):
"Clear the chat history and drop all files from the chat context"
self.coder.abs_fnames = set()
self.coder.done_messages = []
self.coder.cur_messages = []
def cmd_undo(self, args):
"Undo the last git commit if it was done by aider"
if not self.coder.repo: