aider icon indicating copy to clipboard operation
aider copied to clipboard

GPT claiming it can't read files that Aider or I add to chat

Open Orinks opened this issue 1 year ago • 4 comments

This is my first time using this, and while it appeared to do what it was supposed to, Aider kept prompting me to add the same file to chat over and over. When it did so, GPT claimed that it could not see the code to add changes. Is this one of those hallucination looping issues that faces every GPT app? I'll add the history markdown file for reference. Perhaps I didn't prompt it correctly? .aider.chat.history.md

Orinks avatar Jul 02 '23 22:07 Orinks

Thanks for trying aider and reporting this issue and sharing the chat history. That's very helpful information.

It looks to me like this may be a problem with the way aider handles subdirectories on Windows. I will continue to investigate and let you know when I've implemented a solution.

In the meantime, you might want to try and avoid using subdirectories and see if that helps. When starting a new project with aider you could run aider like aider quorum_scraper.py. Aider will make a new empty file without suggesting a subdirectory. Then when you ask for code, it will go into that file.

For example, here is the transcript of me doing that and giving aider your initial prompt:

aider quorum_scraper.py

Model: gpt-4
Creating empty file quorum_scraper.py
Files not tracked in .git:
quorum_scraper.py
Add them? y
Added quorum_scraper.py to the git repo
Commit 07b56f3 Added new files to the git repo: quorum_scraper.py
Git repo: .git
Repo-map: universal-ctags using 1024 tokens
Added quorum_scraper.py to the chat.
Use /help to see in-chat commands.

I want to make a Quorum web scraper that scrapes text from pages and subpages from http://quorumlanguage.com. The script will create text files so that a large language model can understand them.

To create a web scraper for the Quorum language website, we will need to use a library like BeautifulSoup to parse the HTML of the website and extract the text. We will also need the requests library to send HTTP requests to the website.

Here are the steps we will follow:

  1. Send a GET request to the main page of the website.
  2. Parse the HTML of the main page to find links to subpages.
  3. For each subpage, send a GET request to retrieve the HTML.
  4. Parse the HTML of each subpage to extract the text.
  5. Write the text to a file.

Here's how we can modify your quorum_scraper.py file to implement this:

quorum_scraper.py
<<<<<<< ORIGINAL

=======
import requests
from bs4 import BeautifulSoup
import os

def get_page_text(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    return soup.get_text()

def get_subpage_urls(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    return [a['href'] for a in soup.find_all('a', href=True) if a.text]

def write_text_to_file(text, filename):
    with open(filename, 'w') as f:
        f.write(text)

def main():
    url = 'http://quorumlanguage.com'
    subpage_urls = get_subpage_urls(url)
    for i, subpage_url in enumerate(subpage_urls):
        text = get_page_text(subpage_url)
        write_text_to_file(text, f'subpage_{i}.txt')

if __name__ == '__main__':
    main()
>>>>>>> UPDATED

This script will create a text file for each subpage on the Quorum language website. The text files will be named subpage_0.txt, subpage_1.txt, etc.

Applied edit to quorum_scraper.py
Commit 3ea30de aider: Refactor quorum_scraper.py to include functions for getting page text, subpage URLs, and writing text to a file, and add a main function that retrieves the subpage URLs, gets the text for each subpage, and writes it to a file.

paul-gauthier avatar Jul 03 '23 20:07 paul-gauthier

Correct me if i'm wrong -- until this issue is fixed, aider won't be able to access existing repos on Windows, only new ones being created, yes?

twilwa avatar Jul 04 '23 23:07 twilwa

Thanks for your patience on this. I had to set up a cloud windows server to debug this issue.

I just pushed a fix, so aider should stop asking over and over again to add files that are in subdirectories.

You'll need to install the latest from github to pick up this fix. Let me know if if resolves your issue.

paul-gauthier avatar Jul 05 '23 20:07 paul-gauthier

I also added a CI step to run all the tests on windows on every push now.

https://github.com/paul-gauthier/aider/actions/runs/5469581577

paul-gauthier avatar Jul 05 '23 22:07 paul-gauthier

I'm going to close this issue for now. Please feel free to re-open or file a new issue if you continue to see problems.

paul-gauthier avatar Jul 06 '23 20:07 paul-gauthier