Refactoring and suggestions (#334)

This commit is contained in:
Plamen Ivanov
2023-06-23 13:01:29 +03:00
committed by GitHub
parent 14f79a8163
commit 1b2831ab85
28 changed files with 82 additions and 87 deletions

View File

@@ -60,7 +60,7 @@ representative at an online or offline event.
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at reported to the community leaders responsible for enforcement at
anton.osika@gmail.com. <anton.osika@gmail.com>.
All complaints will be reviewed and investigated promptly and fairly. All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of reporters of incidents. All community leaders are obligated to respect the privacy and security of reporters of incidents.

View File

@@ -15,7 +15,6 @@ To get started with contributing, please follow these steps:
7. Push to the branch: `git push origin my-branch-name`. 7. Push to the branch: `git push origin my-branch-name`.
8. Submit a pull request to the `main` branch of the original repository. 8. Submit a pull request to the `main` branch of the original repository.
## Code Style ## Code Style
Please make sure to follow the established code style guidelines for this project. Consistent code style helps maintain readability and makes it easier for others to contribute to the project. Please make sure to follow the established code style guidelines for this project. Consistent code style helps maintain readability and makes it easier for others to contribute to the project.
@@ -37,13 +36,13 @@ pre-commit installed at .git/hooks/pre-commit
Or you could just run `make dev-install` to install the dependencies and the hooks! Or you could just run `make dev-install` to install the dependencies and the hooks!
If you are not familiar with the concept of [git hooks](https://git-scm.com/docs/githooks) and/or [`pre-commit`](https://pre-commit.com/) please read the documentation to understand how they work. If you are not familiar with the concept of [git hooks](https://git-scm.com/docs/githooks) and/or [`pre-commit`](https://pre-commit.com/) please read the documentation to understand how they work.
As an introduction of the actual workflow, here is an example of the process you will encounter when you make a commit: As an introduction of the actual workflow, here is an example of the process you will encounter when you make a commit:
Let's add a file we have modified with some errors, see how the pre-commit hooks run `black` and fails. Let's add a file we have modified with some errors, see how the pre-commit hooks run `black` and fails.
`black` is set to automatically fix the issues it finds: `black` is set to automatically fix the issues it finds:
```bash ```bash
$ git add chat_to_files.py $ git add chat_to_files.py
$ git commit -m "commit message" $ git commit -m "commit message"
@@ -58,6 +57,7 @@ All done! ✨ 🍰 ✨
``` ```
You can see that `chat_to_files.py` is both staged and not staged for commit. This is because `black` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes. You can see that `chat_to_files.py` is both staged and not staged for commit. This is because `black` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes.
```bash ```bash
$ git status $ git status
On branch pre-commit-setup On branch pre-commit-setup
@@ -71,8 +71,8 @@ Changes not staged for commit:
modified: chat_to_files.py modified: chat_to_files.py
``` ```
Now let's add the file again to include the latest commits and see how `ruff` fails. Now let's add the file again to include the latest commits and see how `ruff` fails.
```bash ```bash
$ git add chat_to_files.py $ git add chat_to_files.py
$ git commit -m "commit message" $ git commit -m "commit message"
@@ -86,6 +86,7 @@ Found 2 errors (2 fixed, 0 remaining).
``` ```
Same as before, you can see that `chat_to_files.py` is both staged and not staged for commit. This is because `ruff` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes. Same as before, you can see that `chat_to_files.py` is both staged and not staged for commit. This is because `ruff` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes.
```bash ```bash
$ git add chat_to_files.py $ git add chat_to_files.py
$ git commit -m "commit message" $ git commit -m "commit message"
@@ -100,13 +101,10 @@ Now your file has been committed and you can push your changes.
At the beginning this might seem like a tedious process (having to add the file again after `black` and `ruff` have modified it) but it is actually very useful. It allows you to see what changes `black` and `ruff` have made to your files and make sure that they are correct before you commit them. At the beginning this might seem like a tedious process (having to add the file again after `black` and `ruff` have modified it) but it is actually very useful. It allows you to see what changes `black` and `ruff` have made to your files and make sure that they are correct before you commit them.
## Issue Tracker ## Issue Tracker
If you encounter any bugs, issues, or have feature requests, please [create a new issue](https://github.com/AntonOsika/gpt-engineer/issues/new) on the project's GitHub repository. Provide a clear and descriptive title along with relevant details to help us address the problem or understand your request. If you encounter any bugs, issues, or have feature requests, please [create a new issue](https://github.com/AntonOsika/gpt-engineer/issues/new) on the project's GitHub repository. Provide a clear and descriptive title along with relevant details to help us address the problem or understand your request.
## Licensing ## Licensing
By contributing to GPT Engineer, you agree that your contributions will be licensed under the [LICENSE](../LICENSE) file of the project. By contributing to GPT Engineer, you agree that your contributions will be licensed under the [LICENSE](../LICENSE) file of the project.

View File

@@ -4,12 +4,11 @@ about: All templates should use this format unless there is a reason not to
title: '' title: ''
labels: '' labels: ''
assignees: '' assignees: ''
--- ---
**YOU MAY DELETE THE ENTIRE TEMPLATE BELOW.** **YOU MAY DELETE THE ENTIRE TEMPLATE BELOW.**
# Issue Template ## Issue Template
## Expected Behavior ## Expected Behavior

View File

@@ -3,6 +3,7 @@
## How Has This Been Tested? ## How Has This Been Tested?
Please describe if you have either: Please describe if you have either:
- Generated the "example" project - Generated the "example" project
- Ran the entire benchmark suite - Ran the entire benchmark suite
- Something else - Something else

View File

@@ -1,25 +1,23 @@
name: Pytest Execution name: Pytest Execution
on: on:
pull_request: pull_request:
branches: branches: [main]
- main paths:
- "**.py"
push: push:
branches: branches: [main]
- main paths:
- "**.py"
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: "3.10"
cache: pip cache: pip
- name: Install package - name: Install package

View File

@@ -8,7 +8,15 @@ on:
jobs: jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0 - uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files

View File

@@ -1,34 +1,32 @@
# See https://pre-commit.com for more information # See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks # See https://pre-commit.com/hooks.html for more hooks
fail_fast: true fail_fast: true
default_stages: [commit]
repos: repos:
- repo: https://github.com/pre-commit/mirrors-mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0 rev: v1.3.0
hooks: hooks:
- id: mypy - id: mypy
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.3.0 rev: 23.3.0
hooks: hooks:
- id: black - id: black
args: [--config, pyproject.toml] args: [--config, pyproject.toml]
types: [python] types: [python]
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.272" rev: "v0.0.272"
hooks: hooks:
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.4.0
hooks: hooks:
- id: check-toml - id: check-toml
id: check-yaml - id: check-yaml
id: detect-private-key - id: detect-private-key
id: end-of-file-fixer - id: end-of-file-fixer
id: trailing-whitespace - id: trailing-whitespace

View File

@@ -50,4 +50,3 @@ run:
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \ @echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
source venv/bin/activate && \ source venv/bin/activate && \
gpt-engineer projects/$(name) gpt-engineer projects/$(name)

View File

@@ -1,9 +1,9 @@
# GPT Engineer # GPT Engineer
[![Discord Follow](https://dcbadge.vercel.app/api/server/4t5vXHhu?style=flat)](https://discord.gg/4t5vXHhu) [![Discord Follow](https://dcbadge.vercel.app/api/server/4t5vXHhu?style=flat)](https://discord.gg/4t5vXHhu)
[![GitHub Repo stars](https://img.shields.io/github/stars/AntonOsika/gpt-engineer?style=social)](https://github.com/AntonOsika/gpt-engineer) [![GitHub Repo stars](https://img.shields.io/github/stars/AntonOsika/gpt-engineer?style=social)](https://github.com/AntonOsika/gpt-engineer)
[![Twitter Follow](https://img.shields.io/twitter/follow/antonosika?style=social)](https://twitter.com/AntonOsika) [![Twitter Follow](https://img.shields.io/twitter/follow/antonosika?style=social)](https://twitter.com/AntonOsika)
**Specify what you want it to build, the AI asks for clarification, and then builds it.** **Specify what you want it to build, the AI asks for clarification, and then builds it.**
GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt. GPT Engineer is made to be easy to adapt, extend, and make your agent learn how you want your code to look. It generates an entire codebase based on a prompt.
@@ -11,6 +11,7 @@ GPT Engineer is made to be easy to adapt, extend, and make your agent learn how
[Demo](https://twitter.com/antonosika/status/1667641038104674306) 👶🤖 [Demo](https://twitter.com/antonosika/status/1667641038104674306) 👶🤖
## Project philosophy ## Project philosophy
- Simple to get value - Simple to get value
- Flexible and easy to add new own "AI steps". See `steps.py`. - Flexible and easy to add new own "AI steps". See `steps.py`.
- Incrementally build towards a user experience of: - Incrementally build towards a user experience of:
@@ -39,19 +40,20 @@ With an api key that has GPT4 access run:
- `export OPENAI_API_KEY=[your api key]` - `export OPENAI_API_KEY=[your api key]`
**Run**: **Run**:
- Create an empty folder. If inside the repo, you can run: - Create an empty folder. If inside the repo, you can run:
- `cp -r projects/example/ projects/my-new-project` - `cp -r projects/example/ projects/my-new-project`
- Fill in the `main_prompt` file in your new folder - Fill in the `main_prompt` file in your new folder
- `gpt-engineer projects/my-new-project` - `gpt-engineer projects/my-new-project`
- (Note, `gpt-engineer --help` lets you see all available options. For example `--steps use_feedback` lets you improve/fix code in a project) - (Note, `gpt-engineer --help` lets you see all available options. For example `--steps use_feedback` lets you improve/fix code in a project)
**Results** **Results**:
- Check the generated files in `projects/my-new-project/workspace` - Check the generated files in `projects/my-new-project/workspace`
## Features ## Features
You can specify the "identity" of the AI agent by editing the files in the `identity` folder. You can specify the "identity" of the AI agent by editing the files in the `identity` folder.
Editing the identity, and evolving the `main_prompt`, is currently how you make the agent remember things between projects. Editing the identity, and evolving the `main_prompt`, is currently how you make the agent remember things between projects.
@@ -59,13 +61,13 @@ Editing the identity, and evolving the `main_prompt`, is currently how you make
Each step in `steps.py` will have its communication history with GPT4 stored in the logs folder, and can be rerun with `scripts/rerun_edited_message_logs.py`. Each step in `steps.py` will have its communication history with GPT4 stored in the logs folder, and can be rerun with `scripts/rerun_edited_message_logs.py`.
## Contributing ## Contributing
We are building the open platform for devs to tinker with and build their personal code-generation toolbox. We are building the open platform for devs to tinker with and build their personal code-generation toolbox.
If you want to contribute, please check out the [roadmap](https://github.com/AntonOsika/gpt-engineer/blob/main/ROADMAP.md), [projects](https://github.com/AntonOsika/gpt-engineer/projects?query=is%3Aopen) or [issues tab](https://github.com/AntonOsika/gpt-engineer/issues) in the GitHub repo. You are welcome to read the [contributing document](.github/CONTRIBUTING.md) and join our [Discord 💬](https://discord.gg/4t5vXHhu). If you want to contribute, please check out the [roadmap](https://github.com/AntonOsika/gpt-engineer/blob/main/ROADMAP.md), [projects](https://github.com/AntonOsika/gpt-engineer/projects?query=is%3Aopen) or [issues tab](https://github.com/AntonOsika/gpt-engineer/issues) in the GitHub repo. You are welcome to read the [contributing document](.github/CONTRIBUTING.md) and join our [Discord 💬](https://discord.gg/4t5vXHhu).
We are currently looking for more maintainers and community organisers. Email anton.osika@gmail.com if you are interested in an official role. We are currently looking for more maintainers and community organisers. Email <anton.osika@gmail.com> if you are interested in an official role.
## Example ## Example
https://github.com/AntonOsika/gpt-engineer/assets/4467025/6e362e45-4a94-4b0d-973d-393a31d92d9b <https://github.com/AntonOsika/gpt-engineer/assets/4467025/6e362e45-4a94-4b0d-973d-393a31d92d9b>

View File

@@ -7,7 +7,6 @@ There are three main milestones we believe will 2x gpt-engineer's reliability an
- Make code generation become small, verifiable steps - Make code generation become small, verifiable steps
- Run tests and fix errors with GPT4 - Run tests and fix errors with GPT4
## Steps to achieve our roadmap ## Steps to achieve our roadmap
- [ ] Continuous evaluation of our progress - [ ] Continuous evaluation of our progress
@@ -32,10 +31,10 @@ performance over time
task, by giving it few shot example of what are usually "the right-sized steps" to carry task, by giving it few shot example of what are usually "the right-sized steps" to carry
out for other projects out for other projects
# How you can help out # How you can help out
You can: You can:
- Submit your first PR to address an [issue](https://github.com/AntonOsika/gpt-engineer/issues) - Submit your first PR to address an [issue](https://github.com/AntonOsika/gpt-engineer/issues)
- Submit PRs to address one of the items in the roadmap - Submit PRs to address one of the items in the roadmap
- Review your first PR/issue and propose next steps (further review, merge, close) - Review your first PR/issue and propose next steps (further review, merge, close)
@@ -48,4 +47,3 @@ Volunteer work in any of these gets acknowledged.
### Ad hoc experiments ### Ad hoc experiments
- [ ] Try Microsoft guidance, and benchmark if this helps improve performance - [ ] Try Microsoft guidance, and benchmark if this helps improve performance

View File

@@ -1,10 +1,10 @@
# Benchmarks # Benchmarks
```bash ```bash
$ python scripts/benchmark.py python scripts/benchmark.py
``` ```
# 2023-06-21 ## 2023-06-21
| Benchmark | Ran | Works | Perfect | | Benchmark | Ran | Works | Perfect |
|--------------------|-----|-------|---------| |--------------------|-----|-------|---------|
@@ -20,8 +20,8 @@ $ python scripts/benchmark.py
| password_generator | ✅ | ✅ | ✅ | | password_generator | ✅ | ✅ | ✅ |
| todo_list | ✅ | ✅ | ✅ | | todo_list | ✅ | ✅ | ✅ |
## Notes on the errors
# Notes on the errors
Most errors come from that the "generate entrypoint" are incorrect. Ignoring Most errors come from that the "generate entrypoint" are incorrect. Ignoring
those, we get 8/11 fully correct. those, we get 8/11 fully correct.
@@ -31,8 +31,7 @@ One error was trying to modify a constant.
One error was that the html template was not fully filled in. One error was that the html template was not fully filled in.
One error is that a dependency was used incorrectly and easy to fix One error is that a dependency was used incorrectly and easy to fix
## 2023-06-19
# 2023-06-19
| Benchmark | Ran | Works | Perfect | | Benchmark | Ran | Works | Perfect |
|--------------------|-----|-------|---------| |--------------------|-----|-------|---------|
@@ -48,9 +47,10 @@ One error is that a dependency was used incorrectly and easy to fix
| password_generator | ✅ | ✅ | ✅ | | password_generator | ✅ | ✅ | ✅ |
| todo_list | ✅ | ❌ | ❌ | | todo_list | ✅ | ❌ | ❌ |
## Notes on the errors
# Notes on the errors
**timer_app** almost works with unit tests config **timer_app** almost works with unit tests config
- failure mode: undefined import/conflicting names - failure mode: undefined import/conflicting names
**file_explorer** works **file_explorer** works
@@ -58,17 +58,17 @@ One error is that a dependency was used incorrectly and easy to fix
**file organiser**: works **file organiser**: works
**image_resizer** almost works with unit tests config **image_resizer** almost works with unit tests config
- failure mode: undefined import - failure mode: undefined import
**todo_list** runs. doesn't really work with unit tests config **todo_list** runs. doesn't really work with unit tests config
Uncaught ReferenceError: module is not defined Uncaught ReferenceError: module is not defined
- failure mode: placeholder text
- failure mode: placeholder text
url_shortner starts but gets the error: url_shortner starts but gets the error:
SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 8636125824 and this is thread id 13021003776. SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 8636125824 and this is thread id 13021003776.
markdown_editor: markdown_editor:
failing tests, 'WebDriver' object has no attribute 'find_element_by_id' failing tests, 'WebDriver' object has no attribute 'find_element_by_id'

View File

@@ -1,2 +1 @@
Create a basic file explorer CLI tool in Python that allows users to navigate through directories, view file contents, and perform basic file operations (copy, move, delete). Create a basic file explorer CLI tool in Python that allows users to navigate through directories, view file contents, and perform basic file operations (copy, move, delete).

View File

@@ -1,2 +1 @@
Create a CLI tool in Python that allows users to resize images by specifying the desired width and height. Use the Pillow library for image manipulation. Create a CLI tool in Python that allows users to resize images by specifying the desired width and height. Use the Pillow library for image manipulation.

View File

@@ -1,2 +1 @@
Create a simple timer app using HTML, CSS, and JavaScript that allows users to set a countdown timer and receive an alert when the time is up. Create a simple timer app using HTML, CSS, and JavaScript that allows users to set a countdown timer and receive an alert when the time is up.

View File

@@ -1,2 +1 @@
Create a simple to-do list app using HTML, CSS, and JavaScript. Store tasks in local storage and allow users to add, edit, and delete tasks. Create a simple to-do list app using HTML, CSS, and JavaScript. Store tasks in local storage and allow users to add, edit, and delete tasks.

View File

@@ -6,4 +6,3 @@ pytest==7.3.1
ruff==0.0.272 ruff==0.0.272
termcolor==2.3.0 termcolor==2.3.0
typer==0.9.0 typer==0.9.0

View File

@@ -1,6 +1,7 @@
# list all folders in benchmark folder # list all folders in benchmark folder
# for each folder, run the benchmark # for each folder, run the benchmark
import contextlib
import os import os
import subprocess import subprocess
@@ -59,7 +60,7 @@ def main(
print(f.read()) print(f.read())
print() print()
try: with contextlib.suppress(KeyboardInterrupt):
subprocess.run( subprocess.run(
[ [
"python", "python",
@@ -70,8 +71,6 @@ def main(
"execute_only", "execute_only",
], ],
) )
except KeyboardInterrupt:
pass
if __name__ == "__main__": if __name__ == "__main__":