Address Examples Initiative

pull/9/head
juleshenry 2023-04-11 21:02:39 -05:00
rodzic 1b9649ed7a
commit 31319dd273
3 zmienionych plików z 31 dodań i 1 usunięć

Wyświetl plik

@ -20,7 +20,7 @@ Add your openAI api key to `openai_key.txt` - _warning!_ by default this uses GP
To run with gpt-4 (the default, tested option):
python wolverine.py buggy_script.py "subtract" 20 3
python wolverine.py examples/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:

Wyświetl plik

@ -1,5 +1,9 @@
import sys
import fire
"""
Run With: `wolverine examples/buggy_script.py "subtract" 20 3`
Purpose: Show self-regenerating fixing of subtraction operator
"""
def add_numbers(a, b):
return a + b

Wyświetl plik

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import fire
"""
Run With: with `wolverine examples/buggy_script_2.py "return_2"`
Purpose: Fix singleton code bug in Python
"""
class SingletonClass(object):
def __new__(cls):
if not hasattr(cls, 'instance'):
cls.instance = super(SingletonClass, cls).__new__(cls)
return cls.instance
def return_2():
"""
Always returns 2
"""
singleton = SingletonClass()
new_singleton = SingletonClass()
singleton.a = 1
new_singleton.a = 2
return singleton.a + singleton.a
if __name__=="__main__":
fire.Fire()