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

Changes not applied to file when using gpt-3.5-turbo #8

Closed
tiktuk opened this issue May 29, 2023 · 5 comments
Closed

Changes not applied to file when using gpt-3.5-turbo #8

tiktuk opened this issue May 29, 2023 · 5 comments

Comments

@tiktuk
Copy link

tiktuk commented May 29, 2023

Hi, when I use aider, response is printed to the terminal but not applied to the file like described and shown in the screencasts. I don't have GPT-4 access yes, though, so am running with the -3 flag.

Thanks for doing this, eager to use it :) .

@paul-gauthier
Copy link
Collaborator

Thanks for trying aider!

You are probably correct that the issue is caused by using gpt-3.5-turbo. It doesn't following instructions well, and often fails to format code in a way that aider expects.

Is it outputting "edit blocks" that look like the example in the prompts?
https://github.com/paul-gauthier/aider/blob/82cc64eb6f4bd1006bf55b94890a76c5db1576b8/aider/prompts.py#L18-L28

If not, then aider won't be able to parse out the edit and apply to the file.

@tiktuk
Copy link
Author

tiktuk commented May 29, 2023

No, it's just outputting the entire file, with its changes. It would be nice if there was a command like /replace or /overwrite that would simply replace the file with that output. Because the answer is good, even though it's gpt-3.5-turbo.

@paul-gauthier
Copy link
Collaborator

Yes, it would be nice for aider to support some basic functionality with gpt-3.5-turbo. That model is quite limited in what it can do though. With only 4k context window and the need to read and write the entire code that is being modified... you can only work on small pieces of code with it.

I'll definitely think some more about this and try and find a good approach to adding support for 3.5.

Thanks again for the feedback.

@paul-gauthier paul-gauthier changed the title Changes not applied to file Changes not applied to file when using gpt-3.5-turbo May 31, 2023
@paul-gauthier
Copy link
Collaborator

I just pushed changes that allow aider to work with gpt-3.5-turbo. Let me know if it works for you.

GPT-3.5 is not able to reliably generate "edit blocks" to specify changes to files. The best approach is to ask it to simply return a new copy of the entire file, including the changes that it wants to make. Unfortunately, this wastes context window and is a bit slow. But it is fairly reliable.

So you can really only work with smaller source files with 3.5. This is because of the need to read/write the entire file content and the smaller 4 k-token context window.

Aider also disables the "ctags / repo map" feature when using GPT-3.5. That model probably isn't capable of using the additional code context, so it's not worth using up precious context window with the map.

@paul-gauthier
Copy link
Collaborator

I'm going to close this for now. Feel free to reopen or make a new issue if you have problems or questions about gpt-3.5-turbo support.

paul-gauthier added a commit that referenced this issue May 15, 2024
# Aider chat conversation:

USER: will this pickup the github pages jekyll site that is in this repy? Like the _layouts _data _posts etc dirs?

ASSISTANT: Yes, the current Dockerfile and scripts should pick up the GitHub Pages Jekyll site, including directories like `_layouts`, `_data`, `_posts`, etc., because the `COPY . /srv/jekyll` command in the Dockerfile copies the entire current directory (which should include those directories) into the Docker container.

However, to ensure everything works correctly, let's make sure the Dockerfile and scripts are set up to handle the Jekyll site properly. Here are the steps:

1. Ensure the Dockerfile is correctly set up to copy the entire site and install dependencies.
2. Ensure the build and run scripts are correctly set up to build the Docker image and run the container.

Let's review the current state of the files and make any necessary adjustments.

scripts/Dockerfile
```python
# Use the official Jekyll image from Docker Hub
FROM jekyll/jekyll:latest

# Set the working directory
WORKDIR /srv/jekyll

# Copy the current directory contents into the container at /srv/jekyll
COPY . /srv/jekyll

# Install any needed packages specified in Gemfile
RUN bundle install

# Expose port 4000 to the host
EXPOSE 4000

# Run Jekyll server
CMD ["jekyll", "serve", "--host", "0.0.0.0"]
```

scripts/build.sh
```python
#!/bin/bash

# Build the Docker image
docker build -t my-jekyll-site -f scripts/Dockerfile .
```

scripts/run.sh
```python
#!/bin/bash

# Run the Docker container
docker run --rm -v "$PWD:/srv/jekyll" -p 4000:4000 my-jekyll-site
```

These files should work as expected. The `COPY . /srv/jekyll` command in the Dockerfile will copy all the necessary Jekyll site files, including `_layouts`, `_data`, `_posts`, etc., into the Docker container. The `bundle install` command will install any dependencies specified in the `Gemfile`.

To verify, you can run the following commands in your project directory:

```sh
bash scripts/build.sh
bash scripts/run.sh
```

This will build the Docker image and start a container that serves your Jekyll site on `http://localhost:4000`. If you encounter any issues, please let me know!

USER: I ran this command:

 bash scripts/build.sh

And got this output:

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 435B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 101B 0.0s done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/jekyll/jekyll:latest
#3 DONE 0.6s

#4 [1/4] FROM docker.io/jekyll/jekyll:latest@sha256:400b8d1569f118bca8a3a09a25f32803b00a55d1ea241feaf5f904d66ca9c625
#4 DONE 0.0s

#5 [internal] load build context
#5 transferring context: 250.53kB 0.2s done
#5 DONE 0.2s

#6 [2/4] WORKDIR /srv/jekyll
#6 CACHED

#7 [3/4] COPY . /srv/jekyll
#7 CACHED

#8 [4/4] RUN bundle install
#8 6.277 Could not locate Gemfile
#8 ERROR: process "/bin/sh -c bundle install" did not complete successfully: exit code: 10
------
 > [4/4] RUN bundle install:
#8 6.277 Could not locate Gemfile
------
Dockerfile:11
--------------------
   9 |
  10 |     # Install any needed packages specified in Gemfile
  11 | >>> RUN bundle install
  12 |
  13 |     # Expose port 4000 to the host
--------------------
ERROR: failed to solve: process "/bin/sh -c bundle install" did not complete successfully: exit code: 10

ASSISTANT: The error indicates that the `Gemfile` is not being found in the context being copied into the Docker container. This could be because the `Gemfile` is not in the root directory of your project or it might be missing.

To resolve this, we need to ensure that the `Gemfile` is present in the root directory of your project. If it is not, you should add it. If it is present, we need to make sure it is being copied correctly.

Let's first verify that the `Gemfile` is in the root directory of your project. If it is not, please add it. If it is, we can proceed with the current Dockerfile and scripts.

Assuming the `Gemfile` is present in the root directory, the Dockerfile should work as expected. If the `Gemfile` is in a different directory, please let me know its location so we can adjust the Dockerfile accordingly.

If the `Gemfile` is missing, you can create a basic one with the following content:

Gemfile
```ruby
source 'https://rubygems.org'
gem 'jekyll'
```

Once the `Gemfile` is in place, you can re-run the build script:

```sh
bash scripts/build.sh
```

If you encounter any further issues, please let me know!

USER: please make it

ASSISTANT: Let's create the `Gemfile` in the root directory of your project.

Gemfile
```ruby
<<<<<<< SEARCH
=======
source 'https://rubygems.org'
gem 'jekyll'
>>>>>>> REPLACE
```

This `Gemfile` specifies the source for Ruby gems and includes the `jekyll` gem, which is necessary for your Jekyll site.

After adding this `Gemfile`, you can re-run the build script:

```sh
bash scripts/build.sh
```

This should resolve the issue with the missing `Gemfile` and allow the Docker image to be built successfully. If you encounter any further issues, please let me know!
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

2 participants