Skip to content

Commit

Permalink
Refactoring and suggestions (AntonOsika#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1lgor authored Jun 23, 2023
1 parent 14f79a8 commit 1b2831a
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
<[email protected]>.
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.
Expand Down Expand Up @@ -128,4 +128,4 @@ For answers to common questions about this code of conduct, see the FAQ at
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
[translations]: https://www.contributor-covenant.org/translations
10 changes: 4 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ To get started with contributing, please follow these steps:
7. Push to the branch: `git push origin my-branch-name`.
8. Submit a pull request to the `main` branch of the original repository.


## 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.
Expand All @@ -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!


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:

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:

```bash
$ git add chat_to_files.py
$ git commit -m "commit message"
Expand All @@ -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.

```bash
$ git status
On branch pre-commit-setup
Expand All @@ -71,8 +71,8 @@ Changes not staged for commit:
modified: chat_to_files.py
```


Now let's add the file again to include the latest commits and see how `ruff` fails.

```bash
$ git add chat_to_files.py
$ git commit -m "commit message"
Expand All @@ -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.

```bash
$ git add chat_to_files.py
$ git commit -m "commit message"
Expand All @@ -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.



## 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.


## Licensing

By contributing to GPT Engineer, you agree that your contributions will be licensed under the [LICENSE](../LICENSE) file of the project.
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ about: All templates should use this format unless there is a reason not to
title: ''
labels: ''
assignees: ''

---

**YOU MAY DELETE THE ENTIRE TEMPLATE BELOW.**

# Issue Template
## Issue Template

## Expected Behavior

Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## How Has This Been Tested?

Please describe if you have either:

- Generated the "example" project
- Ran the entire benchmark suite
- Something else
16 changes: 7 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
name: Pytest Execution
on:
pull_request:
branches:
- main
branches: [main]
paths:
- "**.py"
push:
branches:
- main
branches: [main]
paths:
- "**.py"

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: "3.10"
cache: pip

- name: Install package
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ on:
jobs:
pre-commit:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
- uses: actions/checkout@v3

- uses: actions/setup-python@v4

- uses: pre-commit/[email protected]
with:
extra_args: --all-files
50 changes: 24 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
fail_fast: true

default_stages: [commit]

repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--config, pyproject.toml]
types: [python]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--config, pyproject.toml]
types: [python]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
id: check-yaml
id: detect-private-key
id: end-of-file-fixer
id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.272"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ run:
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
source venv/bin/activate && \
gpt-engineer projects/$(name)

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# GPT Engineer

[![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)
[![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.**

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.

[Demo](https://twitter.com/antonosika/status/1667641038104674306) 👶🤖

## Project philosophy

- Simple to get value
- Flexible and easy to add new own "AI steps". See `steps.py`.
- Incrementally build towards a user experience of:
Expand Down Expand Up @@ -39,33 +40,34 @@ With an api key that has GPT4 access run:

- `export OPENAI_API_KEY=[your api key]`


**Run**:

- Create an empty folder. If inside the repo, you can run:
- `cp -r projects/example/ projects/my-new-project`
- Fill in the `main_prompt` file in your new folder
- `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)

**Results**
- Check the generated files in `projects/my-new-project/workspace`
**Results**:

- Check the generated files in `projects/my-new-project/workspace`

## Features

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.

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

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).

We are currently looking for more maintainers and community organisers. Email [email protected] if you are interested in an official role.

We are currently looking for more maintainers and community organisers. Email <[email protected]> if you are interested in an official role.

## 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>
6 changes: 2 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Run tests and fix errors with GPT4


## Steps to achieve our roadmap

- [ ] Continuous evaluation of our progress
Expand All @@ -32,10 +31,10 @@ performance over time
task, by giving it few shot example of what are usually "the right-sized steps" to carry
out for other projects



# How you can help out

You can:

- 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
- Review your first PR/issue and propose next steps (further review, merge, close)
Expand All @@ -48,4 +47,3 @@ Volunteer work in any of these gets acknowledged.

