Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting: Answer Yes/No dynamically #3050

Open
ryanpeach opened this issue Jan 28, 2025 · 1 comment
Open

Scripting: Answer Yes/No dynamically #3050

ryanpeach opened this issue Jan 28, 2025 · 1 comment

Comments

@ryanpeach
Copy link

Issue

Right now InputOutput.confirm_ask is being used as part of a single "run" given a user input.

self.io.user_input(with_message)

message = self.preproc_user_input(user_message)

self.check_for_file_mentions(inp)
inp = self.check_for_urls(inp)
return inp

if self.io.confirm_ask(f"Add {rel_fname} to the chat?", group=group, allow_never=True):

However in scripting this is inconvienient, because you can only use InputOutput(yes=True), which you have to declare BEFORE Coder.create or Coder.run

Example as is:

from aider.coders import Coder
from aider.models import Model
from aider.io import InputOutput

# This is a list of files to add to the chat
fnames = ["greeting.py"]

model = Model("gpt-4-turbo")

# Create an io object (required) and optionally enable confirmations with yes=True
io = InputOutput(yes=True)

# Create a coder object
coder = Coder.create(main_model=model, io=io, fnames=fnames)

# This will execute one instruction on those files and then return the last LLM message
result = coder.run("make a script that prints hello world")
print(result)

Instead, logically, you should be able to run something like this to see if you want to respond yes or not:

fnames = []  # Pretend we didn't give it the filename here
io = InputOutput(yes=None)  # Don't set yes
...
result = coder.run("make a script that prints hello world. Use greetings.py")  # Instead we gave it here
print(result)

result: Do you want to add greetings.py to the context? [Y/n]

result = coder.run("yes")  # Or maybe coder.answer to provide verification

Now result should equal result from the previous run.

Further, we should be able to load this from history!

the chat.history.md file should allow "unanswered" steps:

if not self.done_messages and restore_chat_history:
history_md = self.io.read_text(self.io.chat_history_file)
if history_md:
self.done_messages = utils.split_chat_history_markdown(history_md)
self.summarize_start()

def split_chat_history_markdown(text, include_tool=False):

This function could be modified to scan for answered Y/n questions to things such as adding a file or url, and auto-rerunning those commands.

But further, if there is an unanswered "Y/n" followed by a user "/yes" or "/no" then it adds that to the chat history file as the answer, and then proceeds.

I am willing to implement the demo.

Version and model info

No response

@ryanpeach
Copy link
Author

ryanpeach commented Feb 11, 2025

I've reviewed everywhere confirm_ask is used:

  1. Offer to open a url seen in the messages
  2. Offer to add a file seen in the messages to context
  3. Run pip install
  4. Install playwright
  5. Create a git repo
  6. Add aider files to gitignore
  7. Add command output to chat
  8. Run shell command
  9. Allow edits to files not added to chat
  10. Create new file
  11. Add file name to chat
  12. Attempt to fix test errors
  13. Attempt to fix lint errors
  14. Try to proceed anyway?
  15. Add url to chat

It would be great if we could individually answer these yes-no for scripting purposes at the least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant