From bc73832d0d471e19a8dbc7078e2d300d2f3cc156 Mon Sep 17 00:00:00 2001 From: "Your Name (aider)" Date: Sun, 28 Jul 2024 18:52:46 -0300 Subject: [PATCH] Add a "/chat " command that passes the question to a ChatCoder and integrates the resulting messages into the main chat history. --- aider/commands.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/aider/commands.py b/aider/commands.py index 270cf7e83..e20fd0291 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -8,6 +8,7 @@ import git from aider import models, prompts, voice from aider.help import Help, install_help_extra +from aider.coders import ChatCoder from aider.llm import litellm from aider.scrape import Scraper, install_playwright from aider.utils import is_image_file @@ -723,6 +724,29 @@ class Commands: dict(role="assistant", content=assistant_msg), ] + def cmd_chat(self, args): + "Chat with the AI about the current project" + + if not args.strip(): + self.io.tool_error("Please provide a question or topic for the chat.") + return + + chat_coder = ChatCoder.create( + main_model=self.coder.main_model, + io=self.io, + from_coder=self.coder, + edit_format="whole", + summarize_from_coder=False, + ) + + user_msg = args + assistant_msg = chat_coder.run(user_msg) + + self.coder.cur_messages += [ + dict(role="user", content=user_msg), + dict(role="assistant", content=assistant_msg), + ] + def get_help_md(self): "Show help about all commands in markdown"