Update chat mode

This commit is contained in:
Your Name 2024-07-28 20:18:16 -03:00 committed by Your Name (aider)
parent 09a52f81f1
commit 3121fa1227
2 changed files with 15 additions and 7 deletions

View file

@ -6,7 +6,7 @@ from pathlib import Path
import git
from aider import models, prompts, voice, coders
from aider import models, prompts, voice
from aider.help import Help, install_help_extra
from aider.llm import litellm
from aider.scrape import Scraper, install_playwright
@ -44,14 +44,20 @@ class Commands:
models.sanity_check_models(self.io, model)
raise SwitchCoder(main_model=model)
def cmd_edit_format(self, args):
"Switch to a new editing mode"
def cmd_chat_mode(self, args):
"Switch to a new chat mode"
from aider import coders
ef = args.strip()
valid_formats = [coder.edit_format for coder in coders.__all__ if getattr(coder, 'edit_format', None)]
if ef not in valid_formats:
self.io.tool_error(f"Edit format \"{ef}\" must be one of:")
if ef:
self.io.tool_error(f"Edit format \"{ef}\" must be one of:")
else:
self.io.tool_error(f"Edit format must be one of:")
for format in valid_formats:
self.io.tool_error(f"- {format}")
return
@ -114,11 +120,13 @@ class Commands:
if not attr.startswith("cmd_"):
continue
cmd = attr[4:]
cmd = cmd.replace('_', '-')
commands.append("/" + cmd)
return commands
def do_run(self, cmd_name, args):
cmd_name = cmd_name.replace('-', '_')
cmd_method_name = f"cmd_{cmd_name}"
cmd_method = getattr(self, cmd_method_name, None)
if cmd_method:
@ -688,7 +696,7 @@ class Commands:
pad = max(len(cmd) for cmd in commands)
pad = "{cmd:" + str(pad) + "}"
for cmd in commands:
cmd_method_name = f"cmd_{cmd[1:]}"
cmd_method_name = f"cmd_{cmd[1:]}".replace("-", "_")
cmd_method = getattr(self, cmd_method_name, None)
cmd = pad.format(cmd=cmd)
if cmd_method:
@ -771,7 +779,7 @@ class Commands:
"""
commands = sorted(self.get_commands())
for cmd in commands:
cmd_method_name = f"cmd_{cmd[1:]}"
cmd_method_name = f"cmd_{cmd[1:]}".replace("-", "_")
cmd_method = getattr(self, cmd_method_name, None)
if cmd_method:
description = cmd_method.__doc__

View file

@ -16,6 +16,7 @@ cog.out(get_help_md())
|:------|:----------|
| **/add** | Add files to the chat so GPT can edit them or review them in detail |
| **/ask** | Ask questions about the code base without editing any files |
| **/chat-mode** | Switch to a new chat mode |
| **/clear** | Clear the chat history |
| **/commit** | Commit edits to the repo made outside the chat (commit message optional) |
| **/diff** | Display the diff of the last aider commit |
@ -25,7 +26,6 @@ cog.out(get_help_md())
| **/help** | Ask questions about aider |
| **/lint** | Lint and fix provided files or in-chat files if none provided |
| **/ls** | List all known files and indicate which are included in the chat session |
| **/mode** | Switch to a new editing mode |
| **/model** | Switch to a new LLM |
| **/models** | Search the list of available models |
| **/quit** | Exit the application |