### Ad hoc experiments
- [ ] Try Microsoft guidance, and benchmark if this helps improve performance

16 changes: 8 additions & 8 deletions benchmark/RESULTS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Benchmarks

```bash
$ python scripts/benchmark.py
python scripts/benchmark.py
```

# 2023-06-21
## 2023-06-21

| Benchmark | Ran | Works | Perfect |
|--------------------|-----|-------|---------|
Expand All @@ -20,8 +20,8 @@ $ python scripts/benchmark.py
| password_generator ||||
| todo_list ||||

## Notes on the errors

# Notes on the errors
Most errors come from that the "generate entrypoint" are incorrect. Ignoring
those, we get 8/11 fully correct.

Expand All @@ -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 is that a dependency was used incorrectly and easy to fix


# 2023-06-19
## 2023-06-19

| Benchmark | Ran | Works | Perfect |
|--------------------|-----|-------|---------|
Expand All @@ -48,27 +47,28 @@ One error is that a dependency was used incorrectly and easy to fix
| password_generator ||||
| todo_list ||||

## Notes on the errors

# Notes on the errors
**timer_app** almost works with unit tests config

- failure mode: undefined import/conflicting names

**file_explorer** works

**file organiser**: works

**image_resizer** almost works with unit tests config

- failure mode: undefined import

**todo_list** runs. doesn't really work with unit tests config
Uncaught ReferenceError: module is not defined
- failure mode: placeholder text

- failure mode: placeholder text

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.


markdown_editor:
failing tests, 'WebDriver' object has no attribute 'find_element_by_id'

Expand Down
2 changes: 1 addition & 1 deletion benchmark/currency_converter/main_prompt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Build a currency converter app using an API for exchange rates. Use HTML, CSS, and JavaScript for the frontend and Node.js for the backend. Allow users to convert between different currencies.
Build a currency converter app using an API for exchange rates. Use HTML, CSS, and JavaScript for the frontend and Node.js for the backend. Allow users to convert between different currencies.
1 change: 0 additions & 1 deletion benchmark/file_explorer/main_prompt
Original file line number Diff line number Diff line change
@@ -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).

2 changes: 1 addition & 1 deletion benchmark/file_organizer/main_prompt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Create a file organizer CLI tool in Python that sorts files in a directory based on their file types (e.g., images, documents, audio) and moves them into corresponding folders.
Create a file organizer CLI tool in Python that sorts files in a directory based on their file types (e.g., images, documents, audio) and moves them into corresponding folders.
1 change: 0 additions & 1 deletion benchmark/image_resizer/main_prompt
Original file line number Diff line number Diff line change
@@ -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.

2 changes: 1 addition & 1 deletion benchmark/markdown_editor/main_prompt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Build a simple markdown editor using HTML, CSS, and JavaScript. Allow users to input markdown text and display the formatted output in real-time.
Build a simple markdown editor using HTML, CSS, and JavaScript. Allow users to input markdown text and display the formatted output in real-time.
2 changes: 1 addition & 1 deletion benchmark/password_generator/main_prompt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Create a password generator CLI tool in Python that generates strong, random passwords based on user-specified criteria, such as length and character types (letters, numbers, symbols).
Create a password generator CLI tool in Python that generates strong, random passwords based on user-specified criteria, such as length and character types (letters, numbers, symbols).
2 changes: 1 addition & 1 deletion benchmark/pomodoro_timer/main_prompt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Develop a Pomodoro timer app using HTML, CSS, and JavaScript. Allow users to set work and break intervals and receive notifications when it's time to switch.
Develop a Pomodoro timer app using HTML, CSS, and JavaScript. Allow users to set work and break intervals and receive notifications when it's time to switch.
1 change: 0 additions & 1 deletion benchmark/timer_app/main_prompt
Original file line number Diff line number Diff line change
@@ -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.

1 change: 0 additions & 1 deletion benchmark/todo_list/main_prompt
Original file line number Diff line number Diff line change
@@ -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.

Loading

0 comments on commit 1b2831a

Please sign in to comment.