Give your python scripts regenerative healing abilities!
Go to file
Prayag Shah 946e15ff20 Squashed commit of the following:
commit 742aaaf9d1
Merge: f2d21e7 fe87faa
Author: biobootloader <128252497+biobootloader@users.noreply.github.com>
Date:   Fri Apr 14 15:44:12 2023 -0700

    Merge pull request #13 from fsboehme/main

    more robust parsing of JSON (+ indentation)

commit fe87faa2fb
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 17:49:48 2023 -0400

    cleanup

commit 4db9d1bf43
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 17:49:09 2023 -0400

    more cleanup

commit e1d0a790f8
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 17:46:18 2023 -0400

    cleanup

commit b044882dc3
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 17:37:27 2023 -0400

    remove duplicate code from rebase

commit dd174cf30e
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 17:15:07 2023 -0400

    add DEFAULT_MODEL to .env.sample

    + fix typo

commit 2497fb816b
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Fri Apr 14 16:29:45 2023 -0400

    move json_validated_response to standalone function

commit 923f7057e3
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Thu Apr 13 11:35:24 2023 -0400

    update readme

    - updated readme to mention .env
    - added model arg back

commit 0656a83da7
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Thu Apr 13 11:29:06 2023 -0400

    recursive calls if not json parsable

    - makes recursive calls to API (with a comment about it not being parsable) if response was not parsable
    - pass prompt.txt as system prompt
    - use env var for `DEFAULT_MODEL`
    - use env var for OPENAI_API_KEY

commit 7c072fba2a
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Thu Apr 13 11:24:41 2023 -0400

    update prompt to make it pay attention to indentation

commit c62f91eaee
Author: Felix Boehme <fsboehme@gmail.com>
Date:   Thu Apr 13 11:23:44 2023 -0400

    Update .gitignore

commit f2d21e7b93
Merge: 0420860 6343f6f
Author: biobootloader <128252497+biobootloader@users.noreply.github.com>
Date:   Fri Apr 14 13:59:44 2023 -0700

    Merge pull request #12 from chriscarrollsmith/main

    Implemented .env file API key storage

commit 6343f6f50b
Author: biobootloader <128252497+biobootloader@users.noreply.github.com>
Date:   Fri Apr 14 13:59:31 2023 -0700

    Apply suggestions from code review

commit d87ebfa46f
Merge: 9af5480 75f08e2
Author: Christopher Carroll Smith <75859865+chriscarrollsmith@users.noreply.github.com>
Date:   Fri Apr 14 16:53:25 2023 -0400

    Merge branch 'main' of https://github.com/chriscarrollsmith/wolverine

commit 9af5480b89
Author: Christopher Carroll Smith <75859865+chriscarrollsmith@users.noreply.github.com>
Date:   Fri Apr 14 16:53:02 2023 -0400

    Added python-dotenv to requirements.txt

commit 75f08e2852
Merge: e8a8931 0420860
Author: Christopher Carroll Smith <75859865+chriscarrollsmith@users.noreply.github.com>
Date:   Fri Apr 14 16:50:29 2023 -0400

    Merge pull request #1 from biobootloader/main

    Reconcile with master branch

commit 04208605fe
Merge: d547822 6afb4db
Author: biobootloader <128252497+biobootloader@users.noreply.github.com>
Date:   Fri Apr 14 13:22:53 2023 -0700

    Merge pull request #20 from eltociear/patch-1

    fix typo in README.md

commit d54782230c
Merge: 1b9649e 4863df6
Author: biobootloader <128252497+biobootloader@users.noreply.github.com>
Date:   Fri Apr 14 13:19:43 2023 -0700

    Merge pull request #17 from hemangjoshi37a/main

    added `star-history` 

commit 6afb4db2ff
Author: Ikko Eltociear Ashimine <eltociear@gmail.com>
Date:   Fri Apr 14 16:37:05 2023 +0900

    fix typo in README.md

    reliablity -> reliability

commit 4863df6898
Author: Hemang Joshi <hemangjoshi37a@gmail.com>
Date:   Fri Apr 14 10:27:32 2023 +0530

    added `star-history`

    added `star-history`

commit e8a893156e
Author: Christopher Carroll Smith <75859865+chriscarrollsmith@users.noreply.github.com>
Date:   Wed Apr 12 13:45:54 2023 -0400

    Implemented .env file API key storage
2023-04-15 02:22:57 -03:00
.env.sample Squashed commit of the following: 2023-04-15 02:22:57 -03:00
.flake8 use Fire for args, add flag to use 3.5-turbo 2023-04-08 12:38:14 -07:00
.gitignore Squashed commit of the following: 2023-04-15 02:22:57 -03:00
LICENSE initial commit 2023-03-18 15:16:47 -07:00
README.md Squashed commit of the following: 2023-04-15 02:22:57 -03:00
buggy_script.py initial commit 2023-03-18 15:16:47 -07:00
prompt.txt Squashed commit of the following: 2023-04-15 02:22:57 -03:00
requirements.txt Squashed commit of the following: 2023-04-15 02:22:57 -03:00
wolverine.py Squashed commit of the following: 2023-04-15 02:22:57 -03:00

README.md

Wolverine

About

Give your python scripts regenerative healing abilities!

Run your scripts with Wolverine and when they crash, GPT-4 edits them and explains what went wrong. Even if you have many bugs it will repeatedly rerun until it's fixed.

For a quick demonstration see my demo video on twitter.

Setup

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.sample .env

Add your openAI api key to .env

warning! By default wolverine uses GPT-4 and may make many repeated calls to the api.

Example Usage

To run with gpt-4 (the default, tested option):

python wolverine.py buggy_script.py "subtract" 20 3

You can also run with other models, but be warned they may not adhere to the edit format as well:

python wolverine.py --model=gpt-3.5-turbo buggy_script.py "subtract" 20 3

You can also use flag --confirm=True which will ask you yes or no before making changes to the file. If flag is not used then it will apply the changes to the file

python wolverine.py buggy_script.py "subtract" 20 3 --confirm=True

If you want to use GPT-3.5 by default instead of GPT-4 uncomment the default model line in .env:

DEFAULT_MODEL=gpt-3.5-turbo

Future Plans

This is just a quick prototype I threw together in a few hours. There are many possible extensions and contributions are welcome:

  • add flags to customize usage, such as asking for user confirmation before running changed code
  • further iterations on the edit format that GPT responds in. Currently it struggles a bit with indentation, but I'm sure that can be improved
  • a suite of example buggy files that we can test prompts on to ensure reliability and measure improvement
  • multiple files / codebases: send GPT everything that appears in the stacktrace
  • graceful handling of large files - should we just send GPT relevant classes / functions?
  • extension to languages other than python

Star History

Star History Chart